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
#2

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
Reply
#3

Thanks Kyle!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)