You could make use of the new GetVehicleModelInfo and the custom GetXYBehindVehicle function. This is a function I use:
pawn Код:
|
//When creating a car use.... V
//VehID[playerid] = CreateVehicle(vehid, X, Y, Z, 0.0, random(130), random(130), 0);
new VehID[MAX_PLAYERS]; //Let's store the vehicle ID of the player
public OnPlayerDisconnect(playerid)
{
VehID[playerid] = -1;
return 1;
}
public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(strfind(cmdtext, "trunk", true) != -1)
{
new vehid2 = VehID[playerid];
if(IsPlayerNearVehicle(playerid, vehid2, 5.0) && vehid2 != -1) //The player is near his vehicle
{
SendClientMessage(playerid, 0xFFFFFF, "User used command /trunk and is near his car!");
return 1;
}
}
return 1;
}
IsPlayerNearVehicle(playerid, vehicleid, float:range) //Is player near the vehicle *range
{
new Float:X, Y, Z;
GetVehiclePos(vehicleid, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, X, Y, Z, range) return 1;
return 0;
}