Prevent switch weapons
#1

Hi all, are you okay?

I was wondering how to go about preventing the player to switch a heavy weapon (Style AK-47, shotgun, sniper etc.) to not have so many heavy weapons, unrealistic thing.

Bye.
Reply
#2

This is like an example:
- Tought if you want to make it fully support each gun, I'd recommand making a loop with data over them as you chose. And other values. You didn't give us a code to work with, this is the best I can make for you for now.

pawn Код:
new pastWI[MAX_PLAYERS];

OnPlayerConnect(playerid)
{
    pastWI[playerid] = 0;
    return 1;
}

OnPlayerUpdate(playerid)
{
    new weaponid = GetPlayerWeapon(playerid);
    if(weaponid != pastWI[playerid])
    {
         if(pastWI[playerid] == 24 && weaponid == 31)
        {
              SetPlayerArmedWeapon(playerid, 24);
        }
    }
}
Reply
#3

Suppose I have a gun (m4 id 31), if I want the switcher will remain in my hands?
Reply
#4

The switcher I showed above, detectes if old weapon as 24 (deagle). If it was and new weapon is suddenly 31, it'll switch back towards 24. I hope you understand that and that you'll need to do it yourself all of the other coding.

Again, I suggest making a loop with an enum/new values that loops trought them.
Reply
#5

Yes so you should use loop example for all player weps player got,using geweapondata i guess
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)