27.11.2011, 20:43
Add this to the top of your script:
Replace your old /v command with this:
Add to the bottom of your script:
Note:
I used IsPlayerAdmin function to determine whether the player is an RCON admin, replace it with your own admin variable if you have it.
Untested.
pawn Код:
new SpawnedRecently[MAX_PLAYERS];
pawn Код:
if(strcmp(cmd, "/v", true, 10) == 0)
{
new String[200];
new tmp[256];
new Float:x, Float:y, Float:z;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, l_red, "Usage: /v [car name].");
if(!IsPlayerAdmin(playerid) && SpawnedRecently[playerid] == 1) return SendClientMessage(playerid,l_red,"Please Wait Before Spawning Another Car.");
new vehicle = GetVehicleModelIDFromName(tmp);
if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid, l_red, "Invalid Vehicle Name.");
new Float:a;
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, a+90, -1, -1, -1);
LinkVehicleToInterior(PlayersVehicle, GetPlayerInterior(playerid));
format(String, sizeof(String), "You have spawned a %s", aVehicleNames[vehicle - 400]);
SendClientMessage(playerid, l_green, String);
if(!IsPlayerAdmin(playerid))
{
SetPVarInt(playerid, "WaitSpawn", SetTimerEx("WaitSpawn", 15000, true, "i", playerid));
SpawnedRecently[playerid] = 1;
}
return 1;
}
pawn Код:
forward WaitSpawn(playerid);
public WaitSpawn(playerid);
{
if(SpawnedRecently[playerid] == 1)
{
SpawnedRecently[playerid] = 0;
}
}
I used IsPlayerAdmin function to determine whether the player is an RCON admin, replace it with your own admin variable if you have it.
Untested.