How do I return something from the callback of the pquery method?
#1

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
Reply


Messages In This Thread
How do I return something from the callback of the pquery method? - by EtayJ - 15.10.2017, 12:10
Re: How do I return something from the callback of the pquery method? - by Kyle - 15.10.2017, 12:41
Re: How do I return something from the callback of the pquery method? - by EtayJ - 15.10.2017, 12:46

Forum Jump:


Users browsing this thread: 2 Guest(s)