Turning Cmds - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Turning Cmds (
/showthread.php?tid=259672)
Turning Cmds -
0_o - 05.06.2011
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;
}
Re: Turning Cmds -
KoczkaHUN - 05.06.2011
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;
}
Re: Turning Cmds -
Laronic - 05.06.2011
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;
}
Re: Turning Cmds -
0_o - 05.06.2011
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
Re: Turning Cmds -
KoczkaHUN - 05.06.2011
Quote:
Originally Posted by 0_o
Pawn compiler crashes
|
code fixed, it should work now. sorry.
Re: Turning Cmds -
Mean - 05.06.2011
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.
Re: Turning Cmds -
0_o - 05.06.2011
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.
Re: Turning Cmds -
KoczkaHUN - 05.06.2011
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.
Re: Turning Cmds -
KoczkaHUN - 05.06.2011
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.
|
Re: Turning Cmds -
0_o - 05.06.2011
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?