SA-MP Forums Archive
Checking the highest - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Checking the highest (/showthread.php?tid=366468)



Checking the highest - Dan. - 06.08.2012

How to detect which variable has the highest value?

pawn Код:
new england, russia, iraq, mexico;
I need to check, which team has the highest value.


Respuesta: Checking the highest - HarlemSAMP - 06.08.2012

Mexico has the highest value ^.^


Re: Checking the highest - Ranama - 06.08.2012

Here's a way to do it, surely it's a better and easyier way but i can't come out with anything else at this moment:

pawn Код:
new england, russia, iraq, mexico;

if(england > russia && iraq && mexico){
SendClientMessageToAll(COLOR_WHITE, "England have taken the lead");//do you thing here
}
else if(russia > england && iraq && mexico){
SendClientMessageToAll(COLOR_WHITE, "Russia have taken the lead");//do you thing here
}
else if(iraq > russia && england && mexico){
SendClientMessageToAll(COLOR_WHITE, "Iraq have taken the lead");//do you thing here
}
else{//this means that mexico is in the lead
SendClientMessageToAll(COLOR_WHITE, "Mexico have taken the lead");//do you thing here
}
Hope it helped


Re: Checking the highest - Dan. - 06.08.2012

Yeah.. I could have done that also, just wanted to know if there is a shorter way, but I'll use that then. Thanks.