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
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 #1

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 #2

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