How to make a timer for non-admin
#2

Add this to the top of your script:

pawn Код:
new SpawnedRecently[MAX_PLAYERS];
Replace your old /v command with this:

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;
}
Add to the bottom of your script:

pawn Код:
forward WaitSpawn(playerid);
public WaitSpawn(playerid);
{
    if(SpawnedRecently[playerid] == 1)
    {
        SpawnedRecently[playerid] = 0;
    }
}
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.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)