gTeam members list in dialog problem, Help Please. -
CharlieSanchez - 11.05.2014
Hi well me and a friend i have got this so far to get a list of the players name that are on the same team using gTeam, however it only gets the last player name that joined and not the full list here is the code , and thanks in advance!
Sugestions ?
Cheers.
Код:
new gTeam[MAX_PLAYERS];
#define TEAM_GROVE 0
CMD:team(playerid, params[])
{
new name[MAX_PLAYER_NAME], string[1024];
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(playerid))
if(GetPlayerTeam(i))
if(gTeam[playerid] == TEAM_GROVE)
{
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s ", name);
ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_LIST, "Team online", string, "OK", "");
}
}
return 1;
}
Re: gTeam members list in dialog problem, Help Please. -
Konstantinos - 11.05.2014
pawn Код:
format(string, sizeof(string), "%s%s\n", string, name);
Re: gTeam members list in dialog problem, Help Please. -
CharlieSanchez - 11.05.2014
Konstantinos ! You are always the first to respond to my problems ! Thanks buddy we are going to try it that way and post the results.
Re: gTeam members list in dialog problem, Help Please. -
CharlieSanchez - 11.05.2014
Progress yes however it keeps looping non stop the players names , what can be done ? ideas ?
here is a screen shot of it looping :
Re: gTeam members list in dialog problem, Help Please. -
ball - 11.05.2014
In the loop you are checking if
playerid is connected (stupid, he used command, so for sure he is connected) and you are checking in variable gTeam again playerid team, not the loop player.
Код:
new gTeam[MAX_PLAYERS];
#define TEAM_GROVE 0
CMD:team(playerid, params[])
{
new name[MAX_PLAYER_NAME], string[1024];
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && gTeam[i] == TEAM_GROVE)
{
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s%s\n ", string, name);
}
}
return ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_LIST, "Team online", string, "OK", "");
}
Sorry for my english, I am from Poland. It is hard to learn new language :P
Re: gTeam members list in dialog problem, Help Please. -
CharlieSanchez - 11.05.2014
Quote:
Originally Posted by ball
In the loop you are checking if playerid is connected (stupid, he used command, so for sure he is connected) and you are checking in variable gTeam again playerid team, not the loop player.
Код:
new gTeam[MAX_PLAYERS];
#define TEAM_GROVE 0
CMD:team(playerid, params[])
{
new name[MAX_PLAYER_NAME], string[1024];
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && gTeam[i] == TEAM_GROVE)
{
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s%s\n ", string, name);
}
}
return ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_LIST, "Team online", string, "OK", "");
}
Sorry for my english, I am from Poland. It is hard to learn new language :P
|
Thank you it worked like a charm, we have been for a couple of hours on this and was plain obvious there but hey thanks for the help
Cheers.