17.07.2016, 12:14
(
Последний раз редактировалось Stinged; 17.07.2016 в 14:54.
Причина: Forgot to use IsPlayerConnected in the loop (I'm used to foreach)
)
Код:
CMD:say(playerid, params[]) { if (isnull(params)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /s [Action]"); new Float: x, Float: y, Float: z, string[145], count; GetPlayerPos(playerid, x, y, z); GetPlayerName(playerid, string, 24); format(string, sizeof(string), "*%s says\58 \34%s\34", string, params); for (new i, j = GetPlayerPoolSize(); i <= j; i++) // for (new i; i < MAX_PLAYERS; i++) if you don't use 0.3.7 { if (!IsPlayerConnected(i)) continue; if (IsPlayerInRangeOfPoint(i, 25.0, x, y, z)) { SendClientMessage(i, COLOR_LIGHTBLUE, string); count++; } } if (!count) SendClientMessage(playerid, COLOR_SILVER, "You spoke but nobody heard you..."); return 1; }
You should format once, outside the loop. No need to format every time the loop runs, because the message is not changing.
Also, no need for sscanf when you're only using a string, because 'params[]' is already a string.