Minigun Timer [reps+]
#3

pawn Код:
#include <a_samp>
#include <zcmd>

#define REMOVEMINIGUN   true    //Change this to 'false' if you want to remove all weapons the end of the event.

new bool:MinigunEvent;

public OnGameModeInit()
{
    MinigunEvent = false;
    return 1;
}

CMD:minigunevent(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You must be an RCON Admin to use this command.");
    if(MinigunEvent) return SendClientMessage(playerid, 0xFF0000FF, "There is already a minigun event running. Wait for it to finish.");
    for(new i = 0; i < MAX_PLAYERS; i++) //Foreach is recommended here...
    {
        if(!IsPlayerConnected(i)) continue;
        GivePlayerWeapon(i, 38, 5000); //Gives a minigun with 5000 ammo.
    }
    MinigunEvent = true;
    SetTimer("ResetMinigunEvent", 60000, false); //Sets a timer for 60 seconds (1 minute).
    SendClientMessageToAll(0xFFFF00FF, "A Minigun Event has begun. It will end in 1 minute.");
    return 1;
}

forward ResetMinigunEvent();
public ResetMinigunEvent()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        #if REMOVEMINIGUN == true
            RemovePlayerWeapon(i, 38);
        #else
            ResetPlayerWeapons(i);
        #endif
    }
    MinigunEvent = false;
    return 1;
}

#if REMOVEMINIGUN == true
stock RemovePlayerWeapon(playerid, weaponid)
{
    new plyWeapons[12];
    new plyAmmo[12];

    for(new slot = 0; slot != 12; slot++)
    {
        new wep, ammo;
        GetPlayerWeaponData(playerid, slot, wep, ammo);

        if(wep != weaponid)
            GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot]);
    }

    ResetPlayerWeapons(playerid);
    for(new slot = 0; slot != 12; slot++)
        GivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot]);
    return 1;
}
#endif
Reply


Messages In This Thread
Minigun Timer [reps+] - by SPA - 25.02.2014, 22:44
Re: Minigun Timer [reps+] - by ZeroTheScyther - 25.02.2014, 23:07
Re: Minigun Timer [reps+] - by Threshold - 25.02.2014, 23:19
Re: Minigun Timer [reps+] - by Mattakil - 25.02.2014, 23:19
Re: Minigun Timer [reps+] - by ZeroTheScyther - 25.02.2014, 23:23
Re: Minigun Timer [reps+] - by Mattakil - 25.02.2014, 23:48
Re: Minigun Timer [reps+] - by Threshold - 26.02.2014, 00:41
Re: Minigun Timer [reps+] - by SPA - 26.02.2014, 10:01

Forum Jump:


Users browsing this thread: 1 Guest(s)