05.08.2016, 11:42
here you go sir
PHP код:
new tempveh[MAX_VEHICLES];
CMD:vehicle(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 4)
{
new msg[128], string[200], vehiclename[30], Float:a;
new Float:x, Float:y, Float:z;
if(sscanf(params,"s[30]",vehiclename)) return SendClientMessage(playerid, COLOR_WHITE,"Usage: /vehicle [Name]");
new vehicle = GetVehicleModelIDFromName(vehiclename);
if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid, COLOR_RED, "Error: Invalid Vehicle Model");
GetPlayerFacingAngle(playerid, a);
GetPlayerPos(playerid, x,y,z);
if(IsPlayerInAnyVehicle(playerid) == 1)
{
GetXYInFrontOfPlayer(playerid,x,y,8);
}
else
{
GetXYInFrontOfPlayer(playerid,x,y,5);
}
new PlayersVehicle = CreateVehicle(vehicle, x, y, z+2, a+90, -1, -1, -1); // <- this will return the id of the created vehicle
tempveh[PlayersVehicle] = 1;
LinkVehicleToInterior(PlayersVehicle, GetPlayerInterior(playerid));
format(string,sizeof(string), "You have spawned a %s", VehicleNames[vehicle - 400]);
SendClientMessage(playerid, COLOR_BLUE, string);
format(msg,sizeof(msg), "[Admin Log]: %s has used the command /vehicle. Spawning a %s", GetName(playerid), VehicleNames[vehicle - 400]);
ABroadCast(COLOR_ADMIN, msg, 1);
}
else
{
return 0;
}
return 1;
}
public OnVehicleDeath(vehicleid,killerid)
{
if(tempveh[vehicleid])
{
DestroyVehicle(vehicleid);
tempveh[vehicleid] = 0;
}
return 1;
}