Turning Cmds
#1

Thank you cyberghost, but if anyone or you can help me turn this command in strcmp it would be great!

pawn Код:
COMMAND:scoreboard(playerid, params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
    {
        new string[1337];
        format(string, sizeof(string), "%s                   \t           %d", PlayerName(i), GetPlayerScore(i));
        ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_MSGBOX, "     {FF0000}Name                                          Score", string, "Okai", "");
    }
    return 1;
}

stock PlayerName(playerid)
{
    new name[24];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if (!strcmp("scoreboard", cmdtext[1], true, 10))
  {
    new string[2048], strline[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      if (!IsPlayerConnected(i)) continue;
      format(strline, sizeof(strline), "%s                   \t           %d\n", PlayerName(i), GetPlayerScore(i));
      strcat(string, strline);
    }
    ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_MSGBOX, "     {FF0000}Name                                          Score", string, "Okai", "");
    return 1;
  }
  return 0;
}

stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Reply
#3

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    /////
    if(strcmp("/scoreboard", cmdtext, true, 10) == 0)
    {
        for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
        {
            new string[1337];
            format(string, sizeof(string), "%s                   \t           %d", PlayerName(i), GetPlayerScore(i));
            ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_MSGBOX, "     {FF0000}Name                                          Score", string, "Okai", "");
        }
        return 1;
    }
    /////
    return 0;
}

stock PlayerName(playerid)
{
    new name[24];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Reply
#4

Quote:
Originally Posted by KoczkaHUN
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if (!strcmp("scoreboard", cmdtext[1], true, 10))
  {
    new string[2048];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      if (!IsPlayerConnected(i)) continue;
      strcat(string, "%s                   \t           %d\n", PlayerName(i), GetPlayerScore(i));
    }
    ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_MSGBOX, "     {FF0000}Name                                          Score", string, "Okai", "");
    return 1;
  }
  return 0;
}

stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Pawn compiler crashes
Reply
#5

Quote:
Originally Posted by 0_o
Посмотреть сообщение
Pawn compiler crashes
code fixed, it should work now. sorry.
Reply
#6

Quote:
Originally Posted by KoczkaHUN
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if (!strcmp("scoreboard", cmdtext[1], true, 10))
  {
    new string[2048], strline[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      if (!IsPlayerConnected(i)) continue;
      format(strline, sizeof(strline), "%s                   \t           %d\n", PlayerName(i), GetPlayerScore(i));
      strcat(string, strline);
    }
    ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_MSGBOX, "     {FF0000}Name                                          Score", string, "Okai", "");
    return 1;
  }
  return 0;
}

stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Not sure, but I think 2048 is WAY too big.
Reply
#7

here is the warning :
pawn Код:
L:\SAGW\gamemodes\SAGW.pwn(733) : warning 219: local variable "string" shadows a variable at a preceding level
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
Reply
#8

Quote:
Originally Posted by Mean
Посмотреть сообщение
Not sure, but I think 2048 is WAY too big.
let's count with 500 players(MAX_PLAYERS): 500*20(MAX_PLAYER_NAME) = 1000 cells
500 \n = 500 cells
500 \t = 500 cells
overall: 2000 cells
I have not counted the whitespaces, it can be more.
So this size is needed.
Reply
#9

Quote:
Originally Posted by 0_o
Посмотреть сообщение
here is the warning :
pawn Код:
L:\SAGW\gamemodes\SAGW.pwn(733) : warning 219: local variable "string" shadows a variable at a preceding level
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if (!strcmp("scoreboard", cmdtext[1], true, 10))
  {
    new sbstring[2048], strline[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      if (!IsPlayerConnected(i)) continue;
      format(strline, sizeof(strline), "%s                   \t           %d\n", PlayerName(i), GetPlayerScore(i));
      strcat(sbstring, strline);
    }
    ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_MSGBOX, "     {FF0000}Name                                          Score", sbstring, "Okai", "");
    return 1;
  }
  return 0;
}

stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Quote:

This forum requires that you wait 120 seconds between posts. Please try again in 42 seconds.

Reply
#10

Quote:
Originally Posted by KoczkaHUN
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if (!strcmp("scoreboard", cmdtext[1], true, 10))
  {
    new sbstring[2048], strline[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      if (!IsPlayerConnected(i)) continue;
      format(strline, sizeof(strline), "%s                   \t           %d\n", PlayerName(i), GetPlayerScore(i));
      strcat(sbstring, strline);
    }
    ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_MSGBOX, "     {FF0000}Name                                          Score", sbstring, "Okai", "");
    return 1;
  }
  return 0;
}

stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
alright its working, i want to test it in server now, need a tester, anyone who can be in the server for 5 mins now?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)