IsPlayerConnected returns 0
#1

I've got this snippet of code:

pawn Код:
public OnPlayerConnect(playerid)
{
    //Check if player has an account
    new query[256], pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
   
    mysql_format(sql_connection, query, sizeof(query), "SELECT * FROM player WHERE name = '%s' LIMIT 1", pname);
    mysql_tquery(sql_connection, query, "OnAccountCheck", "r", playerid);
   
    return 1;
}

forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
    printf("Connect status: %d", IsPlayerConnected(playerid));
    new row_count;
    if(!cache_get_row_count(row_count))
    {
        return 1;
    }
    if(row_count == 0) //No account, register
    {
   
    }
    else //Account registered, log in
    {
        printf("Hello %s", RoleplayName(playerid));
    }
   
    return 1;
}

In which especially this part is concerning me
pawn Код:
printf("Connect status: %d", IsPlayerConnected(playerid));
In the console it returns the following:
Quote:

Connect status: 0

So it considers me as not being connected, while I clearly am. What could be the reason(s) that this is the case?
Reply
#2

Код:
mysql_tquery(sql_connection, query, "OnAccountCheck", "r", playerid);
It probably passes an invalid id. r passes a reference but in this case you should pass an integer. Use i instead of r.
Reply
#3

Also,
This:

PHP код:
 if(!cache_get_row_count(row_count))
    {
        return 
1;
      } 
and
PHP код:
if(row_count == 0//No account, register
    
{
    
    } 
Are same.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)