SA-MP Forums Archive
Minigun Timer [reps+] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Minigun Timer [reps+] (/showthread.php?tid=497267)



Minigun Timer [reps+] - SPA - 25.02.2014

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!


Re: Minigun Timer [reps+] - ZeroTheScyther - 25.02.2014

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


Re: Minigun Timer [reps+] - Threshold - 25.02.2014

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



Re: Minigun Timer [reps+] - Mattakil - 25.02.2014

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


Re: Minigun Timer [reps+] - ZeroTheScyther - 25.02.2014

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


Re: Minigun Timer [reps+] - Mattakil - 25.02.2014

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


Re: Minigun Timer [reps+] - Threshold - 26.02.2014

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...


Re: Minigun Timer [reps+] - SPA - 26.02.2014

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