SA-MP Forums Archive
How should I declare array for this - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How should I declare array for this (/showthread.php?tid=636291)



How should I declare array for this - Riwerry - 24.06.2017

Hey guys, right now I wonder, because I would like to declare array, which would fit my needs.

I'm currently using this:
PHP код:
enum E_MDC
{
    
//stuff
    
E_MDC_RECORD_ENTRY_ID[MAX_RECORDS],
    
E_MDC_RECORD_ISSUER[MAX_RECORDS][MAX_PLAYER_NAME 1]
}
static 
MDC_g_sPlayer[MAX_PLAYERS][E_MDC]; 
So yeah, for each specific record I want to save it's issuer name. But I don't know how I will do that.


Re: How should I declare array for this - jlalt - 24.06.2017

MDC_g_sPlayer[playerid][E_MDC_RECORD_ENTRY_ID][0] = 10;
MDC_g_sPlayer[playerid][E_MDC_RECORD_ISSUER][0] = "Hi";


Re: How should I declare array for this - Abagail - 24.06.2017

This type of system is much better done with the MySQL plugin, where you can create tables, use auto generating IDs and easily look up, change, remove and add data. The only difference is that you're querying the data, which is relatively quick if you're using good optimization.


Re: How should I declare array for this - Riwerry - 24.06.2017

Yeah, that's the method which I will use, if I don't find anything. Anyways, it would be fastest if I could access data from memory instead of firing select query.


Re: How should I declare array for this - Abagail - 24.06.2017

Quote:
Originally Posted by Riwerry
Посмотреть сообщение
Yeah, that's the method which I will use, if I don't find anything. Anyways, it would be fastest if I could access data from memory instead of firing select query.
The MySQL plugin is widely used by SA-MP servers and is optimized for performance, speed shouldn't be an issue if you're using optimized queries along with an optimized database. On top of that, the plugin provides threaded queries which allows queries to go through a different thread apart from the server itself (which eliminates the server having to wait between calls). It also allows you to store a cache of the queries results for further use outside of the returned callback.


Re: How should I declare array for this - Riwerry - 25.06.2017

I'm interested that if I store cache and some of the values in database get updated, and I use proviously stored cache again, will it load new values also, or it'll keep it's provious database state?