Raised This Month: $ Target: $400
 0% 

[Ham Sandwich] Ham_TakeDamage Function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Infinity
Junior Member
Join Date: Sep 2009
Old 08-11-2012 , 02:04   [Ham Sandwich] Ham_TakeDamage Function
Reply With Quote #1

Here's a modified part of my code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <hamsandwich>

public plugin_init(){
RegisterHam(Ham_TakeDamage"player""OnPlayerEvent_Damage"1);
}

public 
OnPlayerEvent_Damage(victimcauseattacker1.0){
SOME CODE HERE

I want the code to execute when AT LEAST 1 damage is taken/given but when I try compiling I get the following error:
<47> : error 010: invalid function or declaration
*Line 47 is where the public function "OnPlayerEvent_Damage" is

I read this and I appear to have followed the function format:
http://www.amxmodx.org/funcwiki.php?go=module&id=24

but I'm getting an error for some odd reason.
Infinity is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-11-2012 , 02:31   Re: [Ham Sandwich] Ham_TakeDamage Function
Reply With Quote #2

Why do you have a 1.0 in your function declaration? That doesn't even make any sense. You can't have random numbers in a function declaration. You need to follow the forward format for Ham_TakeDamage in ham_const.inc.
__________________
fysiks is offline
GordonFreeman (RU)
Veteran Member
Join Date: Jan 2010
Location: Uzbekistan
Old 08-11-2012 , 02:36   Re: [Ham Sandwich] Ham_TakeDamage Function
Reply With Quote #3

Try this:

Code:
#include <amxmodx> #include <hamsandwich> public plugin_init(){     RegisterHam(Ham_TakeDamage, "player", "OnPlayerEvent_Damage"); } public OnPlayerEvent_Damage(this, idinflictor, idattacker, Float:damage, damagebits){     SetHamParamFloat(3,1.0) }
__________________
The functional way is the right way
GordonFreeman (RU) is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-11-2012 , 02:41   Re: [Ham Sandwich] Ham_TakeDamage Function
Reply With Quote #4

Quote:
Originally Posted by GordonFreeman (RU) View Post
Try this:

Code:
#include <amxmodx> #include <hamsandwich> public plugin_init(){     RegisterHam(Ham_TakeDamage, "player", "OnPlayerEvent_Damage"); } public OnPlayerEvent_Damage(this, idinflictor, idattacker, Float:damage, damagebits){     SetHamParamFloat(3,1.0) }
He doesn't want to change the damage to 1.0. He wants to execute code when the damage is 1.0 or greater:

PHP Code:
if( damage 1.0 )
{
    
// do stuff

__________________
fysiks is offline
Infinity
Junior Member
Join Date: Sep 2009
Old 08-11-2012 , 02:47   Re: [Ham Sandwich] Ham_TakeDamage Function
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
Why do you have a 1.0 in your function declaration? That doesn't even make any sense. You can't have random numbers in a function declaration. You need to follow the forward format for Ham_TakeDamage in ham_const.inc.
Because I read in the Ham Sandwich docs this:
function(this, idinflictor, idattacker, Float:damage, damagebits)

So I thought I would replace the function with:
Function(victim, cause, attacker, 1.0, damagebits)
Infinity is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 08-11-2012 , 03:54   Re: [Ham Sandwich] Ham_TakeDamage Function
Reply With Quote #6

Quote:
Originally Posted by Infinity View Post
Because I read in the Ham Sandwich docs this:
function(this, idinflictor, idattacker, Float:damage, damagebits)

So I thought I would replace the function with:
Function(victim, cause, attacker, 1.0, damagebits)
Function headers are used to just declare parameters passed to the function. If you want to change how a function is called, either play with the native that calls the function or place code within the function to only execute when certain conditions are met (see fysiks' post).
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Infinity
Junior Member
Join Date: Sep 2009
Old 08-11-2012 , 23:44   Re: [Ham Sandwich] Ham_TakeDamage Function
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
He doesn't want to change the damage to 1.0. He wants to execute code when the damage is 1.0 or greater:

PHP Code:
if( damage 1.0 )
{
    
// do stuff

The if still triggers when I shoot a teammate or if a teammate shoots me, here's a part of my code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <hamsandwich>

public register_init(){
    
RegisterHam(Ham_TakeDamage"player""OnPlayerEvent_Damage"1);
}


public 
OnPlayerEvent_Damage(victiminflictorattackerFloat:damagedamagebits){
    if(
damage 1.0){
        
set_user_camo(victimfalse);
        
set_user_camo(attackerfalse);
        }


Last edited by Infinity; 08-12-2012 at 00:33.
Infinity is offline
Old 08-12-2012, 00:32
Infinity
This message has been deleted by Infinity. Reason: Accidental Double Post
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-12-2012 , 00:42   Re: [Ham Sandwich] Ham_TakeDamage Function
Reply With Quote #8

Quote:
Originally Posted by Infinity View Post
The if still triggers when I shoot a teammate or if a teammate shoots me, here's a part of my code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <hamsandwich>

public register_init(){
    
RegisterHam(Ham_TakeDamage"player""OnPlayerEvent_Damage"1);
}


public 
OnPlayerEvent_Damage(victiminflictorattackerFloat:damagedamagebits){
    if(
damage 1.0){
        
set_user_camo(victimfalse);
        
set_user_camo(attackerfalse);
        }

Well, that sounds logical to me. Why would it not trigger when you shoot someone? Do you have a gun that does 0.5 damage? No.
__________________
fysiks is offline
Infinity
Junior Member
Join Date: Sep 2009
Old 08-12-2012 , 01:06   Re: [Ham Sandwich] Ham_TakeDamage Function
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
Well, that sounds logical to me. Why would it not trigger when you shoot someone? Do you have a gun that does 0.5 damage? No.
Yes, but when you get shot by a teammate you receive 0 damage. I don't want the code to execute when you get shot by a teammate while FF is off.
Infinity is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-12-2012 , 01:28   Re: [Ham Sandwich] Ham_TakeDamage Function
Reply With Quote #10

Quote:
Originally Posted by Infinity View Post
Yes, but when you get shot by a teammate you receive 0 damage. I don't want the code to execute when you get shot by a teammate while FF is off.
Well, you failed to mention that part. What is the value of damage?
__________________
fysiks is offline
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

Forum Jump


All times are GMT -4. The time now is 05:52.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode