player is not connected?
#1

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

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

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

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)