SA-MP Forums Archive
Return guns [+Rep] - 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: Return guns [+Rep] (/showthread.php?tid=611762)



Return guns [+Rep] - DavidGravelli - 10.07.2016

Hi Guys I got the holster system so when i switch Gun ID 0 its return fast to the killer guns
like knife or anything so guys i need to set it to return the gun after 3 seconds not faster

Sorry for my bad english!
This is the code!

pawn Код:
public OnPlayerUpdate(playerid)
{
    new w = GetPlayerWeapon(playerid);

    if(w != lastWeapon[playerid])
    {
        if(lastWeapon[playerid] == 0) return lastWeapon[playerid] = GetPlayerWeapon(playerid);

        SetPlayerArmedWeapon(playerid, lastWeapon[playerid]);
    }

    lastWeapon[playerid] = w;

    return 1;
}



Re: Return guns [+Rep] - Sjn - 10.07.2016

Because you are doing this inside OnPlayerUpdate callback which gets called frequently. Create your own timer with the interval of 3 seconds and do the stuff there.


Re: Return guns [+Rep] - DavidGravelli - 10.07.2016

I try to change OnPlayerUpdate to HolsterOnPlayerUpdate and still switching fast.