PDA

View Full Version : detect if player is switching weapons.


jasperschellekens
09/02/2018, 02:29 PM
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?

Mauzen
09/02/2018, 02:35 PM
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.

raydx
09/02/2018, 02:36 PM
OnPlayerUpdate:


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;
}

Mugala
09/02/2018, 06:16 PM
OnPlayerUpdate:


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.