SA-MP Forums Archive
detect if player is switching weapons. - 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: detect if player is switching weapons. (/showthread.php?tid=649467)



detect if player is switching weapons. - jasperschellekens - 09.02.2018

So i wonder if this is possible because i am creating a switching weapons system on different keys. This is because i want players to only equip 4 weapons at a time(there is an equipment textdraw.) And also let them equip deagle and 9mm etc together.

I can't use onplayerkeystatechange i think because you also use the the switch keys when you are using sniper right? correct me if i am wrong.

What i actually want to do now, is block the player from using the original weapon switching scrolling.
Is that possible?


Re: detect if player is switching weapons. - Mauzen - 09.02.2018

Give players only one weapon at once, and when pressing your custom weapon switch key, remove it and give them the next equipped weapon.
They can still switch to unarmed, you may prevent that with SetPlayerArmedWeapon in OnPlayerUpdate, but maybe you want it like that, so they can always use unarmed attacks.


Re: detect if player is switching weapons. - raydx - 09.02.2018

OnPlayerUpdate:

Code:
     
                new wid = GetPlayerWeapon(playerid);
		if( pInfo[playerid][player_held_weapon] != wid )
		{
			OnPlayerWeaponSwitch(playerid, wid, pInfo[playerid][player_held_weapon]);
			pInfo[playerid][player_held_weapon] = wid;
		}



Re: detect if player is switching weapons. - Mugala - 09.02.2018

Quote:
Originally Posted by raydx
View Post
OnPlayerUpdate:

Code:
     
                new wid = GetPlayerWeapon(playerid);
		if( pInfo[playerid][player_held_weapon] != wid )
		{
			OnPlayerWeaponSwitch(playerid, wid, pInfo[playerid][player_held_weapon]);
			pInfo[playerid][player_held_weapon] = wid;
		}
what is this OnPlayerWeaponSwitch?
provide code please, otherwise your given code will not work.

Mauzen's idea is good.