SA-MP Forums Archive
IsPlayerConnected returns 0 - 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: IsPlayerConnected returns 0 (/showthread.php?tid=654570)



IsPlayerConnected returns 0 - Mado - 01.06.2018

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?


Re: IsPlayerConnected returns 0 - NaS - 01.06.2018

Код:
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.


Re: IsPlayerConnected returns 0 - GTLS - 01.06.2018

Also,
This:

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