How to do for...?
#1

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.
Reply
#2

Add
pawn Код:
Value = Var;
inside that if.
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Add
pawn Код:
Value = Var;
inside that if.
Besides that 'Value' is a integrer and 'Var' is a floating. It would give mistakes .
Reply
#4

Sorry, didn't spot that. Initialize Value with Float tag (or use floatround/ceil/floor on Var)
Reply
#5

Код:
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;
}
Reply
#6

You are genius, thank you very much! .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)