SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/02/2018, 02:29 PM   #1
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,165
Reputation: 165
Default detect if player is switching weapons.

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?
__________________
Undead Wasteland Roleplay | Visit website
The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
jasperschellekens is offline   Reply With Quote
Old 09/02/2018, 02:35 PM   #2
Mauzen
High-roller
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 4,878
Reputation: 1597
Default Re: detect if player is switching weapons.

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.
Mauzen is offline   Reply With Quote
Old 09/02/2018, 02:36 PM   #3
raydx
Huge Clucker
 
raydx's Avatar
 
Join Date: Feb 2017
Posts: 203
Reputation: 73
Default Re: detect if player is switching weapons.

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;
		}
raydx is offline   Reply With Quote
Old 09/02/2018, 06:16 PM   #4
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,176
Reputation: 73
Default Re: detect if player is switching weapons.

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.
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to detect if player has any weapons ? Adarsh007 Scripting Help 7 08/07/2015 08:49 AM
hold one gun only no switching weapons PSYCHOBABYKILLA Scripting Help 6 05/04/2015 05:58 PM
Weapons Switching System ? ? rockhopper Everything and Nothing 10 19/01/2015 07:17 AM
Weapons Detect Stereotype Scripting Help 6 13/06/2013 01:34 PM
Fix for auto reload when switching weapons? [MM]RoXoR[FS] Scripting Help 4 09/09/2012 09:59 AM


All times are GMT. The time now is 09:14 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.