SA-MP Forums Archive
[Quick Swapping] example - 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: [Quick Swapping] example (/showthread.php?tid=562288)



[Quick Swapping] example - bigboy81 - 08.02.2015

I need some example if player quick swapping weapon, server say him you need swapping your weapon slowly.
And player must wait 3-4 second to swap that weapon,because she is qucik swapping.


Re: [Quick Swapping] example - Abagail - 08.02.2015

Something like this?
pawn Код:
new PlayerWeaponSwap[MAX_PLAYERS];

public OnPlayerUpdate(playerid)
{
    new iCurWeap = GetPlayerWeapon(playerid); // Return the player's current weapon    
    if(iCurWeap != GetPVarInt(playerid, "iCurrentWeapon")) // If he changed weapons since the last update
    {
        // Lets call a callback named OnPlayerChangeWeapon
        OnPlayerChangeWeapon(playerid, GetPVarInt(playerid, "iCurrentWeapon"), iCurWeap);
        SetPVarInt(playerid, "iCurrentWeapon", iCurWeap);//Update the weapon variable
    }
    return 1; // Send this update to other players.
}
public OnPlayerChangeWeapon(playerid, newweapon, oldweapon)
{
     if(PlayerWeaponSwap[playerid] > gettime() - 5)
     {
          SetPlayerArmedWeapon(playerid, oldweapon);
          CallLocalFunction("OnPlayerQuickSwap", "i", playerid);
          return 0;
     }

     PlayerWeaponSwap[playerid] = gettime();
     return 1;
}



Re: [Quick Swapping] example - bigboy81 - 08.02.2015

@Abagail something like that,but that don't work.


Re: [Quick Swapping] example - Sew_Sumi - 08.02.2015

Quick swapping relates to switching weapons to avoid the reload animation, so in essence, this won't avoid the QuickSwap.

I could fire spas rounds, switch, run around for a few seconds, then switch back to spas. QuickSwap achieved.


What you could look at more though, is checking whether the player actually had the animation for the reload occur, and that'd show it up.

There won't be a stopping it, but more then people can see it, and admins can act upon it.

You could even broadcast it to the server openly, so everyone knows.