Say command
#4

Код:
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 have to count how many players got the message, and then check if no one did after the loop.
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.
Reply


Messages In This Thread
Say command - by Tass007 - 17.07.2016, 11:17
Re: Say command - by oMa37 - 17.07.2016, 11:58
Re: Say command - by TaiRinsuru - 17.07.2016, 12:00
Re: Say command - by Stinged - 17.07.2016, 12:14
Re: Say command - by Tass007 - 18.07.2016, 04:52
Re: Say command - by Stinged - 18.07.2016, 08:55
Re: Say command - by Tass007 - 18.07.2016, 10:41
Re: Say command - by Tass007 - 20.07.2016, 02:09
Re: Say command - by Sew_Sumi - 20.07.2016, 03:20
Re: Say command - by Tass007 - 20.07.2016, 04:17

Forum Jump:


Users browsing this thread: 1 Guest(s)