18.06.2012, 15:41
Simple codes, but should do the trick.
Considering the enum. of the player data is the "PlayerInfo" as the common used..
Considering the enum. of the player data is the "PlayerInfo" as the common used..
pawn Код:
// Anywhere, recommended to be after the variables, not in a function or a callback for sure.
enum pinfo
{
Admin,
SpawnedVehicle,
HasVehicleSpawned,
}
new PlayerInfo[MAX_PLAYERS][pinfo];
// Same here, but recommended to be coded after the callbacks..
CMD:v(playerid, params[])
{
new vehicleid, color1, color2, Float: x, Float: y, Float: z;
if(sscanf(params,"iii", vehicleid, color1, color2)) return SendClientMessage(playerid, SOME_COLOR,"USAGE: /v [vehicleid] [color1] [color2]");
GetPlayerPos(playerid, x, y, z);
PlayerInfo[playerid][SpawnedVehicle] = CreateVehicle(vehicleid, x+2, y, z, 1.0, color1, color2, 1000);
PlayerInfo[playerid][HasVehicleSpawned] = 1;
return 1;
}
CMD:vdestroy(playerid, params[])
{
if(!PlayerInfo[playerid][HasVehicleSpawned]) return SendClientMessage(playerid, SOME_COLOR,"ERROR: You don't have a spawned vehicle to destroy.");
DestroyVehicle(PlayerInfo[playerid][SpawnedVehicle]);
PlayerInfo[playerid][HasVehicleSpawned] = 0;
return 1;
}
CMD:respawnvehicles(playerid, params[])
{
if(!PlayerInfo[playerid][Admin]) return SendClientMessage(playerid, SOME_COLOR,"ERROR: You are not an administrator.");
for(new v; v < MAX_VEHICLES; v++)
{
for(new i; i < MAX_PLAYERS; i++)
{
if(!GetPlayerVehicleID(i) == v)
{
SetVehicleToRespawn(v);
SendClientMessageToAll(SOME_COLOR,"Warning: All unused vehicles have been respawned by an administrator.");
return 1;
}
}
}
return 1;
}