New Member
|
02-19-2020
, 15:40
SQLite not updating tables
|
#1
|
Howdy y'all.
Pretty simple problem, really. Yesterday these same lines were working fine and updating. Last night I upgraded my server from ubuntu 18.04 to ubuntu 19.(whatever). As of today, the UPDATE function no longer works in this plugin.
PHP Code:
Format(buff,sizeof(buff),"UPDATE players SET character='%s' WHERE steamid = '%s'","Bill",menuids)
SQL_TQuery(db,SQLErrorCheckCallback,buff)
public SQLErrorCheckCallback(Handle:owner, Handle:hndl, const String:error[], client)
{
if(!StrEqual("", error))
{
PrintToServer("SQL Error: %s", error);
}
}
While this doesn't work, I know for a fact that these lines do:
PHP Code:
public InitializeDB()
{
new String:Query1[255];
new String:Query2[255];
new String:Query3[255];
Format(Query1, sizeof(Query1), "CREATE TABLE IF NOT EXISTS players (steamid TEXT UNIQUE, name TEXT, character TEXT, ellis INT);");
Format(Query2, sizeof(Query2), "CREATE TABLE IF NOT EXISTS loadout (steamid TEXT UNIQUE, primaryweapon TEXT, secondaryweapon TEXT, throwable TEXT, health TEXT, boost TEXT, laser TEXT, FOREIGN KEY(steamID) REFERENCES players(steamID) ON UPDATE SET DEFAULT, PRIMARY KEY(steamID));");
Format(Query3, sizeof(Query3), "CREATE TABLE IF NOT EXISTS infected (steamid TEXT UNIQUE, infected1 TEXT, infected2 TEXT, infected3 TEXT, FOREIGN KEY(steamID) REFERENCES players(steamID) ON UPDATE SET DEFAULT, PRIMARY KEY(steamID));");
new String:error[255];
//yes I know this next line is outdated but it works
db = SQL_ConnectEx(SQL_GetDriver("sqlite"), "", "", "", "sourcemod-local", error, sizeof(error), true, 0);
if(db == INVALID_HANDLE)
{
SetFailState(error);
}
SQL_LockDatabase(db);
SQL_FastQuery(db,Query1);
SQL_FastQuery(db,Query2);
SQL_FastQuery(db,Query3);
SQL_UnlockDatabase(db);
}
public initialAddToDatabase(client)
{
new String:name[40];
new String:sanitizedName[40]
GetClientName(client, name, sizeof(name));
SQL_EscapeString(db,name,sanitizedName,sizeof(name))
Format(buff, sizeof(buff), "INSERT INTO players VALUES ('%s','%s','%s','%i')",steamId,sanitizedName,"bill",1);
SQL_TQuery(db, SQLErrorCheckCallback, buff);
//adding default values to the loadout table
Format(buff, sizeof(buff), "INSERT INTO loadout VALUES ('%s','%s','%s','%s','%s','%s','%s')",steamId,"rifle_ak47","katana","vomitjar","first_aid_kit","adrenaline","on");
SQL_TQuery(db, SQLErrorCheckCallback, buff);
getEquipment(client)
//adding default values to the infected table
Format(buff, sizeof(buff), "INSERT INTO infected VALUES ('%s','%i','%i','%i')",steamId,1,2,3);
SQL_TQuery(db, SQLErrorCheckCallback, buff);
}
What did I do wrong? Is there any package I need to reinstall after upgrading?
EDIT:
I'm a dumbass. I put a query inside of OnPlayerRunCmd. Couldn't write to anything. fixed it
Last edited by Toxic360; 02-24-2020 at 16:42.
Reason: Fixed it
|
|