Problem with (IsPlayerConnected)
#1

PHP код:
CMD:stats(playeridparams[])
{
    new 
id;
    if(
connected[playerid] == true) return GameTextForPlayer(playerid"~r~Spawn First"50005);
    if(!
IsPlayerConnected(id)) return SendClientMessage(playerid, -1"{c3c3c3}(INFO) The player is not connected!");
    if(
sscanf(params"u"id)) return SendClientMessage(playerid, -1"{c3c3c3}(INFO) /stats [id]");
    {
    new 
string[900], stats[900],str[129], iString[150];
    
format (iStringsizeof(iString), "{CECEF6}* You are viewing /stats of %s"PlayerName[playerid]);
    
SendClientMessage(playerid, -1iString);
    
format(strsizeof(str), "{FFFFFF}%s {4286f4}database id {FFFFFF}%i\n\n"PlayerName[id], pInfo[id][ID]);
    
strcat(statsstr);
    
format(stringsizeof(string), "{4286f4}Admin Level: ( {FFFFFF}%i {4286f4})\n"pInfo[id][Admin]);
    
strcat(statsstring);
    
format(stringsizeof(string), "{4286f4}Score: ( {FFFFFF}%i {4286f4})\n"pInfo[id][Score]);
    
strcat(statsstring);
    
format(stringsizeof(string), "{4286f4}Points: ( {FFFFFF}%i {4286f4})\n"pInfo[id][Points]);
    
strcat(statsstring);
    
format(stringsizeof(string), "{4286f4}Respect: ( {FFFFFF}%i {4286f4})\n"pInfo[id][Respect]);
    
strcat(statsstring);
    
format(stringsizeof(string), "{4286f4}Kills: ( {FFFFFF}%i {4286f4})\n"pInfo[id][Kills]);
    
strcat(statsstring);
    
format(stringsizeof(string), "{4286f4}Deaths: ( {FFFFFF}%i {4286f4})\n"pInfo[id][Deaths]);
    
strcat(statsstring);
    
format(stringsizeof(string), "{4286f4}Ratio K/D: ( {FFFFFF}%.2f {4286f4})\n"floatdiv(pInfo[id][Kills], pInfo[id][Deaths]));
    
strcat(statsstring);
    
ShowPlayerDialog(playerid55DIALOG_STYLE_MSGBOX"Player statistics"stats"Ok""");
    }
      return 
1;

So all works, except the one last thing, if i do /Stats 3 (id 3= not connected) , it just keep showing id 0 and then unknown command under.
Look's like the code is done correctly, do you guys got any ideas :&
Reply
#2

Because you don't retrieve player id from params. You should use sscanf to done the job.
Reply
#3

You need to check if is null return 0; or SCM
Edit: wops read that wrong, maybe check if is player connected? AFTER sscanf
Reply
#4

just add this.
PHP код:
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1"{c3c3c3}(INFO) Player not found!"); 
Reply
#5

Quote:
Originally Posted by Mugala
Посмотреть сообщение
just add this.
PHP код:
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1"{c3c3c3}(INFO) Player not found!"); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)