/playerlist Only one players shows up ;/
#1

I was making a command to show players for a specific group and i wanted to test it on NPC's, but only one of 4 NPC's show up ;/

Код:
    if(!strcmp(cmdtext, "/testing", true))
	{
	new name[MAX_PLAYER_NAME];
	for(new i = 0; i <MAX_PLAYERS; i++){
	if(IsPlayerNPC(i)){
	new lol[256] = "* ";

	GetPlayerName(i,name,MAX_PLAYER_NAME);
	format(lol,256,"{FFFFFF}%s {64B500}%s,",lol,name);
	ShowPlayerDialog(playerid,100,DIALOG_STYLE_MSGBOX,"{64B500}Online:",lol,"OK","Exit");
	}
	}
	return 1;
	}
Reply
#2

Oh yes if i change the GUI with
Код:
SendClientMessage(playerid,COLOR_BLUE,lol);
it works fine, but i still need GUI ;/ HELP
Reply
#3

What is this ? o.O

PHP код:
new lol[256] = "* "
Reply
#4

pawn Код:
if(!strcmp(cmdtext, "/testing", true))
{
    new name[MAX_PLAYER_NAME], lol[256] = "* ";
    for(new i = 0; i <MAX_PLAYERS; i++)
    {
        if(IsPlayerNPC(i)) continue;
        GetPlayerName(i,name,MAX_PLAYER_NAME);
        format(lol, 256, "{FFFFFF}%s {64B500}%s,", lol, name);
    }
    ShowPlayerDialog(playerid,100,DIALOG_STYLE_MSGBOX,"{64B500}Online:",lol,"OK","Exit");
    return 1;
}
Reply
#5

