12.12.2014, 14:25
Well, I am back after a long break and learning some other programming languages.
I've decided to continue PAWN because it's really fun, so.. I've forgotten some stuff.
I've been told how to do this like alot of time ago but I forgot it, I attempted to re-do it just in another scenario and nothing worked, same problem I encountered in the past.
Here's the code, thanks for anyone assisting.
I am 99% sure I am doing most of this wrong.
I've decided to continue PAWN because it's really fun, so.. I've forgotten some stuff.
I've been told how to do this like alot of time ago but I forgot it, I attempted to re-do it just in another scenario and nothing worked, same problem I encountered in the past.
Here's the code, thanks for anyone assisting.
pawn Код:
public OnFilterScriptInit()
{
mysql_log(LOG_ALL);
print("\n--------------------------------------");
print(" ************************************");
print("--------------------------------------\n");
dbconnect(SQL_DB);
return 1;
}
forward dbconnect(db);
public dbconnect(db) {
if(db == SQL_DB) {
dbHandle = mysql_connect(MySQL_HOST, MySQL_USER, MySQL_DATABASE, MySQL_PASSWORD);
if(mysql_errno() != 0) {
print("Failed connection to database -- Shutting down.");
SendRconCommand("exit");
}
else
{
print("Successful connection to database -- Continue ~~~");
}
LoadDSquery();
}
}
stock LoadDSquery() {
mysql_tquery(dbHandle, "SELECT * FROM `dealerships`", "LoadDEALERSHIPS");
return 1;
}
forward loadDEALERSHIPS();
public loadDEALERSHIPS() {
for(new i = 0 ; i < cache_num_rows(dbHandle) ; i++) {
DS[i][DsID] = cache_get_field_content_int(i, "DsID", dbHandle);
DS[i][DsLocX] = cache_get_field_content_float(i, "DsLocX", dbHandle);
DS[i][DsLocY] = cache_get_field_content_float(i, "DsLocY", dbHandle);
DS[i][DsLocZ] = cache_get_field_content_float(i, "DsLocZ", dbHandle);
DS[i][DsIcon] = cache_get_field_content_int(i, "DsIcon", dbHandle);
DS[i][DsSpawned] = cache_get_field_content_int(i, "DsSpawned", dbHandle);
DsPickups = CreatePickup(1239, 23, DS[i][DsLocX], DS[i][DsLocY], DS[i][DsLocZ], -1);
DS[i][DsSpawned] = 1;
}
printf("Loaded %d DEALERSHIPS", cache_num_rows(dbHandle));
return 1;
}
I am 99% sure I am doing most of this wrong.