So here's my code:
PHP Code:
public Action:Command_Tip(client, args)
{
if(args < 2)
{
CPrintToChat(client, "{red}Arctek ★ System - ERROR: Usage: !tip <playername> <1-9>");
}
else if(args == 2)
{
new String:arg1[32], String:arg2[1], String:steamid[32];
GetCmdArg(1, arg1, sizeof(arg1));
GetCmdArg(2, arg2, sizeof(arg2));
GetClientAuthString(client, steamid, sizeof(steamid));
new target = FindTarget(client, arg1);
// Write DataPack
new Handle:pack = CreateDataPack();
WritePackCell(pack, client);
WritePackString(pack, steamid);
WritePackCell(pack, target);
// Debug
PrintToServer("Arctek ★ SQL: Writing of DataPack fired");
TipQuery(pack);
}
}
TipQuery(Handle:pack)
{
// Debug
PrintToServer("Arctek ★ SQL: TipQuery fired");
// Read DataPack
ResetPack(pack, false);
new String:packSteamID[32];
ReadPackString(pack, packSteamID, sizeof(packSteamID));
new String:query[128];
FormatEx(query, sizeof(query), "SELECT points FROM Users WHERE steamID2 = '%s'", packSteamID);
SQL_TQuery(g_hDB, tipquerycallback, query, pack);
}
public tipquerycallback(Handle:owner, Handle:hndl, const String:error[], any:pack)
{
// Debug
PrintToServer("Arctek ★ SQL: tipquerycallback fired");
ResetPack(pack, false);
new packClient = ReadPackCell(pack);
ResetPack(pack, false);
new tokensme[MAXPLAYERS + 1];
if (hndl == INVALID_HANDLE)
{
LogError("Arctek ★ SQL: - ERROR: %s", error);
return;
}
while(SQL_FetchRow(hndl))
{
tokensme[packClient] = SQL_FetchInt(hndl, 0);
if(tokensme[packClient] < 1)
{
CPrintToChat(packClient, "{red}Arctek ★ System - ERROR: You have do have enough VIP Tokens! (You have {blue}%d{red} VIP Tokens.)", tokensme[packClient]);
}
else if(tokensme[packClient] > 0)
{
TipSendQuery(pack);
}
}
}
TipSendQuery(Handle:pack)
{
ResetPack(pack, false);
new packClient = ReadPackCell(pack);
new String:packSteamID[32];
ReadPackString(pack, packSteamID, sizeof(packSteamID));
new packTarget = ReadPackCell(pack);
ResetPack(pack, false);
CPrintToChatAll("%d %s %d", packClient, packSteamID, packTarget);
}
Compiles fine, console says this when using the command:
Code:
L 09/14/2015 - 21:35:21: [SM] Native "ReadPackString" reported: DataPack operation is out of bounds.
L 09/14/2015 - 21:35:21: [SM] [0] Line 147, arctek/sql.sp::TipQuery()
L 09/14/2015 - 21:35:21: [SM] [1] Line 135, arctek/sql.sp::Command_Tip()
Line 147: ReadPackString(pack, packSteamID, sizeof(packSteamID));
Line 135: TipQuery(pack);
These 2 functions worked fine before i started calling "pack" in the TQuery call back and such. Am I calling it on multiple levels? dimensions?
Either way, im confused.
Any help is appreciated.
__________________