28.01.2015, 04:45
pawn Код:
// Top of Script with Global variables.
static
veh[MAX_PLAYERS]; // Asigns the Created vehicle to that player.
pawn Код:
if(GetPlayerMoney(playerid) < 4500) return SendClientMessage(playerid, COLOR_RED," SERVER : You don't have so much money!");
GetPlayerPos(playerid, X,Y,Z);
veh[playerid] = CreateVehicle(499, X,Y,Z, Angle, 44, 44, -1); // This avoids the last CreatedVehicle from being destroyed, it now destroys one assigned to that player.
SetPVarInt(playerid, #CreatedCar, 1);// Player has created a vehicle.
PutPlayerInVehicle(playerid,veh,0);
GivePlayerMoney(playerid,-4500);
SendClientMessage(playerid,COLOR_ROYALBLUE,"CAR SHOP : You have bought a Benson Cost: "COL_WHITE" $4,500");
pawn Код:
public OnVehicleDeath(vehicleid, killerid) // KillerID = Player that caused the vehicle to destroy.
{
if(GetPVarInt(killerid, #CreatedCar) == 1) // Checks if they created a vehicle.
{
DestroyVehicle(veh[playerid]);
DeletePVar(playerid, #CreatedCar); // No longer have a created car assigned to them.
}
return 1;
}