View Single Post
Old 10/04/2019, 12:43 AM   #1
Join Date: Jul 2015
Posts: 796
Reputation: 175
Smile - Multi-weapon switch system with a lot of features
I was inspired by this release 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

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!

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 and replace KEY_WALK with one of the keys in that page.

pawn Code:
#define MANUAL_SWITCH false

You can disable both manual and automatic weapon switch options and use the following function to make your own way of switching weapons:

pawn Code:
SwitchPlayerWeapon(playerid, slot, bool: anim = true);

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

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

This include depends on y_hooks to hook the callbacks used within the include -

This include doesn't use anything from here - I just got inspired from it. This include works in a completely different way.
SWAT vs Terrorists
Discord | Website

Last edited by Variable™; 10/04/2019 at 09:22 PM.
Variable™ is offline   Reply With Quote