One Little Problem... - 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: One Little Problem... (
/showthread.php?tid=278490)
One Little Problem... -
Tigerbeast11 - 22.08.2011
I have this code from XAdmin:
pawn Code:
for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) new string[256], name[24]; GetPlayerName(playerid,name,24); format(string,256,"%s has slapped everyone",name);
But I get these errors on this line:
Code:
XAdmin.pwn(368) : error 003: declaration of a local variable must appear in a compound block
XAdmin.pwn(368) : error 017: undefined symbol "string"
XAdmin.pwn(368) : warning 215: expression has no effect
XAdmin.pwn(368) : error 001: expected token: ";", but found "]"
XAdmin.pwn(368) : fatal error 107: too many error messages on one line
Can anyone help?
Re: One Little Problem... -
Darnell - 22.08.2011
pawn Code:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new string[100], name[24];
GetPlayerName(playerid,name,24);
format(string,sizeof(string),"%s has slapped everyone",name);
SendClientMessageToAll(-1, string);
}
}
Not sure it'll work..I'm not that good of a scripter after all
.
EDIT: Forgot a bracket after IsPlayerConnected.
Re: One Little Problem... -
Tigerbeast11 - 22.08.2011
Ive changed it to this:
pawn Code:
dcmd_slapall(playerid,params[])
{
#pragma unused params
if(IsPlayerCommandLevel(playerid,"slapall")
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new string[100], name[24];
GetPlayerName(playerid,name,24);
format(string,sizeof(string),"%s has slapped everyone",name);
SendClientMessageToAll(-1, string);
}
}
}
else
{
return SendLevelErrorMessage(playerid,"slapall");
}
}
Now I only get 2 errors:
Code:
XAdmin.pwn(367) : error 001: expected token: ")", but found "{"
XAdmin.pwn(383) : warning 209: function "dcmd_slapall" should return a value
EDIT: Nevermind, I fixed it! Both of you can have a rep!
Re: One Little Problem... -
Dragony92 - 22.08.2011
pawn Code:
dcmd_slapall(playerid,params[])
{
#pragma unused params
if(IsPlayerCommandLevel(playerid,"slapall"))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new string[100], name[24];
GetPlayerName(playerid,name,24);
format(string,sizeof(string),"%s has slapped everyone",name);
SendClientMessageToAll(-1, string);
}
}
}
else
{
return SendLevelErrorMessage(playerid,"slapall");
}
return 1;
}