How to do for...? - 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: How to do for...? (
/showthread.php?tid=491640)
How to do for...? -
Swedky - 31.01.2014
I have tried so many things that I do not still had other one that to ask for help...
I need to know how to do in order that a function returns her ID of the player with more points.
I did this:
pawn Код:
stock SearchPlayerWhitHighPoints()
{
new Value = -1;
new player = -1;
new Float:Var;
foreach(new i: Player)
{
Var = PlayerInfo[i][RadarSpeed]; // The points it would be 'PlayerInfo[i][RadarSpeed]'.
if(Var > Value)
{
player = i;
}
}
return player;
}
And it does not work, is more, I do not even see the logic to this function
.
Might someone say to me how to do it?
Regards.
Re: How to do for...? -
Misiur - 31.01.2014
Add
inside that if.
Respuesta: Re: How to do for...? -
Swedky - 31.01.2014
Quote:
Originally Posted by Misiur
|
Besides that 'Value' is a integrer and 'Var' is a floating. It would give mistakes
.
Re: How to do for...? -
Misiur - 31.01.2014
Sorry, didn't spot that. Initialize Value with Float tag (or use floatround/ceil/floor on Var)
Re: How to do for...? -
Mic_H - 31.01.2014
Код:
stock SearchPlayerWhitHighPoints()
{
new Float:Value = -1.0; //Var is float.. So its supposed to be float so is PlayerInfo[i][RadarSpeed]
new Player = -1;
new Float:Var;
foreach(new i: Player)
{
Var = PlayerInfo[i][RadarSpeed]; // The points it would be 'PlayerInfo[i][RadarSpeed]'.
if(Var > Value)
{
player = i;
Value=PlayerInfo[i][RadarSpeed]; //Or else Everybody's point will be greater than Value (=-1) and it will return last online player's ID.
}
}
return player;
}
Respuesta: How to do for...? -
Swedky - 31.01.2014
You are genius, thank you very much!
.