/stats
#1

If i do only /stats, it shows correctly my stats, but if i do /stats name/id it shows only the message: "You can also use /stats id bla bla"

Why?

pawn Код:
CMD:stats(playerid, params[])
{
    new id;
    sscanf(params, "u", id);

    SCM(playerid,-1, "* You can also do "ORANGE_RED"/stats [playername/id] "WHITE"to check other player's stats.");

    if (isnull(params))
    {
    ShowStats(playerid);
    }

    else if(IsPlayerConnected(id))
    {
    ShowStats(id);
    }

    else SCM(playerid,COLOR_RED,"* Player is not connected or is invalid id/name.");
   
    return 1;
}
Reply
#2

Your code is old and inefficient. This should work (mind you - it is untested).
This should fix the issue you're having at the moment.

Код:
CMD:stats(playerid, params[])
{
	new targetid;
	if(sscanf(params, "u", targetid))
	{
		SendClientMessage(playerid, -1, "* You can also do "ORANGE_RED"/stats [playername/id] "WHITE"to check other player's stats.");
		targetid = playerid;
	}

	if(!IsPlayerConnected(targetid))
		return SendClientMessage(playerid, COLOR_RED, "* Player is not connected or is invalid id/name.");
	
	ShowStats(targetid);
	return 1;
}
Reply
#3

Doesn't work. It i do only /stats i get "Player is not connected" message.
Reply
#4

PHP код:
CMD:stats(playeridparams[])
{
    new 
id;
    if(
isnull(params)) format(params10"%d"playerid);
    if(
sscanf(params"i"id)) return SCM(playerid,-1"* USAGE "ORANGE_RED"/stats [playername/id] "WHITE"to check other player's stats.");
    if(
id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1"This player is not connected");
    
ShowStats(playeridid);
    return 
1;

You must add a variable to ShowStats
ShowStats(the player who used cmd, the id to show stats);

If you dont know how to do this show your ShowStats function
Reply
#5

Код:
CMD:stats(playerid, params[])
{
        new otherid;
	if(sscanf(params, "u", otherid))
	{
	    ShowStats(playerid);
 	}
	else
	{
	    	if(!IsPlayerConnected(otherid))
		return SendClientMessage(playerid, COLOR_RED, "* Player is not connected or is invalid id/name.");

	    ShowStats(otherid);
	}
	return true;
}
try this
Reply
#6

Ehi! Prova con:
PHP код:
CMD:stats(playeridparams[]){

    new 
id;
    
sscanf(params"u"id);

    if(
isnull(params)){
    
ShowStats(playerid);
    
SCM(playerid,-1"* You can also do "ORANGE_RED"/stats [playername/id] "WHITE"to check other player's stats.");
    return 
1;
    }

    if(
IsPlayerConnected(id)){
    
ShowStats(id);
    return 
1;
    }

     else 
SCM(playerid,COLOR_RED,"* Player is not connected or is invalid id/name.");
     
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)