Check if player is online by mysql id?
#6

You cannot use both break and return one after another.

PHP код:
GetIDbyVDID(vehicleid)
{
    for(new 
0GetPlayerPoolSize(); <= ji++)
    {
        if (
PlayerInfo[i][pDatabaseID] == VehicleInfo[vehicleid][carOwner])
        {
            
printf("Returning %d"i);
            return 
i;
        }
    }
    return 
INVALID_PLAYER_ID;

What do you reset "CarOwner" to so we won't have to loop through players when a vehicle is not owned by anyone?

Be it 0, INVALID_PLAYER_ID or whatever, add it at the top of the function.
pawn Код:
if (VehicleInfo[vehicleid][carOwner] == /* RESET VALUE/NO OWNER */) return INVALID_PLAYER_ID;
and then usage:
pawn Код:
new p_id = GetIDbyVDID(vehicleid);
if (p_id != INVALID_PLAYER_ID) // necessary if you want to use "p_id" in arrays.
{
    // messages or what you want..
}
Reply


Messages In This Thread
Check if player is online by mysql id? - by TheBigFive - 03.08.2016, 11:19
Re: Check if player is online by mysql id? - by Konstantinos - 03.08.2016, 11:28
Re: Check if player is online by mysql id? - by TheBigFive - 03.08.2016, 11:29
Re: Check if player is online by mysql id? - by Konstantinos - 03.08.2016, 11:34
Re: Check if player is online by mysql id? - by TheBigFive - 03.08.2016, 12:28
Re: Check if player is online by mysql id? - by Konstantinos - 03.08.2016, 12:44

Forum Jump:


Users browsing this thread: 1 Guest(s)