My command and function's not working.
#1

I made a command to see who's playing what, and at the moment it just goes like this:
Quote:

Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:
Name: James | Playing:

When it should go:
Quote:

Name: James | Playing: Roleplay
Name: Joe | Playing: Deathmatch

Here's my command:
pawn Код:
if (strcmp("/playing", cmdtext, true, 10) == 0)
    {
      new name[MAX_PLAYER_NAME], string[256], gametype[256];
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
        GetPlayerName(i, name, sizeof(name));
        gametype = GetPlayerGameType(i);
            format(string, sizeof(string), "Name: %s | Playing: %s", name, gametype);
          SendClientMessage(playerid, COLOR_WHITE, string);
        }
        return 1;
    }
And here's my function:
pawn Код:
GetPlayerGameType(targetid) {
    new gametypetext[256];
    switch(PlayerInfo[targetid][GameType])
    {
      case 1: gametypetext = "Free For All";
      case 2: gametypetext = "Team Deathmatch";
      case 3: gametypetext = "Roleplay";
    }
    return gametypetext;
}
I get no errors when compiling.
Reply
#2

Код:
if (strcmp("/playing", cmdtext, true, 10) == 0)
{
  new name[MAX_PLAYER_NAME], string[256], gametype[256];
  for(new i = 0; i < MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      GetPlayerName(i, name, sizeof(name));
      gametype = GetPlayerGameType(i);
      format(string, sizeof(string), "Name: %s | Playing: %s", name, gametype);
      SendClientMessage(playerid, COLOR_WHITE, string);
    }
  }
  return 1;
}
Try this, you forget to check is player from your loop connected
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)