Raised This Month: $ Target: $400
 0% 

Problem with ham take damage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tomes11
Member
Join Date: Apr 2010
Old 01-28-2013 , 14:23   Problem with ham take damage
Reply With Quote #1

Hi.

I have a problem with ham take damage. whatever i do its dont do the efects to the victim. Also no error log at compiling and at gameplay :S

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
#include <hamsandwich>
#include <zp50_class_human>
#include <cs_ham_bots_api>

#define TASK_REGENERATION     65845
#define ID_REGEN         (taskid - TASK_REGENERATION)

public plugin_init()
{
    
register_event("HLTV""event_round_start""a""1=0""2=0")

    
RegisterHam(Ham_TakeDamage"player""ham_take_damage")
}
public 
ham_take_damage(taskidinflictorattackerFloat:damagedamagebits)
{
    
remove_task(ID_REGEN+TASK_REGENERATION)
    
set_task(5.0"RemoveBlockRegen"ID_REGEN+TASK_REGENERATION)
}

public 
RemoveBlockRegen(taskid)
{
    
set_task(0.2"regeneration"ID_REGEN+TASK_REGENERATION__"b")    
}
//rest of my code 
tomes11 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-28-2013 , 20:34   Re: Problem with ham take damage
Reply With Quote #2

I see some poor coding there. First explain, in words, what exactly you want to happen when a player takes damage. Then, attach your full code as an attachment.
__________________
fysiks is offline
tomes11
Member
Join Date: Apr 2010
Old 01-29-2013 , 00:58   Re: Problem with ham take damage
Reply With Quote #3

soo what i want is when a player hit by an enemy he will stop regenerating his armor and after 5 sec armor regeneration continous.

The basic regeneration works. And player will got only 1 effect regeneration every round.

Thanks for the help.
Attached Files
File Type: sma Get Plugin or Get Source (zp50_class_human_Regen.sma - 819 views - 2.6 KB)

Last edited by tomes11; 01-29-2013 at 00:59.
tomes11 is offline
tomes11
Member
Join Date: Apr 2010
Old 02-13-2013 , 14:19   Re: Problem with ham take damage
Reply With Quote #4

I tried to modify it, but it didn't worked.

PHP Code:
public ham_take_damage(victiminflictorattackerFloat:damagedamagebits)
{
    if(
is_user_connected(victim) && is_user_alive(victim))
    {
        
remove_task(victim+TASK_BLOCK)
        
set_task(5.0"RemoveBlockRegen"victim+TASK_BLOCK)
    }
}

public 
RemoveBlockRegen(taskid)
{
    
remove_task(ID_BLOCK+TASK_REGENERATION)
    
set_task(0.2"regeneration"ID_BLOCK+TASK_REGENERATION__"b")    

what is the problem?
Attached Files
File Type: sma Get Plugin or Get Source (zp50_class_human_Regen.sma - 731 views - 2.7 KB)
tomes11 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-13-2013 , 21:05   Re: Problem with ham take damage
Reply With Quote #5

I don't think that this code ever worked. You need to remove the following variable from your code completely so you can do it correctly:

PHP Code:
#define ID_REGEN         (taskid - TASK_REGENERATION)
#define ID_BLOCK        (taskid - TASK_BLOCK) 
Once you fix that, it should be easier for you to fix the "issue" that you are current claiming to have.
__________________

Last edited by fysiks; 02-13-2013 at 21:07.
fysiks is offline
tomes11
Member
Join Date: Apr 2010
Old 02-14-2013 , 08:45   Re: Problem with ham take damage
Reply With Quote #6

but if i use it without the ID_REGEN i always got invalid player (65846). Soo basicly i can set up the task first with this:
PHP Code:
set_task(0.2"regeneration"id+TASK_REGENERATION__"b"
but after that in regeneration how to do it correctly?
PHP Code:
public regeneration(id)
{
    if(
is_user_alive(id) || !zp_get_user_zombie(id))
        
set_pev(idpev_armorvaluefloat(min(pev(idpev_armorvalue) + g_add_regen_armorg_max_regen)))

tomes11 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 02-14-2013 , 08:49   Re: Problem with ham take damage
Reply With Quote #7

id-TASK_REGENERATION
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
tomes11
Member
Join Date: Apr 2010
Old 02-14-2013 , 12:29   Re: Problem with ham take damage
Reply With Quote #8

with this the regeneration works perfect, but hame_take_damage stil not. and no error log :S
PHP Code:
public ham_take_damage(victiminflictorattackerFloat:damagedamagebits)
{
    if(
is_user_connected(victim) && is_user_alive(victim) && !zp_core_is_zombie(victim)) // called when a player got hit
    
{
        
remove_task(victim+TASK_REGENERATION//remove current regeneration??
        
remove_task(victim+TASK_BLOCK//remove current delay counter??
        
set_task(5.0"RemoveBlockRegen"victim+TASK_BLOCK//then activate it
    
}
}

public 
RemoveBlockRegen(id// called when counter reaches 5 sec
{
    
remove_task(id+TASK_BLOCK// just to be sure that counter removed
    
set_task(0.2"regeneration"id+TASK_REGENERATION__"b"// start the regeneration    

tomes11 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-15-2013 , 01:59   Re: Problem with ham take damage
Reply With Quote #9

Your Ham_TakeDamage function is done correctly. You need to think logically about what you are doing in your task function.

First of all, you don't need to remove the task in the task function itself since it will only execute once (meaning it's not a repeating task).

In your ham function, you added 65840 to the id. Then, you go and add it again . . . The player id is not passed to the task's function. The whole value is passed. So, the "id" in RemoveBlockRegen is that whole value. If the player's actual id is 15, then "id" in that function will have the value of 15+65840.
__________________
fysiks is offline
tomes11
Member
Join Date: Apr 2010
Old 02-15-2013 , 11:21   Re: Problem with ham take damage
Reply With Quote #10

I checked, that whatever i got hit is something hapens to me, but not. Added a simple chat message and it didnt showed. Soo the ham dont work?
just added this line:
PHP Code:
ColorChat(victimGREEN"^1[^4ZP^1] You have been hit by a zombie!"

Last edited by tomes11; 02-15-2013 at 11:24.
tomes11 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 20:31.


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