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=178858)



player is not connected? - Seven. - 24.09.2010

pawn Код:
dcmd_stats(playerid, params[])
{
    new string[156];
    new targetid;
    if(sscanf(params, "u", targetid))
    {
//code
    }
    else
    {
//code
    }
    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!");
    return 1;
}
It's showing me i ain't connected or when typing someone elses id. It will show my stats fine or when typing someones id. But it's telling me all the time player is not connected.


Re: player is not connected? - Ash. - 24.09.2010

Try:

pawn Код:
dcmd_stats(playerid, params[])
{
    new string[156];
    new targetid;
    if(sscanf(params, "u", targetid))
    {
//code
    }
    else
    {
//code
    }
    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!");
    return 1;
}



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

What did you change? And i am experiencing another problem with my /pm command

pawn Код:
dcmd_pm(playerid, params[])
{
    new targetid;
    new string[128];
    new message[128];
    if(sscanf(params,"uz",targetid,message)) return SM(playerid,red,"Error: /pm [id/name] [message]");
   
    format(string, sizeof(string),"PM: %s(id: %d): %s",gPlayer[playerid][gName],message);
    SendClientMessage(targetid,PLAYER_COLOR_YELLOW,string);
    return 1;
}
It's crashing the server somehow.. :S


Re: player is not connected? - yakitashax - 24.09.2010

What about just:
Код:
 if(!IsPlayerConnect(playerid)) return SendClientMessage(playerid, color, "Player ain't online");
?

if it'd be a code for, if function wasn't full, use that as example:

Код:
dcmd_skin(playerid,params[])
	 {
	    new tmp2[256], Index; tmp2 = strtok(params,Index);
		new skin = strval(tmp2);
		if(!strlen(tmp2)) return SendClientMessage(playerid, COLOR_WHITE, "USO: /skin [skin id]"); // if was just /skin, returns this message
		if(!IsValidSkin(skin)) return SendClientMessage(playerid, COLOR_WHITE, "Skin Invalido");
        SetPlayerSkin(playerid, skin);
        return  SendClientMessage(playerid, vermelho, "/si for save skin and your spawn position!!");




}



Re: player is not connected? - The_Moddler - 24.09.2010

pawn Код:
dcmd_pm(playerid, params[])
{
    new targetid;
    new string[128];
    new message[128];
    if(sscanf(params,"uz",targetid,message)) return SM(playerid,red,"Error: /pm [id/name] [message]");
    else if(targetid== INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFFFFFFFF, "Not connected.");
    else
    {
        format(string, sizeof(string),"PM: %s(id: %d): %s",gPlayer[playerid][gName],message);
        SendClientMessage(targetid,PLAYER_COLOR_YELLOW,string);
    }
    return 1;
}