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

Best way to store damage done to an entity by each player?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BeasT
Senior Member
Join Date: Apr 2007
Location: Lithuania
Old 11-22-2016 , 05:54   Best way to store damage done to an entity by each player?
Reply With Quote #1

I want to somehow temporary store the damage done by each player to an entity, and after the entity gets destroyed, pay out $ to the players by how much damage they have done. What would be the best way? Obviously creating an array like the one below is bad.
Code:
g_Damage[MAX_PLAYERS+1][MAX_ENTITIES+1]
BeasT is offline
Send a message via Skype™ to BeasT
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 11-22-2016 , 06:32   Re: Best way to store damage done to an entity by each player?
Reply With Quote #2

Better say what are you tryng to do, not in the code, as a plugin.
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 11-22-2016 , 07:18   Re: Best way to store damage done to an entity by each player?
Reply With Quote #3

Quote:
Originally Posted by Craxor View Post
Better say what are you tryng to do, not in the code, as a plugin.
Exactly what it says in the tin.

Store damage done by each player to an entity, and then when the entity is killed do something with each player damage.

I'm interested in this as well, I was planning doing an array like OP suggested but it doesn't seem optimal.
__________________
gabuch2 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 11-22-2016 , 07:28   Re: Best way to store damage done to an entity by each player?
Reply With Quote #4

try csx module with client_damage or check hamsandwitch with Ham_TakeDamage i guess
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
BeasT
Senior Member
Join Date: Apr 2007
Location: Lithuania
Old 11-22-2016 , 07:55   Re: Best way to store damage done to an entity by each player?
Reply With Quote #5

Quote:
Originally Posted by ^SmileY View Post
try csx module with client_damage or check hamsandwitch with Ham_TakeDamage i guess
I need to store the total damage done by a player till the entity dies, so how does that help me?..

Last edited by BeasT; 11-22-2016 at 07:55.
BeasT is offline
Send a message via Skype™ to BeasT
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-22-2016 , 08:42   Re: Best way to store damage done to an entity by each player?
Reply With Quote #6

I would create a cellarray (CreateArray(), make it 33 long) and store it in one of entity's pev_[i|f|e]user[1-4] entity variables.

Last edited by klippy; 11-22-2016 at 08:42.
klippy is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 11-22-2016 , 09:42   Re: Best way to store damage done to an entity by each player?
Reply With Quote #7

Multiarray should be efficient and convenient to use. Yes, you have memory overhead, but it is not so much to worry about that.
There is only one problem with multiarray - zeroing when entity is removed, but you can hook this via FM_FreeEntPrivateData.
__________________

Last edited by PRoSToTeM@; 11-24-2016 at 06:28.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
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:34.


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