Minigun Timer [reps+]
#1

Hello,

I see many servers give players minigun for 1 minute then disarm it , the event is starting by writing /minigunevent, I think this is timer idea or something like that , how to make something like that? ,thanks for help & Read!
Reply
#2

Like
Add at the top of the script

pawn Код:
forward MinigunTimer();
And then

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/minigunevent", cmdtext, true, 10) == 0)
    {
        for (new i = 0; i < MAX_PLAYERS; i++)
           {
                if (IsPlayerConnected(i))
                {
                GivePlayerWeapon(playerid, 38, 999999);
                }
           }
           SetTimer("SaveDataTimer",60000 , 0);
    return 1;
    }
}

public MinigunTimer()
{
      foreach(new playerid : Player)
      {
      GivePlayerWeapon(playerid, 38, 0);
      }
      return 1;
}
Didn't tested. Tell me if it works.

And I recommand Benzo's script
Reply
#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
#4

coded in ZCMD.

pawn Код:
CMD:minigunevent(playerid)
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You are not admin"); //requires RCON, can be changed if you have a custom admin system
    for(new i; i<MAX_PLAYERIS; i++)
    {
        if(IsPlayerConnected(i))
        {
            GivePlayerWeapon(playerid, 38, 999999);
        }
    }
    SetTimer("RemoveMinigun", 60000, false);
    SendClientMessageToAll(-1, "The minigun event has been activated by an admin!");
    return 1;
}

forward RemoveMinigun();
public RemoveMiniGun()
{
    for(new i; i>MAX_PLAYERS, i++)
    {
        if(GetPlayerWeapon(i) == 38)
        {
            ResetPlayerWeapons(i);
        }
    }
    return 1;
}
That should work
Reply
#5

Quote:
Originally Posted by Mattakil
Посмотреть сообщение
coded in ZCMD.

pawn Код:
CMD:minigunevent(playerid)
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You are not admin"); //requires RCON, can be changed if you have a custom admin system
    for(new i; i<MAX_PLAYERIS; i++)
    {
        if(IsPlayerConnected(i))
        {
            GivePlayerWeapon(playerid, 38, 999999);
        }
    }
    SetTimer("RemoveMinigun", 60000, false);
    SendClientMessageToAll(-1, "The minigun event has been activated by an admin!");
    return 1;
}

forward RemoveMinigun();
public RemoveMiniGun()
{
    for(new i; i>MAX_PLAYERS, i++)
    {
        if(GetPlayerWeapon(i) == 38)
        {
            ResetPlayerWeapons(i);
        }
    }
    return 1;
}
That should work
Nice One but ResetPlayerWeapons will remove ALL the weapons. Check this one
Reply
#6

Quote:
Originally Posted by ZeroTheScyther
Посмотреть сообщение
Nice One but ResetPlayerWeapons will remove ALL the weapons. Check this one
That is true, it will. But usually after an event you want your weapons reset. Forgot to mention that :P
Reply
#7

My code supports both total weapon resets and just minigun resets by changing true to false. So don't worry about posting any more code...
Reply
#8

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
My code supports both total weapon resets and just minigun resets by changing true to false. So don't worry about posting any more code...
You'r hero , + rep and thanks all ill try to rep anyway im going to test
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)