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_Events[ LastEventIndex ][ Event_Type ], 32, "death");
strcopy(g_Events[ LastEventIndex ][ Involved_Player_Name ], 64, killerName);
strcopy(g_Events[ LastEventIndex ][ Involved_Player_Id ], 64, InvolvedPlayerSteamId);
strcopy(g_Events[ LastEventIndex ][ Weapon], 64, weapon);
g_Events[ LastEventIndex ][ Headshot] = headshot;
g_Events[ LastEventIndex ][ Penetrated] = penetrated;
strcopy(g_Events[ LastEventIndex ][ Victim_Player_Name ], 64, victimName);
strcopy(g_Events[ LastEventIndex ][ Victim_Player_Id ], 64, VictimPlayerSteamId);
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.