Find all mysql lines (query, mysql_* and cache_*).
Or search for all mysql instructions: SELECT, UPDATE, DELETE, ...
Then you should be able to figure out which tables you need and which fields you need, and the datatype as well.
Example from my script:
pawn Код:
#define table_speedcams "speedcameras"
// Send a query to load all speedcameras from MySQL
format(Query, sizeof(Query), "SELECT * FROM %s", table_speedcams);
result = mysql_query(SQL_db, Query, true);
// Print some debug info to the server console
printf("*** Loading speed-cameras from MySQL using \"%s\"", Query);
CamerasLoad();
cache_delete(result, SQL_db);
// This function is called to load the speedcameras
CamerasLoad()
{
// Setup local variables
new Rows, CamID, CameraName[50], MaxSpeed, Float:x, Float:y, Float:z, Float:rot, CountSuccess, CountFailed, Query[128];
// Get the amount of rows (cameras)
Rows = cache_get_row_count(SQL_db);
// If there are any rows (cameras) loaded, load data and create them
if (Rows >= 1)
{
// Loop through all rows
for (new Row; Row < Rows; Row++)
{
// Load the data
CamID = cache_get_field_content_int(Row, "ID", SQL_db);
cache_get_field_content(Row, "Name", CameraName, SQL_db, sizeof(CameraName));
MaxSpeed = cache_get_field_content_int(Row, "CamSpeed", SQL_db);
x = cache_get_field_content_float(Row, "X", SQL_db);
y = cache_get_field_content_float(Row, "Y", SQL_db);
z = cache_get_field_content_float(Row, "Z", SQL_db);
rot = cache_get_field_content_float(Row, "Angle", SQL_db);
// Check if the CamID is invalid (out of range)
if ((CamID < 0) || (CamID >= MAX_CAMERAS))
{
// Count the amount of failed cameras (invalid CamID's)
CountFailed++;
printf("*** ERROR: Invalid CamID found in table %s: %i (entry deleted)", table_speedcams, CamID);
mysql_format(SQL_db, Query, sizeof(Query), "DELETE FROM %s WHERE ID = '%i'", table_speedcams, CamID);
mysql_tquery(SQL_db, Query, "", "");
// Continue with the next speedcamera from the MySQL query
continue;
}
// Check if the CamSpeed is invalid (0 or lower)
if (MaxSpeed <= 0)
{
// Count the amount of failed cameras (invalid MaxSpeed)
CountFailed++;
printf("*** ERROR: Invalid CamSpeed found in table %s: CamID %i, MaxSpeed %i (entry deleted)", table_speedcams, CamID, MaxSpeed);
mysql_format(SQL_db, Query, sizeof(Query), "DELETE FROM %s WHERE ID = '%i'", table_speedcams, CamID);
mysql_tquery(SQL_db, Query, "", "");
// Continue with the next speedcamera from the MySQL query
continue;
}
// Create the camera at the given CamID (there should be no duplicate cameras with the same ID as the table-structure doesn't allow it, ID = primary key)
SetupSpeedCamera(x, y, z, rot, MaxSpeed, CameraName, CamID);
// Count the succesfully created cameras
CountSuccess++;
}
}
// Print the amount of speedcams loaded for debugging
printf("*** Speed-cameras loaded: %i (successful: %i, failed: %i)", Rows, CountSuccess, CountFailed);
return 1;
}
As you can see, the table's name is "speedcameras".
It holds these columns:
- ID (integer), non auto-increment, because I need to set the ID myself to avoid array-index-out-of-bounds errors as the ID is the same as the index of my array (this would be more clear when looking at my CreateCamera function), and it also primary ID as there may be no duplicate ID's in the table
- Name (varchar, size 50)
- CamSpeed (integer)
- X (float)
- Y (float)
- Z (float)
- Angle (float)
You should be able to do the same.
Fortunately, my own scripts created the tables automatically when they don't exist.
This makes it easy to setup my server-scripts when it's available for download.