SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 10/04/2019, 12:43 AM   #1
Variable™
Gangsta
 
Join Date: Jul 2015
Posts: 787
Reputation: 175
Smile multi-weapon2.inc - Multi-weapon switch system with a lot of features

multi-weapon2.inc
I was inspired by this release https://forum.sa-mp.com/showthread.php?t=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://wiki.sa-mp.com/wiki/Keys and replace KEY_WALK with one of the keys in that page.

pawn Code:
//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 Code:
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://forum.sa-mp.com/showthread.php?t=665507 - 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
Old 10/04/2019, 01:56 AM   #2
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,857
Reputation: 1292
Default Re: multi-weapon2.inc - Multi-weapon switch system with a lot of features

Why not let the player decide which key they want? Allow the config to accept multiple possibilities.
Pottus is offline   Reply With Quote
Old 10/04/2019, 02:46 AM   #3
justinnater
Huge Clucker
 
justinnater's Avatar
 
Join Date: Jan 2011
Posts: 249
Reputation: 85
Default Re: multi-weapon2.inc - Multi-weapon switch system with a lot of features

Great job!
justinnater is offline   Reply With Quote
Old 10/04/2019, 05:39 AM   #4
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,795
Reputation: 223
Default Re: multi-weapon2.inc - Multi-weapon switch system with a lot of features

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.
Riddick94 is offline   Reply With Quote
Old 10/04/2019, 11:54 AM   #5
Marshas
Little Clucker
 
Join Date: Apr 2017
Posts: 37
Reputation: 0
Default Re: multi-weapon2.inc - Multi-weapon switch system with a lot of features

Well done! I tried to do something similar to this, few weeks ago, but unfortunately, my patience gone
Marshas is offline   Reply With Quote
Old 10/04/2019, 12:26 PM   #6
Bolex_
Gangsta
 
Bolex_'s Avatar
 
Join Date: Aug 2015
Location: Croatia.
Posts: 577
Reputation: 117
Default Re: multi-weapon2.inc - Multi-weapon switch system with a lot of features

Good job freund.
Bolex_ is offline   Reply With Quote
Old 10/04/2019, 12:56 PM   #7
kristo
Banned
 
Join Date: Jun 2012
Location: Estonia
Posts: 370
Reputation: 179
Default Re: multi-weapon2.inc - Multi-weapon switch system with a lot of features

Quote:
Originally Posted by Riddick94 View Post
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.
kristo is offline   Reply With Quote
Old 10/04/2019, 07:56 PM   #8
denNorske
Banned
 
Join Date: Nov 2011
Location: Oslo, Norway
Posts: 788
Reputation: 95
Default Re: multi-weapon2.inc - Multi-weapon switch system with a lot of features

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.
denNorske is offline   Reply With Quote
Old 10/04/2019, 11:06 PM   #9
Variable™
Gangsta
 
Join Date: Jul 2015
Posts: 787
Reputation: 175
Default Re: multi-weapon2.inc - Multi-weapon switch system with a lot of features

Quote:
Originally Posted by Pottus View Post
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 View Post
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 View Post
Well done! I tried to do something similar to this, few weeks ago, but unfortunately, my patience gone
Quote:
Originally Posted by justinnater View Post
Great job!
Quote:
Originally Posted by Bolex_ View Post
Good job freund.
Quote:
Originally Posted by denNorske View Post
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
__________________
SWAT vs Terrorists
Discord | Website
Variable™ 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
[Include] Multi-Weapon - Able to switch to every weapon received justinnater Includes 11 21/04/2019 04:04 PM
[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
[HELP] Multi langauge system Dusan01 Scripting Help 8 01/08/2015 04:58 PM
[GameMode] Jueix's Multi mod / Los Entertainment Multi mod Release jueix Gamemode Scripts 15 09/08/2014 12:41 PM
[FilterScript] Lach's Multi AFK System Antonio [G-RP] Filterscripts 12 05/03/2012 02:00 PM


All times are GMT. The time now is 02:26 AM.


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