19.12.2013, 00:21
New /veh command:
OnPlayerDisconnect and OnPlayerConnect:
/respawnallc command (This command will destroy all player-spawned vehicles):
pawn Код:
CMD:veh(playerid,params[])
{
if(pInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
new car;
if(sscanf(params,"i", car)) return SendClientMessage(playerid,0xff0000ff,"USAGE: /Veh <Vehicle ID 400 - 611>");
if(car < 400 || car > 611) return SendClientMessage(playerid, 0xff0000ff, "ERROR: Cannot go under 400 or above 611.");
new string[128], Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(Vehicle[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(Vehicle[playerid]);
Vehicle[playerid] = CreateVehicle(car, X, Y, Z + 2.0, 0, -1, -1, 1);
format(string,sizeof(string),"You Have Spawned Vehicle ID %i",car);
SendClientMessage(playerid, 0xffffffff, string);
PutPlayerInVehicle(playerid, Vehicle[playerid], 0);
return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
if(Vehicle[playerid] != INVALID_VEHICLE_ID)
{
DestroyVehicle(Vehicle[playerid]);
Vehicle[playerid] = INVALID_VEHICLE_ID;
}
return 1;
}
public OnPlayerConnect(playerid)
{
Vehicle[playerid] = INVALID_VEHICLE_ID;
return 1;
}
pawn Код:
CMD:respawnallc(playerid, params[])
{
#pragma unused params
if(pInfo[playerid][Adminlevel] < 4) return SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
new bool:vehicleused[MAX_VEHICLES], i;
for(i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(Vehicle[i] != INVALID_VEHICLE_ID)
{
DestroyVehicle(Vehicle[i]);
Vehicle[i] = INVALID_VEHICLE_ID;
}
if(!IsPlayerInAnyVehicle(i)) continue;
vehicleused[GetPlayerVehicleID(i)] = true;
}
for(i = 0; i < MAX_VEHICLES; i++)
{
if(vehicleused[i] == true) continue;
SetVehicleToRespawn(i);
}
new msg[80], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(msg, sizeof(msg), "[ADMIN]{FFFFFF} %s has respawned all unused vehicles.", pName);
SendClientMessageToAll(COLOR_ADMIN, msg);
return 1;
}