Jump to content

Recommended Posts

I'm currently on DEV branch and not sure if this is a bug or not on DEV branch.

 

I am trying both IF Then and Switch:Case codes but both are not working as i hope.

 

Basically seems to be ignoring the CONDITIONS and executing the scripts twice that it should be calling when the CONDITION is met.  Any ideas?

Currently value = "intelPoints = 0;"

_RandomIntel = execvm "SPAWN\IntelHint.sqf";
_HVTIntel = execvm "SPAWN\BOMBERHINT.sqf";
_INTELTYPE = [_RandomIntel,_HVTIntel] call BIS_fnc_selectRandom; 

_Case1 = false;
_Case2 = false;
_Case3 = false;
_Case4 = false;
_Case5 = false;

If (intelPoints == 60) then {_Case1 = true};
If (intelPoints == 100) then {_Case2 = true};
If (intelPoints == 150) then {_Case3 = true};
If (intelPoints == 200) then {_Case4 = true};
If (intelPoints == 300) then {_Case5 = true};


switch (true) do {
case (_Case1): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"]; };
case (_Case2): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"]; };
case (_Case3): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];}; 
case (_Case4): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];}; 
case (_Case5): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];}; 
default {}; 

Share this post


Link to post
Share on other sites

FYI:  I tried putting the IF conditions directly in the CASE condition field as well with same results.  It should work that way too, correct?

Share this post


Link to post
Share on other sites

The switch is not closed.  ie switch (true) do {....}; Why not just test the intelPoints  in the case? 


switch (true) do {
case (intelPoints == 60): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];};
case (intelPoints == 100): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];};
case (intelPoints == 150): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];}; 
case (intelPoints == 200): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];}; 
case (intelPoints == 300): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];}; 
default {}; 
};

  • Like 1

Share this post


Link to post
Share on other sites

Stupid me!! :936:

 

Yes that is what i initially wanted.  But I never used Switch:CASE before so i thought i may be doing something wrong.  I will try that again.  Thanks man

Share this post


Link to post
Share on other sites

Ok new bug?  Sorry.  So originally i did have the CASe correctly with the closed bracket, but now finding out taht the private value i am creating is actually running the code instead of being called?  Or am i miss understanding this?

 

So for example, i have the following setup:

_RandomIntel = execvm "SPAWN\IntelHint.sqf";
_HVTIntel = execvm "SPAWN\BOMBERHINT.sqf";
_INTELTYPE = [_RandomIntel,_HVTIntel] call BIS_fnc_selectRandom; 

If (true) then {_INTELTYPE};  //Only execute_INTELTYPE now

Basically it is calling the scripts 3 times before the Condition is even looked at.  If it doesnt work this way, how can i get it two choose between to random scripts?

Share this post


Link to post
Share on other sites

This doesn't change anything, but another way of writing it as well:

switch (intelPoints) do {
case (60): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];};
case (100): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];};
case (150): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];}; 
case (200): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];}; 
case (300): {_INTELTYPE; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];}; 
default {}; 
};

When you execVM something, it returns a handle, what you need to do is:

_RandomIntel = {execVM "SPAWN\IntelHint.sqf"};
_HVTIntel= {execVM "SPAWN\BOMBERHINT.sqf"};
_INTELTYPE = selectRandom [_RandomIntel,_HVTIntel];
//in your switch cases:

call _INTELTYPE;

Or:

_intelScripts = ["SPAWN\IntelHint.sqf","SPAWN\BOMBERHINT.sqf"];
_INTELTYPE = selectRandom _intelScripts;

//in your switch cases:
execVM _INTELTYPE;

Share this post


Link to post
Share on other sites

Repeated code makes pandas cry.

 

Maybe this?

_randomIntel = {execVM "SPAWN\IntelHint.sqf"};
_hvtIntel = {execVM "SPAWN\BOMBERHINT.sqf"};
_intelType = selectRandom [_randomIntel, _hvtIntel];
_pointRange = [60, 100, 150, 200, 300];

if (intelPoints in _pointRange ) then {
	call _intelType;
	cutText["...You found a piece of intel.  Check your Map!", "PLAIN"];
};

Share this post


Link to post
Share on other sites

Thanks brother.  You wouldnt believe what i was just trying to do...LOL

 

:icon_redface:

RANDOMINTEL = {
_RandomIntel = execvm "SPAWN\IntelHint.sqf";};

HVTINTEL = {
_HVTIntel = execvm "SPAWN\BOMBERHINT.sqf";};

//_INTELTYPE = [_RandomIntel,_HVTIntel] call BIS_fnc_selectRandom; 

CALLNOW = {
_luck = (random 100);
If (_luck <= 50) then {call RANDOMINTEL} ELSE {call HVTINTEL};
};

switch (true) do {
case (intelPoints == 60): {call CALLNOW; cutText["...You found a piece of intel.  Check your Map!","PLAIN"];};

Share this post


Link to post
Share on other sites

 

Repeated code makes pandas cry.

 

Maybe this?

_randomIntel = {execVM "SPAWN\IntelHint.sqf"};
_hvtIntel = {execVM "SPAWN\BOMBERHINT.sqf"};
_intelType = selectRandom [_randomIntel, _hvtIntel];
_pointRange = [60, 100, 150, 200, 300];

if (intelPoints in _pointRange ) then {
	call _intelType;
	cutText["...You found a piece of intel.  Check your Map!", "PLAIN"];
};

 

I wasted my all my "likes" for today already on the Tanoa thread, so thanks guys for the tips/help.

Share this post


Link to post
Share on other sites

I wasted my all my "likes" for today already on the Tanoa thread

 

Haha, same here!  So many amazing screenshots.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×