SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 26/09/2017, 09:35 PM   #711
Jeroen52
Gangsta
 
Jeroen52's Avatar
 
Join Date: Oct 2008
Location: The Netherlands
Posts: 803
Reputation: 62
Default Re: weapon-config.inc - Damage system with many features

Quote:
Originally Posted by ToySoldier View Post
Yeah I did read that but only got it working copy pasting an example on page 50 something. Thx anyway. Gonna try to reduce cbug damage now, spend a day or so trying to make sense of something way out of my league, fail miserably, cry a little and then return here to ask for help.
Put this in OnPlayerDamage to reduce cbug damage.

PHP Code:
        new avg_rate AverageShootRate(issuerid2);
        
        
// Lower rapid fire damage
        
if (avg_rate != -1) {
            if (
weapon == WEAPON_DEAGLE && avg_rate 500)
                
amount *= 0.50;
            else if (
weapon == WEAPON_SHOTGSPA && avg_rate 250)
                
amount *= 0.50;
        } 
__________________
Jeroen52 is offline   Reply With Quote
Old 26/09/2017, 10:10 PM   #712
ToySoldier
Big Clucker
 
Join Date: Feb 2013
Posts: 129
Reputation: 13
Default Re: weapon-config.inc - Damage system with many features

This is my OnPlayerDamage. When I compile with the cbug part my pawn library stops working.
PHP Code:
public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart)
{
    
/*
     *    Explaining OnPlayerDamage a bit.
     *    OnPlayerDamage is called whenever a player has been damaged, you can use this to modify the amount of damage.
     *    OnPlayerDamage MUST return a value, if you return `1` it will issue the playerid the `amount` on behalf of the `issuerid`, if you return `0` no damage will be issued.
     *    Parameters:
     *        • `playerid`: The player that receives the damage.
     *        • `amount`: The amount of damage that will be issued.
     *        • `issuerid`: The player that issued the damage.
     *        • `weapon`: The weaponid of the weapon that is used to issue the damage.
     *        • `bodypart`: The bodypart that has been damaged/shot, you can use this to make a headshot system or increase/decrease damage depending on bodypart.
     */

    
if(issuerid != INVALID_PLAYER_ID && playerid != INVALID_PLAYER_ID// Check if the issuer (issuerid) is a valid player and the receiver (playerid) is a valid player
    
{
        if(
weapon == 24// Check if the weapon is a deagle
            
amount 32// Set the damage to 32
           
if(weapon == 30// ak47
            
amount 6;
           if(
weapon == 31// m4
            
amount 6;
           if(
weapon == 29// mp5
            
amount 5;
           if(
weapon == 33// rifle cuntgun
            
amount 17;


    }
    return 
1// Return 1 to issue the damage
}
        new 
avg_rate AverageShootRate(issuerid2);

        
// Lower rapid fire damage
        
if (avg_rate != -1) {
            if (
weapon == WEAPON_DEAGLE && avg_rate 500)
                
amount *= 0.50;
            else if (
weapon == WEAPON_SHOTGSPA && avg_rate 250)
                
amount *= 0.50;
        }
    return 
1;

[/QUOTE]
__________________

Vês! Ninguém assistiu ao formidável
Enterro de tua última quimera.
Somente a Ingratidão - esta pantera -
Foi tua companheira inseparável!

Acostuma-te à lama que te espera!
O Homem, que, nesta terra miserável,
Mora, entre feras, sente inevitável
Necessidade de também ser fera.

Toma um fósforo. Acende teu cigarro!
O beijo, amigo, é a véspera do escarro,
A mão que afaga é a mesma que apedreja.

Se a alguém causa inda pena a tua chaga,
Apedreja essa mão vil que te afaga,
Escarra nessa boca que te beija!
- Augusto dos Anjos
ToySoldier is offline   Reply With Quote
Old 26/09/2017, 10:18 PM   #713
Jeroen52
Gangsta
 
Jeroen52's Avatar
 
Join Date: Oct 2008
Location: The Netherlands
Posts: 803
Reputation: 62
Default Re: weapon-config.inc - Damage system with many features

Quote:
Originally Posted by ToySoldier View Post
This is my OnPlayerDamage. When I compile with the cbug part my pawn library stops working.
PHP Code:
public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart)
{
    
/*
     *    Explaining OnPlayerDamage a bit.
     *    OnPlayerDamage is called whenever a player has been damaged, you can use this to modify the amount of damage.
     *    OnPlayerDamage MUST return a value, if you return `1` it will issue the playerid the `amount` on behalf of the `issuerid`, if you return `0` no damage will be issued.
     *    Parameters:
     *        • `playerid`: The player that receives the damage.
     *        • `amount`: The amount of damage that will be issued.
     *        • `issuerid`: The player that issued the damage.
     *        • `weapon`: The weaponid of the weapon that is used to issue the damage.
     *        • `bodypart`: The bodypart that has been damaged/shot, you can use this to make a headshot system or increase/decrease damage depending on bodypart.
     */

    
if(issuerid != INVALID_PLAYER_ID && playerid != INVALID_PLAYER_ID// Check if the issuer (issuerid) is a valid player and the receiver (playerid) is a valid player
    
{
        if(
weapon == 24// Check if the weapon is a deagle
            
amount 32// Set the damage to 32
           
if(weapon == 30// ak47
            
amount 6;
           if(
weapon == 31// m4
            
amount 6;
           if(
weapon == 29// mp5
            
amount 5;
           if(
weapon == 33// rifle cuntgun
            
amount 17;


    }
    return 
1// Return 1 to issue the damage
}
        new 
avg_rate AverageShootRate(issuerid2);

        
// Lower rapid fire damage
        
if (avg_rate != -1) {
            if (
weapon == WEAPON_DEAGLE && avg_rate 500)
                
amount *= 0.50;
            else if (
weapon == WEAPON_SHOTGSPA && avg_rate 250)
                
amount *= 0.50;
        }
    return 
1;

Change it to this.
PHP Code:
public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart)
{
    
/*
     *    Explaining OnPlayerDamage a bit.
     *    OnPlayerDamage is called whenever a player has been damaged, you can use this to modify the amount of damage.
     *    OnPlayerDamage MUST return a value, if you return `1` it will issue the playerid the `amount` on behalf of the `issuerid`, if you return `0` no damage will be issued.
     *    Parameters:
     *        • `playerid`: The player that receives the damage.
     *        • `amount`: The amount of damage that will be issued.
     *        • `issuerid`: The player that issued the damage.
     *        • `weapon`: The weaponid of the weapon that is used to issue the damage.
     *        • `bodypart`: The bodypart that has been damaged/shot, you can use this to make a headshot system or increase/decrease damage depending on bodypart.
     */

    
if(issuerid != INVALID_PLAYER_ID && playerid != INVALID_PLAYER_ID// Check if the issuer (issuerid) is a valid player and the receiver (playerid) is a valid player
    
{
        if(
weapon == 24// Check if the weapon is a deagle
            
amount 32// Set the damage to 32
        
if(weapon == 30// ak47
            
amount 6;
        if(
weapon == 31// m4
            
amount 6;
        if(
weapon == 29// mp5
            
amount 5;
        if(
weapon == 33// rifle cuntgun
            
amount 17;
    }
    
    new 
avg_rate AverageShootRate(issuerid2);
    
    
// Lower rapid fire damage
    
if (avg_rate != -1) {
        if (
weapon == WEAPON_DEAGLE && avg_rate 500)
            
amount *= 0.50;
        else if (
weapon == WEAPON_SHOTGSPA && avg_rate 250)
            
amount *= 0.50;
    }
    return 
1// Return 1 to issue the damage

And using the following is not the best way to do custom weapon damage.
PHP Code:
    if(issuerid != INVALID_PLAYER_ID && playerid != INVALID_PLAYER_ID// Check if the issuer (issuerid) is a valid player and the receiver (playerid) is a valid player
    
{
        if(
weapon == 24// Check if the weapon is a deagle
            
amount 32// Set the damage to 32
        
if(weapon == 30// ak47
            
amount 6;
        if(
weapon == 31// m4
            
amount 6;
        if(
weapon == 29// mp5
            
amount 5;
        if(
weapon == 33// rifle cuntgun
            
amount 17;
    } 
Instead you should put this somewhere else in your code.

PHP Code:
    SetWeaponDamage(WEAPON_DEAGLEDAMAGE_TYPE_STATIC32.0);
    
SetWeaponDamage(WEAPON_AK47DAMAGE_TYPE_STATIC6.0);
    
SetWeaponDamage(WEAPON_M4DAMAGE_TYPE_STATIC6.0);
    
SetWeaponDamage(WEAPON_MP5DAMAGE_TYPE_STATIC5.0);
    
SetWeaponDamage(WEAPON_RIFLEDAMAGE_TYPE_STATIC17.0); 
__________________
Jeroen52 is offline   Reply With Quote
Old 26/09/2017, 10:47 PM   #714
ToySoldier
Big Clucker
 
Join Date: Feb 2013
Posts: 129
Reputation: 13
Default Re: weapon-config.inc - Damage system with many features

Too kind, good sir. Everything is working like a charm now. But until I started using weapon-config I didn't get any warnings. Do you know if these are worth worrying about?

include\weapon-config.inc(339 : warning 219: local variable "hitid" shadows a variable at a preceding level
include\weapon-config.inc(5320) : warning 219: local variable "hour" shadows a variable at a preceding level
include\weapon-config.inc(5320) : warning 219: local variable "minute" shadows a variable at a preceding level
include\weapon-config.inc(5320) : warning 219: local variable "second" shadows a variable at a preceding level
include\seif_walk.inc(5 : warning 201: redefinition of constant/macro (symbol "OnPlayerKeyStateChange")
__________________

Vês! Ninguém assistiu ao formidável
Enterro de tua última quimera.
Somente a Ingratidão - esta pantera -
Foi tua companheira inseparável!

Acostuma-te à lama que te espera!
O Homem, que, nesta terra miserável,
Mora, entre feras, sente inevitável
Necessidade de também ser fera.

Toma um fósforo. Acende teu cigarro!
O beijo, amigo, é a véspera do escarro,
A mão que afaga é a mesma que apedreja.

Se a alguém causa inda pena a tua chaga,
Apedreja essa mão vil que te afaga,
Escarra nessa boca que te beija!
- Augusto dos Anjos
ToySoldier is offline   Reply With Quote
Old 26/09/2017, 11:16 PM   #715
Jeroen52
Gangsta
 
Jeroen52's Avatar
 
Join Date: Oct 2008
Location: The Netherlands
Posts: 803
Reputation: 62
Default Re: weapon-config.inc - Damage system with many features

Looks like you have the variables "hitid", "hour", "minute", and "second" somewhere else in the code on a global level. Try to correct that or change the variable names inside weapon-config to something else.

And it looks like both weapon-config and seif_walk redefine OnPlayerKeyStateChange, make sure that it is only defined once.
__________________
Jeroen52 is offline   Reply With Quote
Old 27/09/2017, 01:56 AM   #716
playZeD
Little Clucker
 
Join Date: Sep 2017
Posts: 10
Reputation: 2
Default Re: weapon-config.inc - Damage system with many features

cool thing thanks a lot !
playZeD is offline   Reply With Quote
Old 28/09/2017, 04:07 PM   #717
ToySoldier
Big Clucker
 
Join Date: Feb 2013
Posts: 129
Reputation: 13
Unhappy Re: weapon-config.inc - Damage system with many features

This is a great include.
__________________

Vês! Ninguém assistiu ao formidável
Enterro de tua última quimera.
Somente a Ingratidão - esta pantera -
Foi tua companheira inseparável!

Acostuma-te à lama que te espera!
O Homem, que, nesta terra miserável,
Mora, entre feras, sente inevitável
Necessidade de também ser fera.

Toma um fósforo. Acende teu cigarro!
O beijo, amigo, é a véspera do escarro,
A mão que afaga é a mesma que apedreja.

Se a alguém causa inda pena a tua chaga,
Apedreja essa mão vil que te afaga,
Escarra nessa boca que te beija!
- Augusto dos Anjos

Last edited by ToySoldier; 05/10/2017 at 01:43 AM.
ToySoldier is offline   Reply With Quote
Old 07/10/2017, 11:21 PM   #718
Skream
Huge Clucker
 
Skream's Avatar
 
Join Date: Apr 2012
Posts: 230
Reputation: 59
Default Re: weapon-config.inc - Damage system with many features

Is there any version fixing the y_hooks conflict?
Skream is offline   Reply With Quote
Old 29/10/2017, 05:37 PM   #719
MBilal
Gangsta
 
MBilal's Avatar
 
Join Date: May 2013
Location: Pakistan
Posts: 793
Reputation: 53
Default Re: weapon-config.inc - Damage system with many features

How to delay the death of the player who got headshooted ?

I'm using the 2 sec Timer to set his health to 0 using SetPlayerHealth(playerid,0); but the problem is in deathlist it showing he got killed by no one like he did /kill .
I'm doing this right now. this was working fine with OnPlayerTakeDamage before but after changing it to OnPlayerDamage it's not working like it was.
Code:
public OnPlayerHeadshot(Float:Ax, Float:Ay, Float:Az, playerid)
{
	KillTimer(HeadshotTimer[playerid]);
 	DestroyObject(blood[playerid]);
        SetPLayerHealth(playerid,0); 
	return 1;
}
Should i do this?
Code:
public OnPlayerHeadshot(Float:Ax, Float:Ay, Float:Az, playerid,Float:amount)
{
	KillTimer(HeadshotTimer[playerid]);
 	DestroyObject(blood[playerid]);
        amount = 0.0;
	return 1;
}
MBilal is offline   Reply With Quote
Old 29/10/2017, 06:10 PM   #720
Jeroen52
Gangsta
 
Jeroen52's Avatar
 
Join Date: Oct 2008
Location: The Netherlands
Posts: 803
Reputation: 62
Default Re: weapon-config.inc - Damage system with many features

Quote:
Originally Posted by MBilal View Post
How to delay the death of the player who got headshooted ?

I'm using the 2 sec Timer to set his health to 0 using SetPlayerHealth(playerid,0); but the problem is in deathlist it showing he got killed by no one like he did /kill .
I'm doing this right now. this was working fine with OnPlayerTakeDamage before but after changing it to OnPlayerDamage it's not working like it was.
Code:
public OnPlayerHeadshot(Float:Ax, Float:Ay, Float:Az, playerid)
{
	KillTimer(HeadshotTimer[playerid]);
 	DestroyObject(blood[playerid]);
        SetPLayerHealth(playerid,0); 
	return 1;
}
Should i do this?
Code:
public OnPlayerHeadshot(Float:Ax, Float:Ay, Float:Az, playerid,Float:amount)
{
	KillTimer(HeadshotTimer[playerid]);
 	DestroyObject(blood[playerid]);
        amount = 0.0;
	return 1;
}
You could try to do it with OnPlayerPrepareDeath or OnPlayerDeathFinished.
But I recommend you to view https://github.com/oscar-broman/samp-weapon-config anyways.
__________________
Jeroen52 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
Help with weapon damage system thanks JessThompson Scripting Help 7 15/07/2014 02:01 PM
[FilterScript] New Weapon Damage System [0.3z] RenSoprano Filterscripts 6 17/01/2014 07:03 AM
[FilterScript] Weapon damage system [v1.0] Darnell Filterscripts 74 21/10/2013 09:53 PM
[FilterScript] Weapon Damage System Donicans Filterscripts 14 06/11/2012 02:22 PM
[FilterScript] Realistic Weapon Damage And Death System [V1.0][New Cool FS] Nirzor Filterscripts 6 08/08/2012 06:34 AM


All times are GMT. The time now is 12:19 PM.


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