AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Increase cvar by a code (https://forums.alliedmods.net/showthread.php?t=331812)

HowToRuski 04-08-2021 13:51

Increase cvar by a code
 
Hello i wanted to ask if is this a true way to increase for this point humans dealt damage reward to zombie??
PHP Code:

set_pcvar_num(cvar_ammodamage_humanget_pcvar_num(cvar_ammodamage_human) +5

Seems not working for me... Anyone who could help?

Napoleon_be 04-08-2021 19:58

Re: Increase cvar by a code
 
depends on when the cvar gets updated, if it gets updated every shot fired or every single damage taken, then yes it should work, but that's not the proper way. You should be handling that stuff in TraceAttack & TakeDamage by adjusting the damage using a new float variable

https://www.amxmodx.org/api/ham_const

HowToRuski 04-09-2021 03:08

Re: Increase cvar by a code
 
Quote:

Originally Posted by Napoleon_be (Post 2743472)
depends on when the cvar gets updated, if it gets updated every shot fired or every single damage taken, then yes it should work, but that's not the proper way. You should be handling that stuff in TraceAttack & TakeDamage by adjusting the damage using a new float variable

https://www.amxmodx.org/api/ham_const

Actually its meant to be updated after i kill a zombie... But seems not workimg for me...

Napoleon_be 04-09-2021 11:39

Re: Increase cvar by a code
 
You'll need to update the damage everytime u kill a zombie then. use DeathMsg event or Ham_Killed. Use a variable to store the bonus damage in, and increase it using get_pcvar_num(). Hook TakeDamage & TraceAttack.

https://forums.alliedmods.net/showthread.php?t=80208 : This is a great example of how you could do it.

HowToRuski 04-10-2021 01:41

Re: Increase cvar by a code
 
Quote:

Originally Posted by Napoleon_be (Post 2743568)
You'll need to update the damage everytime u kill a zombie then. use DeathMsg event or Ham_Killed. Use a variable to store the bonus damage in, and increase it using get_pcvar_num(). Hook TakeDamage & TraceAttack.

https://forums.alliedmods.net/showthread.php?t=80208 : This is a great example of how you could do it.

Actually i already have that in my forwardPlayerKilled...

Heres my code:
PHP Code:

// Zombie killed human, add up the extra frags for kill
    
if (g_zombie[attacker] && get_pcvar_num(cvar_fragsinfect) > 1)
        
set_pcvar_num(cvar_ammodamage_humanget_pcvar_num(cvar_ammodamage_human) +5)
        
UpdateFrags(attackervictimget_pcvar_num(cvar_fragsinfect) - 100


Black Rose 04-10-2021 03:06

Re: Increase cvar by a code
 
So debug it...
Code:
// Zombie killed human, add up the extra frags for kill     server_print("g_zombie[%d]: %d, pcvar(cvar_fragsinfect): %d", attacker, g_zombie[attacker], get_pcvar_num(cvar_fragsinfect));     if (g_zombie[attacker] && get_pcvar_num(cvar_fragsinfect) > 1)     {         server_print("Pre increase: %d", get_pcvar_num(cvar_ammodamage_human));         set_pcvar_num(cvar_ammodamage_human, get_pcvar_num(cvar_ammodamage_human) +5)         server_print("Post increase: %d", get_pcvar_num(cvar_ammodamage_human));         // ...     }

HowToRuski 04-10-2021 05:20

Re: Increase cvar by a code
 
Quote:

Originally Posted by Black Rose (Post 2743636)
So debug it...
Code:
// Zombie killed human, add up the extra frags for kill     server_print("g_zombie[%d]: %d, pcvar(cvar_fragsinfect): %d", attacker, g_zombie[attacker], get_pcvar_num(cvar_fragsinfect));     if (g_zombie[attacker] && get_pcvar_num(cvar_fragsinfect) > 1)     {         server_print("Pre increase: %d", get_pcvar_num(cvar_ammodamage_human));         set_pcvar_num(cvar_ammodamage_human, get_pcvar_num(cvar_ammodamage_human) +5)         server_print("Post increase: %d", get_pcvar_num(cvar_ammodamage_human));         // ...     }

Worked out for me. Ty


All times are GMT -4. The time now is 11:00.

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