SA-MP Forums Archive
Avoid quickswapping - 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: Avoid quickswapping (/showthread.php?tid=364323)



Avoid quickswapping - Mikkel_RE - 30.07.2012

Is there a way to make a system that you can't quickswap your weapon, i mean something that if you shoot with a gun, you cant change the weapon before 3 seconds after you stop shooting


Re: Avoid quickswapping - Vince - 30.07.2012

pawn Код:
public OnPlayerUpdate(playerid)
{
    // ----- OnPlayerWeaponChange -----
    static
        oldWeapon[MAX_PLAYERS char];
    new
        newWeapon = GetPlayerWeapon(playerid);
       
    if(newWeapon != oldWeapon{playerid})
    {
        OnPlayerWeaponChange(playerid, newWeapon, oldWeapon{playerid});
        oldWeapon{playerid} = newWeapon;
        return 1;
    }
    return 1;
}

public OnPlayerWeaponChange(playerid, newweapon, oldweapon)
{
    static
        switchTime[MAX_PLAYERS];
       
    if((gettime() - switchTime[playerid]) < 3)
        SetPlayerArmedWeapon(playerid, oldweapon);
       
    switchTime[playerid] = gettime();
    return 1;
}
I think that should work.


Re: Avoid quickswapping - Mikkel_RE - 30.07.2012

Alright i did as you said, but when i switch weapon, it will just fuck up


Re: Avoid quickswapping - Mikkel_RE - 30.07.2012

Also when i switch weapon after i putted what you send me, the weapon is just fucking up, when i switch after i have shot with it