Save/Get multiple different values in the same variable per player
Hello, I'm doing an assist system for the ZM mod, the problem occurs when several players get an assist from the same zombie. What happens is that the variable:
PHP Code:
PHP Code:
|
Re: Save/Get multiple different values in the same variable per player
I don't see a problem there.
Other than that, show the full code so we can see how you're using it. |
Re: Save/Get multiple different values in the same variable per player
|
Re: Save/Get multiple different values in the same variable per player
Nevermind, I didn't notice he's looping through all indexes instead of only connected players.
|
Re: Save/Get multiple different values in the same variable per player
Quote:
PHP Code:
|
Re: Save/Get multiple different values in the same variable per player
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] |
Re: Save/Get multiple different values in the same variable per player
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))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. |
Re: Save/Get multiple different values in the same variable per player
Quote:
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) |
Re: Save/Get multiple different values in the same variable per player
Quote:
|
Re: Save/Get multiple different values in the same variable per player
1 Attachment(s)
There are many things I don't understand in your code, most importantly why are you giving assists in both Ham_TakeDamage and Ham_Killed forwards. You should either do it in one or the other, either you get an assist immediately after dealing 1/3 the original health of the player or you get an assist after the player gets killed by someone other than you and you dealt more than 1/3 the original health of the player. The latter case makes more sense anyway, assists should be given when the victim dies. I coded a plugin which probably does what you want with way less clutter, if you want you can try it and see if it solves your problem.
|
| All times are GMT -4. The time now is 11:43. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.