View Single Post
Author Message
DJ Data
SourceMod Donor
Join Date: Dec 2012
Location: Switzerland
Old 09-14-2015 , 15:41   DataPacks & SQL_TQuery
Reply With Quote #1

So here's my code:
PHP Code:
public Action:Command_Tip(clientargs)
{
    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(1arg1sizeof(arg1));
        
GetCmdArg(2arg2sizeof(arg2));
        
GetClientAuthString(clientsteamidsizeof(steamid));
        new 
target FindTarget(clientarg1);
        
        
// Write DataPack
        
new Handle:pack CreateDataPack();
        
WritePackCell(packclient);
        
WritePackString(packsteamid);
        
WritePackCell(packtarget);
        
        
// Debug
        
PrintToServer("Arctek ★ SQL: Writing of DataPack fired");
        
        
TipQuery(pack);
    }
}

TipQuery(Handle:pack)
{
    
// Debug
    
PrintToServer("Arctek ★ SQL: TipQuery fired");
    
    
// Read DataPack
    
ResetPack(packfalse);
    new 
String:packSteamID[32];
    
ReadPackString(packpackSteamIDsizeof(packSteamID));
    
    new 
String:query[128];
    
FormatEx(querysizeof(query), "SELECT points FROM Users WHERE steamID2 = '%s'"packSteamID);

    
SQL_TQuery(g_hDBtipquerycallbackquerypack);
}

public 
tipquerycallback(Handle:ownerHandle:hndl, const String:error[], any:pack)
{
    
// Debug
    
PrintToServer("Arctek ★ SQL: tipquerycallback fired");
    
    
ResetPack(packfalse);
    new 
packClient ReadPackCell(pack);
    
ResetPack(packfalse);
    
    new 
tokensme[MAXPLAYERS 1];
    
    if (
hndl == INVALID_HANDLE)
    {
        
LogError("Arctek ★ SQL: - ERROR: %s"error);
        return;
    }
    
    while(
SQL_FetchRow(hndl))
    {
        
tokensme[packClient] = SQL_FetchInt(hndl0);
        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(packfalse);
    new 
packClient ReadPackCell(pack);
    new 
String:packSteamID[32];
    
ReadPackString(packpackSteamIDsizeof(packSteamID));
    new 
packTarget ReadPackCell(pack);
    
ResetPack(packfalse);
    
    
CPrintToChatAll("%d %s %d"packClientpackSteamIDpackTarget);

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.
__________________
SourcePawn Coding Level: Novice
DJ Data is offline