Store Attacker damage in dinamic array for every victim
Hello,
I am trying to store a player's damage dealt to another player in an dinamic array. Down below I tried to find Attacker's name in array to get an index:
I found this after I added debug messages to code ( you can see down below ): The problem is when it search for attacker's victim name and it finds one in array, instead of creating a new entry with Attacker's name and the new victim's name, it creates an entry with first victim name from array. Code: PHP Code:
PHP Code:
|
Re: Store Attacker damage in dinamic array for every victim
use tries it will make your life much easiers than dynamic arrays for this kind purpose since you're seeking using strings.
also if you're using an array for a limited size such as max players you can make a 3d array it will be better. PHP Code:
|
Re: Store Attacker damage in dinamic array for every victim
I will try and tries way.
Quote:
|
Re: Store Attacker damage in dinamic array for every victim
I don't understand why the 3d array approach wouldn't work. You would always pass the victim, attacker, and damage amount, so you will have all data. Please better explain where your hiccup is so we can help with that.
Player id 3 attacks player id 5 with 20 dmg g_victim_stats[ 5 ][ 3 ][ DamageReceived ] = 20 g_victim_stats[ 3 ][ 5 ][ DamageGiven ] = 20 |
Re: Store Attacker damage in dinamic array for every victim
Why it won't work ?
What do you mean you need to know the victims id, what is the function are you using? Also it would be better if youve explained what are you trying to do. |
Re: Store Attacker damage in dinamic array for every victim
Does this work?
My understanding is that -1 is always returned. Code:
|
Re: Store Attacker damage in dinamic array for every victim
Again, I think the 3d array solution is fine. Why do you want the data stored in the array and then to find said data based on the player name that you search.
Please explain what you are trying to accomplish, I'm pretty sure you are overthinking it, or just thinking about it the wrong way. PM if you want. |
Re: Store Attacker damage in dinamic array for every victim
I will try later the 3D array too, thank you.
I need the Victim's ID, because this function will used in Round End Event, so I need to loop through player entities to get valid indexes. Quote:
Code:
|
Re: Store Attacker damage in dinamic array for every victim
Is this what you're trying to do?
PHP Code:
|
Re: Store Attacker damage in dinamic array for every victim
Quote:
So it will loop through all entries from "p" loop first, then will continue the "i" loop, isn't that? |
| All times are GMT -4. The time now is 02:30. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.