AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   If damaged teammate more then 100 or 50 HP, print a message (https://forums.alliedmods.net/showthread.php?t=164011)

Diegorkable 08-06-2011 07:37

If damaged teammate more then 100 or 50 HP, print a message
 
Hey guys, I did a script, just like the title says, and hooked it up as a HAM, and for some wierd reason, after g_IsStarted is being set to true, when someone shoots his teammate's leg, which is way less than 100 or 50 HP, it is printing both messages at the same time, and for some reason it detects that the damage the player did to his teammates (which is stored in g_LeftKills) is more than 100.... someone can see the bug?

PHP Code:

public tk(victiminflictorkillerdamagebits)
{
    if (
killer == victim)
    {
        
damage 0
    
}
    
    if (
g_IsStarted)
    {
        if ((
cs_get_user_team(killer) == cs_get_user_team(victim)))
        {
            new 
temp
            
            
if (g_LeftKills[killer] >= 100)
            {
                
temp 1
            
}
            
            if (
temp != 1)
            {
                
g_LeftKills[killer] += damage
            
                
if (g_LeftKills[killer] > 50)
                {
                    
client_print(killerprint_chat"%s Warning! Attacking your teammates can get you banned."PREFIX)
                }
            
                if (
g_LeftKills[killer] >= 100)
                {
                    new 
nameofp[50]
                
                    
get_user_name(killernameofp49)
                    
client_print(0print_chat ,"%s  If %s is team attacking just to be annoying, use .voteban"PREFIXnameofp)
                }
            }
        }
    }
    
    return 
PLUGIN_CONTINUE


Here is the register:

PHP Code:

RegisterHam(Ham_TakeDamage"player""tk"

Also, at public client_connect, g_leftkills of a user is being set to 0, so its not a pervious set...

fysiks 08-06-2011 14:26

Re: If damaged teammate more then 100 or 50 HP, print a message
 
What is the value of damage when you shoot him in the leg? What is the value of g_LeftKills[killer] when you shoot him in the left (before adding damage)?

Also, the damage variable is a float so you must treat it as such (meaning that g_LeftKills must be declared as float) and you must compare to floats and not integers (100.0 instead of 100).


You could also consider http://www.amxmodx.org/funcwiki.php?go=func&id=896

Doc-Holiday 08-07-2011 00:40

Re: If damaged teammate more then 100 or 50 HP, print a message
 
also use

set ham param float. to set damage to 0 if you dchange the value of damage

you need to return HAM_SUPERCEDE or OVERRIDE.

Diegorkable 08-07-2011 06:09

Re: If damaged teammate more then 100 or 50 HP, print a message
 
@fysiks - at public client_connect g_LeftKills[id] is being set to 0, besides, there's no place in the code where the leftkills is being set (except 0) besides the "tk" public. And I'll make sure to treat all its values to floats.

@Doc-Holiday, I really dont know that much in Ham, can you please expand more about what were you trying to say? I didn't understand what were you trying to tell me.

fysiks 08-07-2011 06:12

Re: If damaged teammate more then 100 or 50 HP, print a message
 
Quote:

Originally Posted by Diegorkable (Post 1527443)
@fysiks - at public client_connect g_LeftKills[id] is being set to 0, besides, there's no place in the code where the leftkills is being set (except 0) besides the "tk" public. And I'll make sure to treat all its values to floats.

You always have some sort of excuse for not debugging . . .

ConnorMcLeod 08-07-2011 06:15

Re: If damaged teammate more then 100 or 50 HP, print a message
 
Use client_damage csx forward, will make your life easier and you will get correct damage value (it is not the case with TakeDamage forward unless you hook it post and you retrieve dmg_take value)

Diegorkable 08-07-2011 06:21

Re: If damaged teammate more then 100 or 50 HP, print a message
 
I swear I debugged, fysiks, didn't help. and Connor, im really confused of your post, and you expand and explain?

Diegorkable 08-07-2011 07:21

Re: If damaged teammate more then 100 or 50 HP, print a message
 
So what you do, is suggesting me, to use public client_damage instead of the registerham? and that it'll return the correct value of damage?

Edit: is the value of damage in client_damage equals to float aswell?


All times are GMT -4. The time now is 03:28.

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