AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with ham take damage (https://forums.alliedmods.net/showthread.php?t=207005)

tomes11 01-28-2013 14:23

Problem with ham take damage
 
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 


fysiks 01-28-2013 20:34

Re: Problem with ham take damage
 
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.

tomes11 01-29-2013 00:58

Re: Problem with ham take damage
 
1 Attachment(s)
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.

tomes11 02-13-2013 14:19

Re: Problem with ham take damage
 
1 Attachment(s)
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?

fysiks 02-13-2013 21:05

Re: Problem with ham take damage
 
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.

tomes11 02-14-2013 08:45

Re: Problem with ham take damage
 
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)))



YamiKaitou 02-14-2013 08:49

Re: Problem with ham take damage
 
id-TASK_REGENERATION

tomes11 02-14-2013 12:29

Re: Problem with ham take damage
 
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    



fysiks 02-15-2013 01:59

Re: Problem with ham take damage
 
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.

tomes11 02-15-2013 11:21

Re: Problem with ham take damage
 
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!"



All times are GMT -4. The time now is 20:31.

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