SA-MP Forums Archive
player is not connected? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: player is not connected? (/showthread.php?tid=178307)



player is not connected? - Seven. - 21.09.2010

when typing /stats or /stats ID it's telling player is not connected blablah...

pawn Код:
dcmd_stats(playerid, params[])
{
    new string[128];
    new targetid;
    new Float:ratio=floatdiv(gPlayer[playerid][kills], gPlayer[playerid][deaths]);
    new Float:ratio2=floatdiv(gPlayer[targetid][kills], gPlayer[targetid][deaths]);
    if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID || targetid == playerid)return SM(playerid,red,"Error: Player is not connected. To view your own stats: /stats without id!");
    if(sscanf(params, "u", targetid))
    {
        //code
    }
    else
    {
        //code
    }
    return 1;
}
Any solutions?


Re: player is not connected? - Desert - 21.09.2010

Try putting the sscanf code before you check if the player is online.


Re: player is not connected? - Rachael - 21.09.2010

targetid will be zero as soon as it is defined.
You are checking if targetid is connected before assigning it the value with sscanf.
Put the sscanf before the if(IsPlayerConnected(targetid) .. etc


Re: player is not connected? - Seven. - 21.09.2010

Thanks