PHP код:
if(!strcmp(cmdtext"/testing"true))
{
    new 
name[MAX_PLAYER_NAME], lol[256], string[80];
    for(new 
0<MAX_PLAYERSi++)
    {
        if(!
IsPlayerNPC(i)) continue;
        
GetPlayerName(inameMAX_PLAYER_NAME);
        
format(stringsizeof string,"{FFFFFF}%d {64B500}%s,"iname);
        
strcat(lol,string);
    }
    
ShowPlayerDialog(playerid,100,DIALOG_STYLE_MSGBOX,"{64B500}Online:",lol,"OK","Exit");
    return 
1;

Reply
#6

Quote:
Originally Posted by Shadoww5
Посмотреть сообщение
PHP код:
if(!strcmp(cmdtext"/testing"true))
{
    new 
name[MAX_PLAYER_NAME], lol[256];
    for(new 
0<MAX_PLAYERSi++)
    {
        if(!
IsPlayerNPC(i)) continue;
        
GetPlayerName(i,name,MAX_PLAYER_NAME);
        
strcat(lol,"{FFFFFF}%s {64B500}%s,",i,name);
    }
    
ShowPlayerDialog(playerid,100,DIALOG_STYLE_MSGBOX,"{64B500}Online:",lol,"OK","Exit");
    return 
1;

you cant do strcat(lol,"{FFFFFF}%s {64B500}%s,",i,name);

so either way, mine would be the working one and the fastest.. cus if u do format then strcat = slower..
Reply
#7

Oh sorry !

Now it's correct:

PHP код:
if(!strcmp(cmdtext"/testing"true))
{
    new 
name[MAX_PLAYER_NAME], lol[256], string[80];
    for(new 
0<MAX_PLAYERSi++)
    {
        if(!
IsPlayerNPC(i)) continue;
        
GetPlayerName(inameMAX_PLAYER_NAME);
        
format(stringsizeof string"{FFFFFF}%d {64B500}%s,"iname);
        
strcat(lol,string);
    }
    
ShowPlayerDialog(playerid,100,DIALOG_STYLE_MSGBOX,"{64B500}Online:",lol,"OK","Exit");
    return 
1;

Reply
#8

Test this..
PHP код:
    if(strcmp(cmd"/testing"true) == 0//by Ricop522
    
{
        new 
playersonline[500], playersonline2[504];
        new 
plName[MAX_PLAYER_NAME], Ricop522  0;
        for( ; 
Ricop522 MAX_PLAYERS; ++Ricop522)
        {
            if(
IsPlayerConnected(i)) {
                
GetPlayerName(iplNamesizeof(plName));
                
format(playersonlinesizeof(playersonline), "{FFFFFF}%i {64B500}%s\n"Ricop522plName);
                
strcat(playersonline2,playersonline);
            }
        }
        
ShowPlayerDialog(playerid,100,DIALOG_STYLE_LIST,"Players On",playersonline2,"Exit","");
        return 
0x01;
    } 
Reply
#9

omg.. did u people not read my post.. and why are you people using the php code tag..
Reply
#10

Quote:
Originally Posted by Ricop522
Посмотреть сообщение
Test this..
PHP код:
    if(strcmp(cmd"/testing"true) == 0//by Ricop522
    
{
        new 
playersonline[500], playersonline2[504];
        static 
plName[MAX_PLAYER_NAME], Ricop522  0;
        for( ; 
Ricop522 MAX_PLAYERS; ++Ricop522)
        {
            if(
IsPlayerConnected(i)) {
                
GetPlayerName(iplNamesizeof(plName));
                
format(playersonlinesizeof(playersonline), "{FFFFFF}%i {64B500}%s\n"Ricop522plName);
                
strcat(playersonline2,playersonline);
            }
        }
        
ShowPlayerDialog(playerid,100,DIALOG_STYLE_LIST,"Players On",playersonline2,"Exit","");
        return 
0x01;
    } 
you can't use variables statics in loops and appers error: Undefined Symbol "i"

pawn Код:
if(strcmp(cmd, "/testing", true) == 0) //by Garfield
    {
        new playersonline[500], playersonline2[MAX_PLAYERS*2];
        new plName[MAX_PLAYER_NAME];
        for(new i ; i < MAX_PLAYERS; ++i)
        {
            if(IsPlayerConnected(i ))
            {
                GetPlayerName(i, plName, sizeof(plName));
                format(playersonline, sizeof(playersonline), "{FFFFFF}%i {64B500}%s\n", i, plName);
                strcat(playersonline2,playersonline);
            }
        }
        ShowPlayerDialog(playerid,100,DIALOG_STYLE_LIST,"Players On",playersonline2,"Exit","");
        return 1;
    }
[...]
Reply
#11

I say:
"I think this works."

I retired this from my gamemode, the /list of the cars .
You just copy my code and remove a little things.


Att, Ricop522.
Reply
#12

Quote:
Originally Posted by Ricop522
Посмотреть сообщение
I say:
"I think this works."

I retired this from my gamemode, the /list of the cars .
You just copy my code and remove a little things.


Att, Ricop522.
he fixed it. your code would've actually returned an error.

Quote:
Originally Posted by Donya
Посмотреть сообщение
pawn Код:
if(!strcmp(cmdtext, "/testing", true))
{
    new name[MAX_PLAYER_NAME], lol[256] = "* ";
    for(new i = 0; i <MAX_PLAYERS; i++)
    {
        if(IsPlayerNPC(i)) continue;
        GetPlayerName(i,name,MAX_PLAYER_NAME);
        format(lol, 256, "{FFFFFF}%s {64B500}%s,", lol, name);
    }
    ShowPlayerDialog(playerid,100,DIALOG_STYLE_MSGBOX,"{64B500}Online:",lol,"OK","Exit");
    return 1;
}
Reply
#13

I gonna clear up these things:
pawn Код:
if(!strcmp(cmdtext, "/testing", true))
{
    new bool:check = false, lol[1024] = "* ";
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerNPC(i)) //You can add here another checks later.
        {
            new name[MAX_PLAYER_NAME];
            GetPlayerName(i, name, sizeof(name));
            if(!check)
            {
                format(lol, sizeof(lol), "{FFFFFF}%s {64B500}%s", lol, name);
                state = true;
            }
            else format(lol, sizeof(lol),"%s, %s", lol, name);
        }
    }
    if(check) ShowPlayerDialog(playerid, 100, DIALOG_STYLE_MSGBOX, "{64B500}Online:", lol, "OK", "Exit");
    else ShowPlayerDialog(playerid, 100, DIALOG_STYLE_MSGBOX, "{64B500}Online:", "{FF0000}Nobody", "OK", "Exit");
    return 1;
}
Reply
#14

Quote:
Originally Posted by BigETI
Посмотреть сообщение
I gonna clear up these things:
pawn Код:
if(!strcmp(cmdtext, "/testing", true))
{
    new bool:check = false, lol[1024] = "* ";
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerNPC(i)) //You can add here another checks later.
        {
            new name[MAX_PLAYER_NAME];
            GetPlayerName(i, name, sizeof(name));
            if(!check)
            {
                format(lol, sizeof(lol), "{FFFFFF}%s {64B500}%s", lol, name);
                state = true;
            }
            else format(lol, sizeof(lol),"%s, %s", lol, name);
        }
    }
    if(check) ShowPlayerDialog(playerid, 100, DIALOG_STYLE_MSGBOX, "{64B500}Online:", lol, "OK", "Exit");
    else ShowPlayerDialog(playerid, 100, DIALOG_STYLE_MSGBOX, "{64B500}Online:", "{FF0000}Nobody", "OK", "Exit");
    return 1;
}
No need to do all this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)