03.08.2016, 12:44
You cannot use both break and return one after another.
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.
and then usage:
PHP код:
GetIDbyVDID(vehicleid)
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if (PlayerInfo[i][pDatabaseID] == VehicleInfo[vehicleid][carOwner])
{
printf("Returning %d", i);
return i;
}
}
return INVALID_PLAYER_ID;
}
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;
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..
}