SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 07/04/2019, 02:34 AM   #1
justinnater
Huge Clucker
 
justinnater's Avatar
 
Join Date: Jan 2011
Posts: 249
Reputation: 85
Default Multi-Weapon - Able to switch to every weapon received

Description
Allows players to switch through weapons with the same weapon slot instead of loosing their previous weapon.
Lets say you are holding a Deagle with 25 ammo, normally when you get a silencer with 25 ammo, you
would lose the deagle and than have a silencer with 50 ammo.
With this include you will get a silencer with 25 ammo instead and have the ability to switch to the deagle by pressing ALT, receiving the ammo specifically for that weapon.
This system works for every weapon.

Video
Having some trouble uploading an attached file, will try again tomorrow.

How to use
Simply include the file in your gamemode and you're done.
No changes are required within the gamemode for this to work.
Although, if you are using 'GetPlayerWeaponData' you will have to use it differently now.

Before:
Code:
	new weapons[12][2];
	for (new i = 0; i <= 12; i++)
	{
	    GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
	}
Now:

Code:
	new weapons[47][2];
	for (new i = 1; i <= 47; i++)
	{
	    GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
	}
This function now returns every weapon instead of only the weapon slot in use.

How to switch weapon (Note: Switching weapons through the weapon slot of your equipped weapon)
By default you can switch weapons with the 'ALT' key.
Incase you feel like changing this:
-> open 'multi_weapon.inc'
-> go to line '9' (#define MULTI_WEAPON_SWITCH_KEY KEY_WALK)
-> change 'KEY_WALK' to any SAMP KEY you like.
(info about keys: https://wiki.sa-mp.com/wiki/Keys)

Dependencies
y_hooks

Download
git: multi_weapon.inc

Last edited by justinnater; 07/04/2019 at 04:28 PM.
justinnater is offline   Reply With Quote
Old 07/04/2019, 02:51 AM   #2
Logic_
Banned
 
Join Date: Jun 2015
Posts: 1,514
Reputation: 305
Default Re: Multi-Weapon - Able to switch to every weapon received

That's dope.
Logic_ is offline   Reply With Quote
Old 07/04/2019, 02:41 PM   #3
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,854
Reputation: 1292
Default Re: Multi-Weapon - Able to switch to every weapon received

Why not make it so it works when you switch weapons instead of pressing a key ?
Pottus is offline   Reply With Quote
Old 07/04/2019, 02:53 PM   #4
justinnater
Huge Clucker
 
justinnater's Avatar
 
Join Date: Jan 2011
Posts: 249
Reputation: 85
Default Re: Multi-Weapon - Able to switch to every weapon received

Quote:
Originally Posted by Pottus View Post
Why not make it so it works when you switch weapons instead of pressing a key ?
I am planning on doing this, although I couldn't think of a proper way to detect scrolling weapons other than using OnPlayerUpdate, which, I rather avoid. I will definitely be improving the include.
justinnater is offline   Reply With Quote
Old 07/04/2019, 03:17 PM   #5
Variable™
Gangsta
 
Join Date: Jul 2015
Posts: 802
Reputation: 175
Default Re: Multi-Weapon - Able to switch to every weapon received

Excellent job.
__________________
Discord | Website
Variable™ is offline   Reply With Quote
Old 07/04/2019, 03:35 PM   #6
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,854
Reputation: 1292
Default Re: Multi-Weapon - Able to switch to every weapon received

Quote:
Originally Posted by justinnater View Post
I am planning on doing this, although I couldn't think of a proper way to detect scrolling weapons other than using OnPlayerUpdate, which, I rather avoid. I will definitely be improving the include.
Why would OPU cause any problems for that? No reason not to use it.
Pottus is offline   Reply With Quote
Old 07/04/2019, 03:45 PM   #7
Whyd
Huge Clucker
 
Whyd's Avatar
 
Join Date: Sep 2012
Location: /
Posts: 431
Reputation: 30
Default Re: Multi-Weapon - Able to switch to every weapon received

It looks good, maybe what Pottus says it would be nice to implement it
Whyd is offline   Reply With Quote
Old 07/04/2019, 04:17 PM   #8
justinnater
Huge Clucker
 
justinnater's Avatar
 
Join Date: Jan 2011
Posts: 249
Reputation: 85
Default Re: Multi-Weapon - Able to switch to every weapon received

Quote:
Originally Posted by Pottus View Post
Why would OPU cause any problems for that? No reason not to use it.
It wouldnt cause any problems itself, but it would not be 'enough' to do the job.
Lets say I am running OPU and checking if a player's weapon changed, i still would not be able to detect whether a player scrolled up or down, which is a must to make it work like expected.
justinnater is offline   Reply With Quote
Old 07/04/2019, 05:03 PM   #9
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,854
Reputation: 1292
Default Re: Multi-Weapon - Able to switch to every weapon received

I see what you mean, but you should be able to determine the scroll order and you can determine if they scrolled up or down from that.
Pottus is offline   Reply With Quote
Old 07/04/2019, 05:10 PM   #10
justinnater
Huge Clucker
 
justinnater's Avatar
 
Join Date: Jan 2011
Posts: 249
Reputation: 85
Default Re: Multi-Weapon - Able to switch to every weapon received

Quote:
Originally Posted by Pottus View Post
I see what you mean, but you should be able to determine the scroll order and you can determine if they scrolled up or down from that.
It's possible, but it's going to be a tough one to create. As mentioned before, I am going to improve the include, and I will be adding this feature.
justinnater 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
[Off] elaborar um Tutorial sobre ter 2 ou mais SA:MP aberto? [ Multi-Versões | Multi Games ] RazorGuigo Português/Portuguese 6 17/07/2018 10:04 PM
[GameMode] Jueix's Multi mod / Los Entertainment Multi mod Release jueix Gamemode Scripts 15 09/08/2014 12:41 PM
[FilterScript] Simple Weapon/Weapon skill shop menu AdryanViag Filterscripts 3 14/07/2014 07:42 AM
[FilterScript] Weapon Shop v2.0 With Weapon Saving System Danyal Filterscripts 30 16/01/2014 08:58 AM
[FilterScript] Weapon specifier - Advanced weapon system. Blunt Filterscripts 16 12/01/2014 11:45 AM


All times are GMT. The time now is 01:41 AM.


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