Veteran Member
|
12-10-2014
, 14:01
[MYSQL] Load/Save won't work properly
|
#1
|
Load/save seems to be working poorly and not saving all the data that is supposed to store.
Load
PHP Code:
public Load_MySql(id)
{
new szSteamId[32], szTemp[512]
get_user_authid(id, szSteamId, charsmax(szSteamId))
new Data[1]
Data[0] = id
//we will now select from the table `tutorial` where the steamid match
format( szTemp, charsmax( szTemp ),"SELECT `rating`, `kills`, `deaths` FROM `%s` WHERE `authid` = '%s'", SQL_TABLE, szSteamId )
SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
}
public register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
if(FailState == TQUERY_CONNECT_FAILED)
{
log_amx("Load - Could not connect to SQL database. [%d] %s", Errcode, Error)
}
else if(FailState == TQUERY_QUERY_FAILED)
{
log_amx("Load Query failed. [%d] %s", Errcode, Error)
}
new id
id = Data[0]
if(SQL_NumResults(Query) < 1)
{
//.if there are no results found
new szSteamId[32]
get_user_authid(id, szSteamId, charsmax(szSteamId)) // get user's steamid
// if its still pending we can't do anything with it
if (equal(szSteamId,"ID_PENDING"))
return PLUGIN_HANDLED
new szTemp[512]
// now we will insturt the values into our table.
format( szTemp, charsmax( szTemp ), "INSERT INTO %s ( `authid`, `nick`, `rating`, `kills`, `deaths`) VALUES( '%s', '%s', '%i', '%i', '%i' )", SQL_TABLE, szSteamId, g_szName[ id ],elo_rating[ id ],g_iKills[ id ],g_iDeaths[ id ] )
SQL_ThreadQuery( g_SqlTuple, "IgnoreHandle", szTemp )
}
else
{
elo_rating[ id ] = SQL_ReadResult( Query, 0 )
g_iKills[ id ] = SQL_ReadResult( Query, 1 )
g_iDeaths[ id ] = SQL_ReadResult( Query, 2 )
}
return PLUGIN_HANDLED
}
Save
PHP Code:
public Save_MySql(id)
{
new szSteamId[32], szTemp[512]
get_user_authid(id, szSteamId, charsmax(szSteamId))
// Here we will update the user hes information in the database where the steamid matches.
formatex( szTemp, charsmax( szTemp ),"UPDATE %s SET nick = '%s', rating = '%i', kills = '%i', deaths = '%i' WHERE authid = '%s'",SQL_TABLE, g_szName[ id ], elo_rating[ id ], g_iKills[ id ], g_iDeaths[ id ], szSteamId[ id ] )
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
}
public IgnoreHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
SQL_FreeHandle(Query)
return PLUGIN_HANDLED
}
__________________
ELO RATING SYSTEM - SQL [COMPLETE]
Quote:
Originally Posted by Liverwiz
DDDRRRRAAAAMMMMAAAAA!!!???
Put this shit on pause while i go get some popcorn!!
|
|
|