[Help]Bots list using ShowPlayerDialog
#1

I want to echo all the bots online using ShowPlayerDialog but I can't make it work, here's what I got. It will only display one of the bots D:

Код:
if(strcmp(cmd, "/bots", true) == 0) {
	for(new i = 0; i < MAX_PLAYERS; i++)
  {
   if(IsPlayerConnected(i)) {
     if(IsPlayerNPC(i)) {
     new botname[MAX_PLAYER_NAME];
     GetPlayerName(i, botname, sizeof(botname));
     format(string, sizeof(string), "%s(%d)\n", botname,i);
     ShowPlayerDialog(playerid,BOTSLISTID,DIALOG_STYLE_MSGBOX,"Bots online",string,"OK","Cancel");
    }
   }
  }
  return 1;
}
Any help will be very helpful, thanks in advance.
Reply
#2

pawn Код:
if(strcmp(cmd, "/bots", true) == 0)
{
  new string[256]; // 256 edit to a real size
    for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && IsPlayerNPC(i)) if(!i) format(string, sizeof(string), "%s(%d)\n", GetName(i),i); else format(string, sizeof(string), "%s%s(%d)\n",string, GetName(i),i);
    ShowPlayerDialog(playerid,BOTSLISTID,DIALOG_STYLE_MSGBOX,"Bots online",string,"OK","Cancel");
    return 1;
}
GetName( id )
{
new x[ MAX_PLAYER_NAME ];
if( IsPlayerConnected( id ) ) GetPlayerName( id , x , sizeof(x) );
return x;
}
PS: You can use the GetName function everywhere in your script
Reply
#3

Thanks it works
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)