03.08.2016, 11:19
I'm currently messing up some codes.. trying to find a way how I can get a users playerid to send them a message IF they are logged on. Here's what I got currently (doesn't work at all):
Reason I want that is because of this: VehicleInfo[vehicleid][carOwner] = DatabaseID
So, when a car gets destroyed and the vehicle owner is online - I'd like to send him a message, telling him that his car is rekt. To do that I assume I will have to first check if he's online, then get his in-game playerid and retrieve it so I can send him a message.
Код:
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]));
}


