PlayerPrivateVehicle[???][name]=CreateVehicle(....
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { if(vechileid==PlayerPrivateVehicle[???][name]) { new string[64]; format(string, sizeof(string),This car is owned by %s", name); SendClientMessage(playerid, -1, string); } return 1; }
for(new i; i<MAX_VEHICLES; i++) { if(PlayerPrivateVehicle[i][name]==0){ PlayerPrivateVehicle[i][name]=CreateVehicle(....);} }
// global
new gVehicleOwner[MAX_VEHICLES + 1];
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;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(!strcmp(name,"KillerDVX",true))
{
new string[64];
format(string, sizeof(string),This car is owned by %s", name);
SendClientMessage(playerid, -1, string);
}
return 1;
}
new playercar[MAX_PLAYERS]; playercar[playerid] = CreateVehicle(411,0,0,0,2,-1,-1,3600); public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { if(vehicleid==playercar[playerid]) { SendClientMessage(playerid,-1,This is your car!); } }
You can make like this
Код:
new playercar[MAX_PLAYERS]; playercar[playerid] = CreateVehicle(411,0,0,0,2,-1,-1,3600); public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { if(vehicleid==playercar[playerid]) { SendClientMessage(playerid,-1,This is your car!); } } |
new PlayerIDCar[MAX_VEHICLES];
new playercar[MAX_PLAYERS];
playercar[playerid] = CreateVehicle(411,0,0,0,2,-1,-1,3600);
PlayerIDCar[playercar[playerid] ] = playerid;
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(vehicleid==playercar[playerid])
{
SendClientMessage(playerid,-1,This is your car!);
}
else
{
new str[128];
format(str,sizeof(str),"This car is owned by %s",PlayerName(PlayerIDCar[vehicleid ] ) )
SendClientMessage(playerid,-1,str);
}
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(vehicleid==playercar[playerid])
{
SendClientMessage(playerid,-1, "This is your car!");
}
else
{
SendClientMessage(playerid, -1, "This is not your car!");
}
}
// global
new gVehicleOwner[MAX_VEHICLES + 1] = {INVALID_PLAYER_ID, ...};
new vehicleid = CreateVehicle(411,0,0,0,2,-1,-1,3600);
gVehicleOwner[vehicleid] = playerid;
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(gVehicleOwner[vehicleid] != INVALID_PLAYER_ID)
if(gVehicleOwner[vehicleid] != playerid)
{
new string[64];
GetPlayerName(gVehicleOwner[vehicleid], string, MAX_PLAYER_NAME);
format(string, sizeof(string), "This car is owned by %s", string);
SendClientMessage(playerid, -1, string);
ClearAnimations(playerid);
}
return 1;
}
DestroyVehicleEx(vehicleid)
{
if(!(0 < vehicleid < sizeof(gVehicleOwner))) return 0;
gVehicleOwner[vehicleid] = INVALID_PLAYER_ID;
return DestroyVehicle(vehicleid);
}
pawn Код:
Change all DestroyVehicle to DestroyVehicleEx pawn Код:
|