16.10.2015, 18:30
(
Last edited by Patrick; 24/10/2015 at 10:24 AM.
)
Hello, I'm wondering how you open such simple queries using this include, I've bumped into a little problem.
EDIT:
Temporary Fix, until the author replies and makes an update.
pawn Code:
SOLUTION: You'll only need this query when opening such simple tabes. (SELECT * FROM serverconfig)
ERROR: [SQLITE] - ERROR: (SL::OpenTable) No format has been entered. Format example: (pID)
pawn Code:
hook OnGameModeInit()
{
if(!SL::ExistsTable(CONFIG_TABLE))
{
new tmp_handle;
tmp_handle = SL::Open(SL::CREATE, CONFIG_TABLE);
SL::AddTableEntry(tmp_handle, COL_ATTSKIN, SL_TYPE_INT);
SL::AddTableEntry(tmp_handle, COL_DEFSKIN, SL_TYPE_INT);
SL::AddTableEntry(tmp_handle, COL_ATTSUBSKIN, SL_TYPE_INT);
SL::AddTableEntry(tmp_handle, COL_DEFSUBSKIN, SL_TYPE_INT);
SL::AddTableEntry(tmp_handle, COL_REFEREESKIN, SL_TYPE_INT);
SL::AddTableEntry(tmp_handle, COL_MAXPING, SL_TYPE_INT);
SL::AddTableEntry(tmp_handle, COL_MAXPACKET, SL_TYPE_FLOAT);
SL::Close(tmp_handle);
tmp_handle = SL::Open(SL::INSERT, CONFIG_TABLE);
SL::WriteInt(tmp_handle, COL_ATTSKIN, 170);
SL::WriteInt(tmp_handle, COL_DEFSKIN, 177);
SL::WriteInt(tmp_handle, COL_ATTSUBSKIN, 53);
SL::WriteInt(tmp_handle, COL_DEFSUBSKIN, 230);
SL::WriteInt(tmp_handle, COL_REFEREESKIN, 51);
SL::WriteInt(tmp_handle, COL_MAXPING, 300);
SL::WriteFloat(tmp_handle, COL_MAXPACKET, 1.0);
SL::Close(tmp_handle);
AddDebug("DATABASE", ""CONFIG_TABLE" has been successfully created.");
}
else
{
/*
SOLUTION: You'll only need this query when opening such simple tabes. (SELECT * FROM serverconfig)
ERROR: [SQLITE] - ERROR: (SL::OpenTable) No format has been entered. Format example: (pID)
new tmp_handle = SL::Open(SL::READ, CONFIG_TABLE);
SL::ReadInt(tmp_handle, COL_ATTSKIN, serverData[attackerSkin]);
SL::ReadInt(tmp_handle, COL_DEFSKIN, serverData[deffenderSkin]);
SL::ReadInt(tmp_handle, COL_ATTSUBSKIN, serverData[attackerSubSkin]);
SL::ReadInt(tmp_handle, COL_DEFSUBSKIN, serverData[deffenderSubSkin]);
SL::ReadInt(tmp_handle, COL_REFEREESKIN, serverData[refereeSkin]);
SL::ReadInt(tmp_handle, COL_MAXPING, serverData[maxping]);
SL::ReadFloat(tmp_handle, COL_MAXPACKET, serverData[maxpacket]);
SL::Close(tmp_handle);*/
AddDebug("DATABASE", ""CONFIG_TABLE" has successfully loaded.");
}
}
Temporary Fix, until the author replies and makes an update.
pawn Code:
stock SL::OpenTable_Read(const table[], const column[], columnID, DB:database = DB:1)
{
if(DB:database == DB:0)
{
SL_Error("(SL::OpenTable) No active connection.");
return SL_INVALID_HANDLE;
}
if(strlen(table) > SL_MAX_TABLE_NAME)
{
SL_Error("(SL::OpenTable) Invalid table length.");
return SL_INVALID_HANDLE;
}
/*if(column[0] == '\0')
{
SL_Error("(SL::OpenTable) No format has been entered. Format example: (pID)");
return SL_INVALID_HANDLE;
}*/
new
i = SL::GetFreeUpdatingSlot()
;
if(i == SL_INVALID_HANDLE)
{
return SL_INVALID_HANDLE;
}
SL::upd_type[i] = SL::READ;
SL::database[i] = DB:database;
if(column[0] == '\0' || !columnID)
{
format(SL::upd_form, sizeof(SL::upd_form), "SELECT * FROM `%s`", table);
SL::ReadCache[i] = db_query(DB:database, SL::upd_form);
}
else
{
format(SL::upd_form, sizeof(SL::upd_form), "SELECT * FROM `%s` WHERE `%s` = '%d' ", table, column, columnID);
SL::ReadCache[i] = db_query(DB:database, SL::upd_form);
}
SL::upd_datacount[i] = 0;
if((SL::ReadCache[i]))
{
SL::UsedHandle[i] = true;
return i;
}
return SL_INVALID_HANDLE;
}