[Include] Multi-Weapon - Able to switch to every weapon received
#1

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:
Код:
	new weapons[12][2];
	for (new i = 0; i <= 12; i++)
	{
	    GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
	}
Now:

Код:
	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://sampwiki.blast.hk/wiki/Keys)

Dependencies
y_hooks

Download
git: multi_weapon.inc
Reply
#2

That's dope.
Reply
#3

Why not make it so it works when you switch weapons instead of pressing a key ?
Reply
#4

Quote:
Originally Posted by Pottus
Посмотреть сообщение
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.
Reply
#5

Excellent job.
Reply
#6

Quote:
Originally Posted by justinnater
Посмотреть сообщение
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.
Reply
#7

It looks good, maybe what Pottus says it would be nice to implement it
Reply
#8

Quote:
Originally Posted by Pottus
Посмотреть сообщение
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.
Reply
#9

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.
Reply
#10

Quote:
Originally Posted by Pottus
Посмотреть сообщение
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.
Reply
#11

Quote:
Originally Posted by Y_Less
View Post
I used "sentinel" weapons. When the user has several weapons in the same slot, give them some other ones with very little ammo. These weapons won't be used, but switching to them can be detected. As long as they have at least one weapon and two sentinels you can detect the direction in which they scrolled.

If they have a lot of weapons you can even remove these and just change the scroll order. For example, given the following weapons:

2 (golf club), 3 (nitestick), 4 (knife) (slot 1)
22 (colt 45), 23 (silenced pistol), 24 (deagle) (slot 2)
25 (shotgun), 26 (sawed-off), 27 (spaz) (slot 3)

You initially give them 2, 22, and 25 and set their armed weapon to 22. If they switch to 2 (scroll down) remove 25 and given them 26, thus scrolling down again will loop back to the sawed-off shotgun. If the scroll up instead to 25, they now have the normal shotgun armed and you can replace 2 with 4.

This way, the scrolling order basically becomes:

25
22
2
26
23
3
27
24
4

And they only ever have three weapons on the client - the current weapon and one either side. With more active slots, you can move the replaced slot further away from the current weapon to become more responsive.
I like your way of thinking, thanks for this solution.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)