[Help]Bots list using ShowPlayerDialog - 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: [Help]Bots list using ShowPlayerDialog (
/showthread.php?tid=113993)
[Help]Bots list using ShowPlayerDialog -
zilvernex - 17.12.2009
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.
Re: [Help]Bots list using ShowPlayerDialog -
_[HuN]_Epsilon_ - 17.12.2009
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
Re: [Help]Bots list using ShowPlayerDialog -
zilvernex - 17.12.2009
Thanks it works