Jump to content
Sign in to follow this  
ra1n0fpa1n

Conditional Scripting With Greater than less than

Recommended Posts

Sorry For Double Posting like this i wrote the title wrong

I understand how conditional scripting works but i need to know how i could set up this conditional script with integrating the greater than and less than and greater than equal to into the script

To make an example i want i can only access a certain script if i have a value no less than 3 but can be 3 (so greater than equal to 3) in this case i want to make it so the score total needs to be at least 3 points to access the script

So here are my examples (they are just irrelevant examples but will be used in the same way)

if (score player => 3) then

{hint "You Must Destroy The Tank First";}

else

{hint "Rescue the VIP";};

If anyone can and correct me and help it would be much appreciated

Edited by ra1n0fpa1n

Share this post


Link to post
Share on other sites

HERE you go tested and working

_points = score _caller;


if (_points > 5) then // checks for player / caller of script has 5 points
{

==> YOUR CODE GOES HERE<==

}
else

{
hint "you do not have 5 Points Available to use";
};

and if you want the player to lose points for doing this then add


ParaCost =
          {		
	        _pscore = -5;	
			if (isServer) then 
			{
			player addScore _pscore; // for hosted environment
			hint format ["%1 lost %2 Points for usingwhatever you want", player, _pscore];
			} 
		    else

		    {
			paddscore = [player, _pscore]; publicVariable "paddscore";
		    hint format ["%1 lost %2 Points for using whatever you want", player, _pscore];
			};				


so it looks like this

usageCost =
          {		
	        _pscore = -5;	
			if (isServer) then 
			{
			player addScore _pscore; // for hosted environment
			hint format ["%1 lost %2 Points for usingwhatever you want", player, _pscore];
			} 
		    else

		    {
			paddscore = [player, _pscore]; publicVariable "paddscore";
		    hint format ["%1 lost %2 Points for using whatever you want", player, _pscore];
			};	

_points = score _caller;


if (_points > 5) then // checks for player / caller of script has 5 points
{

==> YOUR CODE GOES HERE<==
[_caller,-5] call usageCost;

}
else

{
hint "you do not have 5 Points Available to use";
};


Edited by hogmason

Share this post


Link to post
Share on other sites

i forgot the

_caller = _this select 0;

place this above the

_points = score _caller;

Share this post


Link to post
Share on other sites
HERE you go tested and working

_points = score _caller;


if (_points > 5) then // checks for player / caller of script has 5 points
{

==> YOUR CODE GOES HERE<==

}
else

{
hint "you do not have 5 Points Available to use";
};

and if you want the player to lose points for doing this then add


ParaCost =
          {		
	        _pscore = -5;	
			if (isServer) then 
			{
			player addScore _pscore; // for hosted environment
			hint format ["%1 lost %2 Points for usingwhatever you want", player, _pscore];
			} 
		    else

		    {
			paddscore = [player, _pscore]; publicVariable "paddscore";
		    hint format ["%1 lost %2 Points for using whatever you want", player, _pscore];
			};				


so it looks like this

usageCost =
          {		
	        _pscore = -5;	
			if (isServer) then 
			{
			player addScore _pscore; // for hosted environment
			hint format ["%1 lost %2 Points for usingwhatever you want", player, _pscore];
			} 
		    else

		    {
			paddscore = [player, _pscore]; publicVariable "paddscore";
		    hint format ["%1 lost %2 Points for using whatever you want", player, _pscore];
			};	

_points = score _caller;


if (_points > 5) then // checks for player / caller of script has 5 points
{

==> YOUR CODE GOES HERE<==
[_caller,-5] call usageCost;

}
else

{
hint "you do not have 5 Points Available to use";
};


Thank You SOOOO MUCH ive been stuck on this for the whole day

Share this post


Link to post
Share on other sites

and if you are using without an addaction like in the example just change

_caller = _this select 0;

to

_caller = player;

or if you want the score for say west or east side to activate the code use

_caller = scoreSide west; // or east whatever you need

hope all this helps

---------- Post added at 13:01 ---------- Previous post was at 13:00 ----------

no probs mate good luck ;)

Share this post


Link to post
Share on other sites

There is no "else if" in SQF, so you're probably failing for syntax error of trying to use else if. Use non-odd formatting. :)

// playerscore being some variable you created since the score command only works in MP

if (playerscore <= 3) then {
    hint "You Must Destroy The Tank First";
};

if (playerscore > 3) then {
    hint "Rescue the VIP";
};

// use this to increase the variable playerscore
playerscore = playerscore + 1;

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
Sign in to follow this  

×