Edit (02/11/2015) - 06:11PM: Updated
I edited my version of this script, it compiles now really really fast and the whole San Andreas structure is loaded when the gamemode is started (takes 2 or 3 seconds to be fully loaded), so if you're going to use it, make sure that you'll place the read function on the top of your "OnGameModeInit" callback.
Example:
Code:
public OnGameModeInit()
{
Read_SA_MAP();//reads the array of all gta:sa objects
return 1;
}
File parser and structure (I changed the name of them but you can easily change it by yourself):
Code:
#define MAX_SA_OBJECTS 44764//updated
enum SA_MAP_INFO
{
SA_MAP_Model,
SA_MAP_LODModel,
SA_MAP_Model_Name[32],
Float:SA_MAP_X,
Float:SA_MAP_Y,
Float:SA_MAP_Z,
Float:SA_MAP_RX,
Float:SA_MAP_RY,
Float:SA_MAP_RZ
};
new SA_MAP_Object[MAX_SA_OBJECTS][SA_MAP_INFO];
stock Read_SA_MAP()
{
print("Parsing GTA:SA objects array.");
new index, line[256], File:file_ptr;
file_ptr = fopen("sanandreasarray.db", filemode:io_read);
if(!file_ptr) return print("Error, server could not find SanAndreasArray.db");
while(fread(file_ptr, line) > 0)
{
if(!sscanf(line, "p<,>dds[32]ffffff",
SA_MAP_Object[index][SA_MAP_Model], SA_MAP_Object[index][SA_MAP_LODModel], SA_MAP_Object[index][SA_MAP_Model_Name],
SA_MAP_Object[index][SA_MAP_X], SA_MAP_Object[index][SA_MAP_Y], SA_MAP_Object[index][SA_MAP_Z],
SA_MAP_Object[index][SA_MAP_RX], SA_MAP_Object[index][SA_MAP_RY], SA_MAP_Object[index][SA_MAP_RZ]))
{
index++;
}
}
fclose(file_ptr);
printf("Server sucessfully parsed %d GTA:SA objects data.", index);
return 1;
}
And last but not least, place the array database file on your scriptfiles folder:
Database download link (updated)
This process will save you too much time for compiling your script, you won't have to wait so much time to use this array anymore, all credits goes to Pottus, have fun