Raised This Month: $51 Target: $400
 12% 

Ham_takedamage and global var


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 06-10-2012 , 16:11   Ham_takedamage and global var
Reply With Quote #1

So ... Here's what am trying to do :

PHP Code:
#include <amxmodx>
#include <hamsandwich>

#define PLUGIN "Test"
#define VERSION "1.0"
#define AUTHOR "Epic"

new TestPlayer;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_TakeDamage"player""Fw_TakeDamage")
    
    
register_clcmd("say /test""Test")
}

public 
Test(id)
{
    
TestPlayer id
}

public 
Fw_TakeDamage(victiminflictorattackerFloat:damagedamagetype)
{
    if(
attacker == TestPlayer)
    {
        
client_print(0print_chat"Attacker is a test player")
    }
    else if(
attacker != TestPlayer)
    {
        
client_print(0print_chat"Attacker is not test player")
    }

here's the problem , when i attack a player , it doesnt print a message , but when another play attack me , it shows that Attacker is not a test player.

Any help would be appreciated , even a hint would be appreciated ...

Last edited by EpicMonkey; 06-10-2012 at 16:16.
EpicMonkey is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-10-2012 , 17:02   Re: Ham_takedamage and global var
Reply With Quote #2

Are you testing on condition zero bots ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 06-10-2012 , 17:26   Re: Ham_takedamage and global var
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
Are you testing on condition zero bots ?
... dont tell me thats the problem ....

Last edited by EpicMonkey; 06-10-2012 at 17:27.
EpicMonkey is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-10-2012 , 17:33   Re: Ham_takedamage and global var
Reply With Quote #4

Bots need to be registered differently than players for Ham hooks.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-10-2012 , 19:16   Re: Ham_takedamage and global var
Reply With Quote #5

Install : http://forums.alliedmods.net/showpos...3&postcount=15

And in your plugin add :

PHP Code:
public cz_bot_ham_registerablebotIndex )
{
    
RegisterHamFromEntity(Ham_TakeDamagebotIndex"Fw_TakeDamage")

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 06-11-2012 , 01:40   Re: Ham_takedamage and global var
Reply With Quote #6

Quote:
Originally Posted by Exolent[jNr] View Post
Bots need to be registered differently than players for Ham hooks.
once again , thank you for enlightening me.


Quote:
Originally Posted by ConnorMcLeod View Post
Install : http://forums.alliedmods.net/showpos...3&postcount=15

And in your plugin add :

PHP Code:
public cz_bot_ham_registerablebotIndex )
{
    
RegisterHamFromEntity(Ham_TakeDamagebotIndex"Fw_TakeDamage")

thanks conner , ur the man
EpicMonkey is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 06-12-2012 , 16:29   Re: Ham_takedamage and global var
Reply With Quote #7

So , I tried this with a real player ... and its still bugg'ish ...
PHP Code:
#include <amxmodx>
#include <hamsandwich>

#define PLUGIN "Test"
#define VERSION "1.0"
#define AUTHOR "Epic"

new g_test1g_test2g_maxplayers;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /Test""TestMenu")
    
RegisterHam(Ham_TakeDamage"player""Fw_TakeDamage")
    
    
g_maxplayers get_maxplayers()
}

public 
TestMenu(id)
{
    new 
menu menu_create("Select a test player:""TestMenu_handler");
        
    new 
players[32], pnumtempid;
    new 
szName[32], szTempid[10];
        
    
get_players(playerspnum);
        
    for( new 
ii<pnumi++ )
    {
        
tempid players[i];
            
        
get_user_name(tempidszName31);
        
num_to_str(tempidszTempid9);
        
        
menu_additem(menuszNameszTempid0);
    }
    
menu_display(idmenu0);
}

public 
TestMenu_Handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    
    new 
tempid str_to_num(data)
    
    
g_test1 id
    g_test2 
tempid
    
    menu_destroy
(menu);
    return 
PLUGIN_HANDLED;
}

public 
Fw_TakeDamage(victiminflictorattackerFloat:damagedamagetype)
{
    if(
attacker == g_test1||g_test2 && victim != g_test1||g_test2)
    {
        
client_print(0print_chat"[AMXX] Attacker is a test player")
        return 
HAM_SUPERCEDE
    
}
    if(
attacker != g_test1||g_test2 && victim == g_test1||g_test2)
    {
        
client_print(0print_chat"[AMXX] Attacker is not a test player")
        return 
HAM_SUPERCEDE
    
}
    return 
HAM_HANDLED

test players arent supposed to hit other players , and other players arent supposed to hit test players ... but its giving me wierd results , even when i test it with real players

Last edited by EpicMonkey; 06-14-2012 at 03:12.
EpicMonkey is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-12-2012 , 16:36   Re: Ham_takedamage and global var
Reply With Quote #8

PHP Code:
attacker == g_test1||g_test2 
That's not how conditionals work.
What you would want to do is this:
PHP Code:
(attacker == g_test1 || attacker == g_test2
You do that several times, so be sure to correct them all.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 06-13-2012 , 01:36   Re: Ham_takedamage and global var
Reply With Quote #9

Quote:
Originally Posted by Exolent[jNr] View Post
PHP Code:
attacker == g_test1||g_test2 
That's not how conditionals work.
What you would want to do is this:
PHP Code:
(attacker == g_test1 || attacker == g_test2
You do that several times, so be sure to correct them all.
the basics of scripting ... and i got it all wrong , time to read the wiki again ....
and thanks alot for pointing that out
EpicMonkey is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 06-13-2012 , 16:35   Re: Ham_takedamage and global var
Reply With Quote #10

so what your saying is as simple as:
PHP Code:
if(attacker == g_test1 || attacker == g_test2 && victim != g_test1 || victim != g_test2)
{
return 
HAM_SUPERCEDE;
}
else if(
attacker != g_test1 || attacker != g_test2 && victim == g_test1 || victim == g_test2
{
return 
HAM_SUPERCEDE;


Last edited by EpicMonkey; 06-13-2012 at 16:36.
EpicMonkey is offline
Reply



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 09:14.


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