SA-MP Forums Archive
How do I return something from the callback of the pquery method? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How do I return something from the callback of the pquery method? (/showthread.php?tid=643208)



How do I return something from the callback of the pquery method? - EtayJ - 15.10.2017

I have this:
PHP код:
forward CheckIfAccountExists(accountName[128]);
public 
CheckIfAccountExists(accountName[128])
{
    new 
query[128];
    
mysql_format(dbquerysizeof(query), "SELECT * FROM logindata WHERE uName = '%e';"accountName);
    
mysql_pquery(dbquery"OnLoginDataLoaded");
}
forward OnLoginDataLoaded();
public 
OnLoginDataLoaded()
{
    new 
rows cache_num_rows();
    if(
rows == 1)
        return 
1;
    return 
0;

and I wanna do something like this:
PHP код:
COMMAND:checkplayerexists(playeridparams[])
{
    new 
playerName[128]; //The player in question
    
if(sscanf(params"s"playerName)) SendClientMessage(playeridCOLOR_WHITE"Usage: /checkplayerexists <name>");
    else
    {
        if(
CheckIfAccountExists(playerName))
        {
            new 
msg[128], name[128];
            
format(msgsizeof(msg), "Player %s exists in the database"playerName);
            
SendClientMessage(playeridCOLOR_GREENmsg);
            
GetPlayerName(playeridnamesizeof(name));
            
format(msgsizeof(msg), "Admin %s has just checked if the player %s exists in the database and he does."nameplayerName);
            print(
msg);
        }
        else
        {
            new 
msg[128], name[128];
            
format(msgsizeof(msg), "Player %s doesn't exist in the database"playerName);
            
SendClientMessage(playeridCOLOR_REDmsg);
            
GetPlayerName(playeridnamesizeof(name));
            
format(msgsizeof(msg), "Admin %s has just checked if the player %s exists in the database and he doesn't."nameplayerName);
            print(
msg);
        }
    }
    return 
1;

But I am really don't know how to do that because I am only able to access the row count in the callback and not after sending the query in the first method


Re: How do I return something from the callback of the pquery method? - Kyle - 15.10.2017

Quote:
Originally Posted by EtayJ
Посмотреть сообщение
I have this:
PHP код:
forward CheckIfAccountExists(accountName[128]);
public 
CheckIfAccountExists(accountName[128])
{
    new 
query[128];
    
mysql_format(dbquerysizeof(query), "SELECT * FROM logindata WHERE uName = '%e';"accountName);
    
mysql_pquery(dbquery"OnLoginDataLoaded");
}
forward OnLoginDataLoaded();
public 
OnLoginDataLoaded()
{
    new 
rows cache_num_rows();
    if(
rows == 1)
        return 
1;
    return 
0;

and I wanna do something like this:
PHP код:
COMMAND:checkplayerexists(playeridparams[])
{
    new 
playerName[128]; //The player in question
    
if(sscanf(params"s"playerName)) SendClientMessage(playeridCOLOR_WHITE"Usage: /checkplayerexists <name>");
    else
    {
        if(
CheckIfAccountExists(playerName))
        {
            new 
msg[128], name[128];
            
format(msgsizeof(msg), "Player %s exists in the database"playerName);
            
SendClientMessage(playeridCOLOR_GREENmsg);
            
GetPlayerName(playeridnamesizeof(name));
            
format(msgsizeof(msg), "Admin %s has just checked if the player %s exists in the database and he does."nameplayerName);
            print(
msg);
        }
        else
        {
            new 
msg[128], name[128];
            
format(msgsizeof(msg), "Player %s doesn't exist in the database"playerName);
            
SendClientMessage(playeridCOLOR_REDmsg);
            
GetPlayerName(playeridnamesizeof(name));
            
format(msgsizeof(msg), "Admin %s has just checked if the player %s exists in the database and he doesn't."nameplayerName);
            print(
msg);
        }
    }
    return 
1;

But I am really don't know how to do that because I am only able to access the row count in the callback and not after sending the query in the first method
Pass the admin variable in the callback. Then send the message to that admin ID that you have passed within the callback.

https://pastebin.com/hg0RfbeQ


Re: How do I return something from the callback of the pquery method? - EtayJ - 15.10.2017

Thanks Kyle!