SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 24/02/2014, 03:36 AM   #1
Scaleta
Big Clucker
 
Join Date: May 2013
Posts: 88
Reputation: 29
Default [SPC] Custom Damage (Now on GitHub!)

Short Pieces of Code - Custom Damage (UPDATED 25/2/2014)


NOTE

If you are using the 0.3z version of this include, please update it to the one currently in the repository.

About

So, I saw a lot of people made "custom damage scripts", but none of these was ever actual custom damage. It simply added onto the current damage and caused problems when the normal damage already killed the player. I first devised the method on the same idea, but it was bugged so I scrapped it. Then, I realized two key pieces missing to the method. 1. Set their team and you can manage the damage yourself. 2. The bug which fatally destroyed my last system.

I am currently using this system, but I still like to contribute to the community as it would be pointless to just keep it to myself.

Notes

The 0.3z version is untested and might not work with all weapons.
The normal version _will_ conflict if you use SetPlayerTeam within your script.
It is suggested that you modify the damages to your liking, as they are not all great amounts.

Current Releases
Documentation

The normal version of this include blocks normal SA-MP damage by setting the player's team and then handling the damage when it normally would have been taken.

With this you could factor in damage modifiers with bodypart hits

Example
pawn Code:
// If statement for just one, but you can use a switch for all.
// Do not forget to define the parts, as they are not already in the samp include.
#define BODY_PART_TORSO 3
if(bodypart == BODY_PART_TORSO) damage *= 2.0; // this would be outrageous to increment by, it's an example.

The 0.3z version uses the OnPlayerWeaponShot, handles the damage and then blocks the shot (this part was untested, compared to the normal). I only made this version to allow compatibility with servers that use multiple teams.

This is meant to be short and sweet, as it is apart of the Short Pieces of Code library.
__________________
Developer at Next Generation Gaming

Last edited by Scaleta; 03/03/2014 at 06:16 AM. Reason: Now on GitHub!
Scaleta is offline   Reply With Quote
Old 24/02/2014, 03:42 AM   #2
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,703
Reputation: 1176
Default Re: [SPC] Custom Damage

9.0 value as MELEE_DAMAGE seems to be much, but yeah the coders could edit it if they're using. You seem to use the _ALS_ hooking method at the last of the include but the callbacks aren't hooked yet in calling out that callback used somewhere else. This usage might not bypass the code or compile well if being re-used. Other than that, the include seems interesting.
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.
Lordzy is offline   Reply With Quote
Old 24/02/2014, 03:48 AM   #3
Scaleta
Big Clucker
 
Join Date: May 2013
Posts: 88
Reputation: 29
Default Re: [SPC] Custom Damage

Quote:
Originally Posted by Lordz™ View Post
9.0 value as MELEE_DAMAGE seems to be much, but yeah the coders could edit it if they're using. You seem to use the _ALS_ hooking method at the last of the include but the callbacks aren't hooked yet in calling out that callback used somewhere else. This usage might not bypass the code or compile well if being re-used. Other than that, the include seems interesting.
The damage values were off the top of my head and are meant to be edited. As for the hooking, would you suggest another method of doing so, as it works fine.
__________________
Developer at Next Generation Gaming
Scaleta is offline   Reply With Quote
Old 24/02/2014, 08:48 AM   #4
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,703
Reputation: 1176
Default Re: [SPC] Custom Damage

Quote:
Originally Posted by Scaleta View Post
The damage values were off the top of my head and are meant to be edited. As for the hooking, would you suggest another method of doing so, as it works fine.
According to the one I use these days:
pawn Code:
public OnPlayerConnect(playerid)
{
    //codes.
    #if defined LIBNAME_OnPlayerConnect
    return LIBNAME_OnPlayerConnect(playerid); //This is being done to get this include compatible with the scripts using it. So in case if those scripts too use the same callback, it would call it.
    #else
    return 1;
    #endif
}

#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif

#define OnPlayerConnect LIBNAME_OnPlayerConnect

#if defined LIBNAME_OnPlayerConnect
forward LIBNAME_OnPlayerConnect(playerid);
#endif

^
This hook method being used is some what called "Hook method 7" and you can get the tutorial of it explained well from the below link. I'm also adding the old hooking method's tutorial which would probably fix your confusion about hooking process.

http://forum.sa-mp.com/showthread.php?t=441293 - Hook method 7
http://forum.sa-mp.com/showthread.php?t=392061 - Normal hooking.
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.
Lordzy is offline   Reply With Quote
Old 25/02/2014, 01:51 AM   #5
Scaleta
Big Clucker
 
Join Date: May 2013
Posts: 88
Reputation: 29
Default Re: [SPC] Custom Damage

EDIT:

The topic was updated and the hooking will no longer conflict with your script.

Thanks to Lordz for his assistance on this understanding.
__________________
Developer at Next Generation Gaming

Last edited by Scaleta; 25/02/2014 at 11:23 PM.
Scaleta is offline   Reply With Quote
Old 10/03/2014, 09:01 PM   #6
John_Cooper
Big Clucker
 
Join Date: Jul 2010
Posts: 95
Reputation: 27
Default Re: [SPC] Custom Damage

Thanks. Will for sure use this.
John_Cooper 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
Question about custom damage Voxel Scripting Help 5 18/01/2014 12:36 AM
[FilterScript] Easy custom damage + damage sound Voxel Filterscripts 14 30/09/2013 05:07 PM
How to detect vehicle damage, and get damage taken? Micius Scripting Help 4 31/07/2013 05:08 PM
Custom weapon damage problems with kill-logs? Mado Scripting Help 2 08/01/2013 09:43 AM
[Include] Car damage system - Damage a car without a driver! The_Moddler Includes 68 30/03/2012 02:38 AM


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


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