public OnPlayerText(playerid, text[]) { new string[56]; new PlayerName[MAX_PLAYER_NAME]; for(new i; i<MAX_PLAYERS; i++) new Float:XXX,Float:YYY,Float:ZZZ; GetPlayerPos(playerid, XXX, YYY, ZZZ); if(IsPlayerInRangeOfPoint(i, 25.0, XXX, YYY, ZZZ)) { format(string, sizeof(string), "%s says: %s",PlayerName,text); SendClientMessage(i, 0xFF0000AA, string); } return 1; }
C:\SAMP 0.3b Server R2\gamemodes\Unknown-RP.pwn(72) : error 003: declaration of a local variable must appear in a compound block C:\SAMP 0.3b Server R2\gamemodes\Unknown-RP.pwn(72) : warning 221: label name "Float" shadows tag name C:\SAMP 0.3b Server R2\gamemodes\Unknown-RP.pwn(72) : error 017: undefined symbol "XXX" C:\SAMP 0.3b Server R2\gamemodes\Unknown-RP.pwn(72) : warning 215: expression has no effect C:\SAMP 0.3b Server R2\gamemodes\Unknown-RP.pwn(73) : error 017: undefined symbol "XXX" C:\SAMP 0.3b Server R2\gamemodes\Unknown-RP.pwn(74) : error 017: undefined symbol "i" C:\SAMP 0.3b Server R2\gamemodes\Unknown-RP.pwn(77) : error 017: undefined symbol "i" C:\SAMP 0.3b Server R2\gamemodes\Unknown-RP.pwn(72) : warning 203: symbol is never used: "Float" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 5 Errors.
public OnPlayerText(playerid, text[])
{
new string[56];
new PlayerName[MAX_PLAYER_NAME];
for(new i; i<MAX_PLAYERS; i++)
{
new Float:XXX,Float:YYY,Float:ZZZ;
GetPlayerPos(playerid, XXX, YYY, ZZZ);
if(IsPlayerInRangeOfPoint(i, 25.0, XXX, YYY, ZZZ))
{
format(string, sizeof(string), "%s says: %s",PlayerName,text);
SendClientMessage(i, 0xFF0000AA, string);
}
}
return 1;
}
You had no opening brace after the 'for' loop.
Also loops like that should be <= MAX_PLAYERS. Because if your sever is full the loop will miss a player. |
stock localMessage(playerid, colour, string[], Float: Distance)
{
new Float:PosFloats[3];
GetPlayerPos(playerid, PosFloats[0], PosFloats[1], PosFloats[2]);
foreach(Player, i)
{
if(IsPlayerInRangeOfPoint(i, Distance, PosFloats[0], PosFloats[1], PosFloats[2])
{
SendClientMessage(i, colour, string);
}
}
return 1;
}
public OnPlayerText(playerid, text[])
{
new
string[128], // 56 cells isn't going to get you very far when the text I/O is 128.
PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s says: %s",PlayerName,text);
localMessage(playerid, 0xFF0000AA, string, 15.0); // Distance you want to send it to
return 1;
}