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

Saving data in multidimensional array/object (CSGO)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
McSnaggit
Junior Member
Join Date: Feb 2019
Old 02-12-2019 , 10:31   Saving data in multidimensional array/object (CSGO)
Reply With Quote #1

Hi,

I'm new here and have been searching for a good solution for my CSGO plugin for a while now and haven't found it yet. I have some experience with javascript and can understand a bit of the SourcePawn language with help of other plugins. However it might be that the solution for my problem is closer than I think.

Background information
So I'm working on a plugin that logs Armsrace stats (yes, that's what we play on our server ). I want to log the end score and send it to my MySQL database. This is not the thing I'm worried about.

The difficult thing will be the logging of all the events. I want to make sure that I'm not lagging the server with SQL queries and I first want to collect all the events of a match before sending it to the database. Events like deaths, disconnects etc. Later I can then create a nice interface where we can view the amount of knifes on each other, most killed by, who killed most bots etc.

So what I want is logging events to an array and then at the end of the match iterate over it and sending it to my database. I have read about adt_arrays and static arrays. And because I don't know the end size of my array of events I should use the adt_array. However, I don't know how to combine it with an enum (which I use kind of as an object).

Current code
Example of my current code. Global scope:
PHP Code:
enum GameEvent
{
    
String:Event_Type[32],
    
String:Involved_Player_Name[64],
    
String:Involved_Player_Id[64],
    
String:Weapon[64],
    
Headshot,
    
Penetrated,
    
String:Victim_Player_Name[64],
    
String:Victim_Player_Id[64]
}

new 
g_Events[1024][ GameEvent ];

int LastEventIndex 0
Code in the death event (all the variables are working):

PHP Code:
strcopy(g_EventsLastEventIndex ][ Event_Type ], 32"death");
strcopy(g_EventsLastEventIndex ][ Involved_Player_Name ], 64killerName);
strcopy(g_EventsLastEventIndex ][ Involved_Player_Id ], 64InvolvedPlayerSteamId);
strcopy(g_EventsLastEventIndex ][ Weapon], 64weapon);
g_EventsLastEventIndex ][ Headshot] = headshot;
g_EventsLastEventIndex ][ Penetrated] = penetrated;
strcopy(g_EventsLastEventIndex ][ Victim_Player_Name ], 64victimName);
strcopy(g_EventsLastEventIndex ][ Victim_Player_Id ], 64VictimPlayerSteamId);

LastEventIndex LastEventIndex 1
The problem
My problem is that I don't know if this is the correct way of doing the thing I want. Maybe it's too resource intensive or maybe it's error-sensitive. Also when firing multiple death events at the same time, my index may be the same for 2 events, thus overwriting a part of my array. That's why I'd rather use an adt_array so I can store a new value at the end of the array instead of pre-defining it, and then "hacking" into it. I just want to make sure I gather the correct data and be efficient about it.

Do you guys know if this should be done differently. Please let me know if the problem is still not clear.

Last edited by McSnaggit; 02-12-2019 at 10:32.
McSnaggit is offline
 



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 12:04.


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