stock GetPIDByDID(did) { for(new i = 0; i <= MAX_PLAYERS; i++) { if(PlayerIsOn(i)) { printf("Returned database ID %d", PlayerInfo[i][pDatabaseID]); return PlayerInfo[i][pDatabaseID]; } } return INVALID_PLAYER_ID; }
if(PlayerIsOn(GetPIDByDID(VehicleInfo[vehicleid][carOwner]))) { format(msg, sizeof(msg), "Your %s has been rekt %d.",VehicleNames[GetVehicleModel(vehicleid)-400],VehicleInfo[vehicleid][carDestroyed]); SCM(GetPIDByDID(VehicleInfo[vehicleid][carOwner]), COLOR_PINK, msg); format(msg, sizeof(msg), "You have %d lives left.",VehicleInfo[vehicleid][carInsurances]); SCM(GetDIDByPID(VehicleInfo[vehicleid][carOwner]), COLOR_PINK, msg); PlayerInfo[GetPIDByDID(VehicleInfo[vehicleid][carOwner])][pCarKey] = 0; CheckOwnedVehicles(GetPIDByDID(VehicleInfo[vehicleid][carOwner])); }
for(new i = 0; i <= MAX_PLAYERS; i++)
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
"CarOwner" holds the user ID? Simply run a player-loop and check if the "pDatabaseID" is equal to.
About this: pawn Код:
pawn Код:
|
if (VehicleInfo[vehicleid][carOwner]) // if it is owned by anyone
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if (PlayerInfo[i][pDatabaseID] == VehicleInfo[vehicleid][carOwner])
{
// Send message to inform player - "i" holds their in-game ID.
break; // stop the loop, result was found
}
}
}
stock GetIDbyVDID(vehicleid) { for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) { if (PlayerInfo[i][pDatabaseID] == VehicleInfo[vehicleid][carOwner]) { // Send message to inform player - "i" holds their in-game ID. printf("Returning %d", i); break; // stop the loop, result was found return i; } } return INVALID_PLAYER_ID; }
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;
}
if (VehicleInfo[vehicleid][carOwner] == /* RESET VALUE/NO OWNER */) return INVALID_PLAYER_ID;
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..
}