AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ham_takedamage prob (https://forums.alliedmods.net/showthread.php?t=167741)

r0ck 09-19-2011 12:25

ham_takedamage prob
 
i'm using

PHP Code:

#define DMG_GRENADE            (1 << 24)

RegisterHam(Ham_TakeDamage"player""ham_damage")

public 
ham_damage(victimentattackerFloat:damagebits)
{
    if(!
is_user_connected(attacker) || victim == attacker)
        return 
HAM_IGNORED
        
    
if(cs_get_user_team(attacker) == CS_TEAM_T && cs_get_user_team(victim) == CS_TEAM_T && bits DMG_GRENADE)
    {
        
SetHamParamFloat(4damage 2)
        return 
HAM_OVERRIDE
    
}


But the problem is that when t's throw grenade on t's it sets half the damage(thats what i want) but if t's throw grenade of cts then too its half damage :( i want that if attacker is t and victim is t then only grenade damage half

thanks

a7811311622 09-19-2011 12:59

Re: ham_takedamage prob
 
Try to delete "return HAM_OVERRIDE".

Hunter-Digital 09-19-2011 17:09

Re: ham_takedamage prob
 
I don't think you're checking for the right damagebit, try DMG_HEGRENADE (define it as (1<<24) ) or DMG_BLAST.

EDIT: wow I didn't see it beeing defined =) I thoght DMG_GRENADE already exists tough.

Arkshine 09-19-2011 17:41

Re: ham_takedamage prob
 
The bit is right, and he uses already DMG_GRENADE.

I don't find problems in your code except HAM_OVERRIDE is useless and should be removed. I don't see how you can have this problem with such check.

Bugsy 09-19-2011 18:05

Re: ham_takedamage prob
 
He is checking the correct damage bit. Try debugging this yourself r0ck. Do some server/client_prints of the values you are checking. You will eventually find when something is not what you thought then you know what needs to be fixed.

Edit: I'll click refresh before posting next time.

Hunter-Digital 09-19-2011 18:28

Re: ham_takedamage prob
 
Yes, so blind of me xD

Anyway, I tested the code and it seems to work just fine, I naded some of my podbot teammates while T and the message I added in the condition triggered.

And you should rearange conditions so it doesn't call if not required:
PHP Code:

public ham_damage(victimentattackerFloat:damagebits)
{
    if(
bits DMG_GRENADE && victim != attacker && is_user_connected(attacker) && cs_get_user_team(attacker) == CS_TEAM_T && cs_get_user_team(victim) == CS_TEAM_T)
        
SetHamParamFloat(4damage 2)


Also, you only want it for T's and not CT's aswell ?


All times are GMT -4. The time now is 19:35.

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