Posts: 715
Threads: 47
Joined: Mar 2011
Reputation:
0
omg.. did u people not read my post.. and why are you people using the php code tag..
Posts: 649
Threads: 4
Joined: Jul 2010
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(i, plName, sizeof(plName));
format(playersonline, sizeof(playersonline), "{FFFFFF}%i {64B500}%s\n", Ricop522, plName);
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;
}
[...]
Posts: 2,640
Threads: 122
Joined: Feb 2010
Reputation:
0
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.
Posts: 1,046
Threads: 29
Joined: Mar 2010
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;
}