[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
#2

Why not let the player decide which key they want? Allow the config to accept multiple possibilities.
Reply
#3

Great job!
Reply
#4

Configurable data should be allowed to change from the text file (*.ini configuration file) located in scriptfiles folder. Not from the code itself. There may still be people that don't know how to compile/edit such a things.
Reply
#5

Well done! I tried to do something similar to this, few weeks ago, but unfortunately, my patience gone
Reply
#6

Good job freund.
Reply
#7

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
Configurable data should be allowed to change from the text file (*.ini configuration file) located in scriptfiles folder. Not from the code itself. There may still be people that don't know how to compile/edit such a things.
That doesn't sound like a good solution at all, the configuration should be able to be changed from the code, but using functions rather than constants, this way users can decide whether and how they want to save the configuration.
Reply
#8

Excellent include.

5 star rating because;

Well documented code (with comments)
Very well sructured code (identation, naming, general layout)
Very well functioning code (No bugs found so far)
Nice idea that has been realised and released publicly.
... and you're a cool guy.

I hope you keep up your good efforts and that you consider making more releases in the future.
Reply
#9

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Why not let the player decide which key they want? Allow the config to accept multiple possibilities.
I could do that, but it isn't a filterscript. It's supposed to be integrated into a gamemode and the function SwitchPlayerWeapon can be used throughout the code. The current manual and automatic weapon switch options are just for people who like it as-is to use it as a plug n' play include, an advanced scripter can easily remove the options I created and use the function in their own gamemode with their own rules and conditions to switch weapon.

I created automatic switch to show how it could be done without much code and in a pretty simple way.

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
Configurable data should be allowed to change from the text file (*.ini configuration file) located in scriptfiles folder. Not from the code itself. There may still be people that don't know how to compile/edit such a things.
Again, this is an include. The function is provided for the scripters to integrate it in their modes and they are supposed to make all of that, I just created the function and two examples of how it can be used.

You know that you need to compile your gamemode to use this include.

Quote:
Originally Posted by Marshas
Посмотреть сообщение
Well done! I tried to do something similar to this, few weeks ago, but unfortunately, my patience gone
Quote:
Originally Posted by justinnater
Посмотреть сообщение
Great job!
Quote:
Originally Posted by Bolex_
Посмотреть сообщение
Good job freund.
Quote:
Originally Posted by denNorske
Посмотреть сообщение
Excellent include.

5 star rating because;

Well documented code (with comments)
Very well sructured code (identation, naming, general layout)
Very well functioning code (No bugs found so far)
Nice idea that has been realised and released publicly.
... and you're a cool guy.

I hope you keep up your good efforts and that you consider making more releases in the future.
Thanks for your comments
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)