will this ever work? is there a way to fix it? - 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: will this ever work? is there a way to fix it? (
/showthread.php?tid=86251)
will this ever work? is there a way to fix it? -
[GF]sIdEkIcK - 12.07.2009
hello. is there a way to fix this code? is it fixable or is it impossible
Код:
stock SendAdminMessage(Message[])
for(new i; i<MAX_PLAYERS; i++) {
if(IsPlayerAdmin(i)) {
new name[MAX_PLAYER_NAME];
new string[256];
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s used command: %s", name, Message);
SendClientMessage(i,LIGHTBLUE, string);
return 1; } }
Edit: i get 1 warning:
Код:
C:\SAMPSE~1\FILTER~1\manhunt.pwn(91) : warning 209: function "SendAdminMessage" should return a value
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
Re: will this ever work? is there a way to fix it? -
dice7 - 12.07.2009
pawn Код:
stock SendAdminMessage(Message[])
{
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerAdmin(i))
{
new name[MAX_PLAYER_NAME];
new string[256];
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s used command: %s", name, Message);
SendClientMessage(i,LIGHTBLUE, string);
}
}
return 1;
}
Re: will this ever work? is there a way to fix it? -
Weirdosport - 12.07.2009
The string doesn't need to be of size 256, as the maximum you'll ever output is 128. Also it would be a better idea to keep the declarations outside the function to save them being re-allocated each time.
Example:
pawn Код:
new name[MAX_PLAYER_NAME], string[128];
stock SendAdminMessage(Message[])
{
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerAdmin(i))
{
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s used command: %s", name, Message);
SendClientMessage(i,LIGHTBLUE, string);
}
}
return 1;
}
Re: will this ever work? is there a way to fix it? -
[GF]sIdEkIcK - 12.07.2009
thnx a lot