Hello,recently I am making some SQL stuffs,and ran into a situation.I want to use natives to link a "core" plugin and some branches,in the "core"plugin,I created some natives for the branches to use,in order to fetch data back from the MySQL server,or write some data into the MySQL server.Luckily,writting was done perfectly but I got trobules with fetching.
As i used SQL_TQuery,there must be a callback,but this callback are not in the process of the native,in other words,the native is not returning what the callback has fetched.
I don't know if I can use native on this situation,as I don't really want to combine both core and branches together,in order to minimize the plugin file size and let myself to check the errors more easily.
Here's the code
Code:
public __Native_getpoints(Handle:plugin,numParams)
{
new client = GetNativeCell(1);
required[client] = 0; //defined as new required[MAXPLAYERS+1]; at the header
if (!IsClientConnected(client) && !IsClientInGame(client))
return ThrowNativeError(SP_ERROR_NATIVE, "L4D STATS is not enabled");
if (IsClientBot(client))
return ThrowNativeError(SP_ERROR_NATIVE, "TARGET IS BOT");
decl String:SteamID[MAX_LINE_WIDTH];
GetClientAuthString(GetNativeCell(1), SteamID, sizeof(SteamID));
decl String:query[256];
Format(query, sizeof(query), "SELECT points FROM players WHERE steamid = '%s'",SteamID);
SQL_TQuery(db,__Native_callback_get, query, client);
}
public __Native_callback_get(Handle:owner, Handle:hndl, const String:error[], any:data)
{
new client = data;
if (!client)
return Plugin_Handled;
if (hndl == INVALID_HANDLE)
return Plugin_Handled;
while (SQL_FetchRow(hndl))
{
required[client] = SQL_FetchInt(hndl, 0);
}
return required[client];
}
I am not very experienced to scripting,this is actually my first time for writing my own SQL process,and please,help!
-FF