Raised This Month: $ Target: $400
 0% 

Solved Save/Get multiple different values in the same variable per player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zXCaptainXz
Member
Join Date: May 2017
Old 02-17-2022 , 18:59   Re: Save/Get multiple different values in the same variable per player
Reply With Quote #1

g_he_attacker
g_count_victim_zombie/g_count_victim_human

What is the point of these variables?


Code:
g_fDamage_Human[victim][attacker] >= g_hp_victim[victim]
You are comparing a float to an integer, IDK if that even works in AMXX.

Last edited by zXCaptainXz; 02-17-2022 at 19:32.
zXCaptainXz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-17-2022 , 22:27   Re: Save/Get multiple different values in the same variable per player
Reply With Quote #2

Here are some thoughts:

If the victim dies, I don't see why you shouldn't be setting all 4 variables to zero. Also, having if statements for both "variable" and "not variable" is unnecessary, simply use an else condition, it will be more efficient.
Code:
	if(zp_core_is_zombie(victim))
	{
		g_count_victim_human[victim] = 0;
		g_fDamage_Human[victim][attacker] = 0.0;
	}
	
	if(!zp_core_is_zombie(victim))
	{
		g_count_victim_zombie[victim] = 0;
		g_fDamage_Zombie[victim][attacker] = 0.0;
	}
I'm not sure if you just stripped a whole bunch of code out or not but you have a couple client_print() calls that reference an undefined variable 'id'.

Are you sure it's just an issue with calling client_print() so many times crazy fast? I feel like there have been issues trying to do this in other threads.

Try removing all the ZP craziness to see if your basic logic is done correctly as well as adding debug logging to see what the values of various variables are during execution. Making the code much simpler should make it easier to debug and determine what you might be doing wrong. The zombie vs human part makes things more complex and I've never played ZP so I'm not 100% how that is all done. Then, once you have that working correctly, start adding the ZP stuff back in.

Regarding seeing players that you didn't expect to see, realize that the entity index (1 through 32) are not unique to unique players. I.e. if a player leaves and someone else joins, they might get the same entity index. So, if you don't do proper connect/disconnect cleanup of the variables then you might see the wrong person show up.
__________________
fysiks is offline
sursista
Senior Member
Join Date: Jul 2010
Location: Spain
Old 02-18-2022 , 05:43   Re: Save/Get multiple different values in the same variable per player
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
Here are some thoughts:

If the victim dies, I don't see why you shouldn't be setting all 4 variables to zero. Also, having if statements for both "variable" and "not variable" is unnecessary, simply use an else condition, it will be more efficient.
Code:
	if(zp_core_is_zombie(victim))
	{
		g_count_victim_human[victim] = 0;
		g_fDamage_Human[victim][attacker] = 0.0;
	}
	
	if(!zp_core_is_zombie(victim))
	{
		g_count_victim_zombie[victim] = 0;
		g_fDamage_Zombie[victim][attacker] = 0.0;
	}
Making the code much simpler should make it easier to debug and determine what you might be doing wrong.
I will do a full debug of the plugin, it will take me some time
sursista is offline
Send a message via MSN to sursista Send a message via Skype™ to sursista
sursista
Senior Member
Join Date: Jul 2010
Location: Spain
Old 02-18-2022 , 05:36   Re: Save/Get multiple different values in the same variable per player
Reply With Quote #4

Quote:
Originally Posted by zXCaptainXz View Post
g_he_attacker
g_count_victim_zombie/g_count_victim_human

What is the point of these variables?


Code:
g_fDamage_Human[victim][attacker] >= g_hp_victim[victim]
You are comparing a float to an integer, IDK if that even works in AMXX.

g_count_victim_zombie/g_count_victim_human detects if the attacker has more than one assist, since when resetting the variables I only need to subtract the value to 1 for each dead victim (this way even if the variable is reset, he will still have more assists thanks to this variable)

g_he_attacker makes it so that if the attacker gets an assist and he kills the victim, all of his variables are reset, otherwise they will also be counted as assists (I could have also made a return for this)

Last edited by sursista; 02-18-2022 at 05:46. Reason: edit
sursista is offline
Send a message via MSN to sursista Send a message via Skype™ to sursista
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 11:43.


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