Raised This Month: $51 Target: $400
 12% 

Increase cvar by a code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-08-2021 , 13:51   Increase cvar by a code
Reply With Quote #1

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?
HowToRuski is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-08-2021 , 19:58   Re: Increase cvar by a code
Reply With Quote #2

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
__________________

Last edited by Napoleon_be; 04-08-2021 at 20:04.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-09-2021 , 03:08   Re: Increase cvar by a code
Reply With Quote #3

Quote:
Originally Posted by Napoleon_be View Post
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...
HowToRuski is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-09-2021 , 11:39   Re: Increase cvar by a code
Reply With Quote #4

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.
__________________

Last edited by Napoleon_be; 04-09-2021 at 11:40.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-10-2021 , 01:41   Re: Increase cvar by a code
Reply With Quote #5

Quote:
Originally Posted by Napoleon_be View Post
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

Last edited by HowToRuski; 04-10-2021 at 01:43.
HowToRuski is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 04-10-2021 , 03:06   Re: Increase cvar by a code
Reply With Quote #6

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));         // ...     }
__________________
Black Rose is offline
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-10-2021 , 05:20   Re: Increase cvar by a code
Reply With Quote #7

Quote:
Originally Posted by Black Rose View Post
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
HowToRuski 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 18:47.


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