14.09.2015, 18:43
You should create a vehicle array
The code gets way more simply
PHP код:
// global
new gVehicleOwner[MAX_VEHICLES + 1];
PHP код:
public OnPlayerStateChange(playerid, newstate, oldstate) {
if(newstate == PLAYER_STATE_DRIVER) {
new
vehicleid = GetPlayerVehicleID(playerid),
owner = gVehicleOwner[vehicleid]
;
if(owner == INVALID_PLAYER_ID) {
// vehicle has no owner
} else {
if(owner == playerid) {
// Vehicle is owned by playerid
} else {
// Vehicle isn't owned by playerid
RemovePlayerFromVehicle(playerid);
}
new string[64];
GetPlayerName(owner, string, MAX_PLAYER_NAME);
format(string, sizeof(string), "This car is owned by %s", string);
SendClientMessage(playerid, -1, string);
}
}
return 1;
}