[Include] multi-weapon2.inc - Multi-weapon switch system with a lot of features
#1

multi-weapon2.inc
I was inspired by this release https://sampforum.blast.hk/showthread.php?tid=665507 by justinnater and I planned to develop something alike for my own server. It's been a while since I contributed anything so I decided to share it with others.

Download: Github

Difference
This include has much more stuff than the first one, I tried to make it as simple and functional as possible;
  • First include requires changing the whole script's use of GetPlayerWeaponData, this doesn't require any changes
  • This include allows you to switch any weapons (even snipers and rifles), except flamethrower
  • Animation on manually changing weapon with the Left ALT key
  • Possibility to use either manual or automatic switch
  • Compatible with server-side weapon and ammo systems (first isn't)
  • Pretty much plug n' play, you don't need to change anything
  • Unlike the first include, you can make your own weapon switch code!
Configuration
Below is the default configuration that I set. Using both automatic and manual switch isn't going to function properly, you can either use manual or automatic. If you want to use the manual, simply change the values and recompile your script.

If you gonna use the manual weapon switch option, and you don't want Left ALT, simply go here https://sampwiki.blast.hk/wiki/Keys and replace KEY_WALK with one of the keys in that page.

pawn Код:
//Configuration
#define KEY_CHANGE_WEAPON KEY_WALK //Left ALT
#define MANUAL_SWITCH false
#define AUTOMATIC_SWITCH true
Function
You can disable both manual and automatic weapon switch options and use the following function to make your own way of switching weapons:

pawn Код:
SwitchPlayerWeapon(playerid, slot, bool: anim = true);
Parameters:
playerid - The player to switch weapon for
slot - The weapon slot of the weapon you want to replace
anim - Set whether you want animation on weapon change or not

Usage
Screenshots and videos aren't needed, it's a plug n' play include that does the following:

1. You spawned with a sawed off shotgun with 200 rounds of ammo
2. You got a shotgun somewhere with 100 rounds of ammo
3. You'll get a shotgun with 300 ammunition and the sawed off stays with 200
4. If you get more ammo or lose for shotgun, it will not inflict any change on the sawed off shotgun
5. If you run out of shotgun ammo, sawed off will automatically replace the shotgun with it's 200 rounds of ammo

Automatic change: If you scroll, weapon will automatically be replaced if you select it
Manual change: Press the key (by default Left ALT) to change your weapon to other on same slot if available

Dependency
This include depends on y_hooks to hook the callbacks used within the include - https://github.com/Southclaws/YSI-4.0

Disclaimer
This include doesn't use anything from here https://sampforum.blast.hk/showthread.php?tid=665507 - I just got inspired from it. This include works in a completely different way.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)