/givescoreall and /givemoneyall
#2

You used SendClientMessageToAll inside a loop, that's why.

I recommend you to use foreach for players-looping since it loops ONLY through connected players and it's MUCH faster!

pawn Код:
CMD:givescoreall(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - You're not a high enough level to use this command!");
    new
        score;
    if (sscanf(params, "d", score)) return SendClientMessage(playerid, COLOR_RED, "[USAGE] - /givescoreall [AMMOUNT]");
    if (score < 1) return SendClientMessage(playerid, COLOR_RED, "[ERROR] - You need to give more than 0 score.");
    new
        string[74],
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(string, sizeof(string), "[ADMIN] - %s[%d] has used GIVESCOREALL - %d -", name, playerid, score);
    SendMessageToAdmins(string);
    format(string, sizeof(string), "* Admin %s[%d] has given %d score to everyone!", name, playerid, score);
    SendClientMessageToAll(COLOR_YELLOW, string);

    for (new i; i != MAX_PLAYERS; ++i)
    {
        if (!IsPlayerConnected(i)) continue;
        SetPlayerScore(i, GetPlayerScore(i) + score);
    }
    return 1;
}

CMD:givemoneyall(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - You're not a high enough level to use this command!");
    new
        money;
    if(sscanf(params, "d", money)) return SendClientMessage(playerid, COLOR_RED, "[USAGE] - /givemoneyall [AMMOUNT]");
    if( money < 1 ) return SendClientMessage(playerid, COLOR_RED, "[ERROR] - You need to give more than 0$");
    new
        string[74],
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(string, sizeof(string), "[ADMIN] - %s[%d] has used GIVEMONEYALL - %d -", name, playerid, money);
    SendMessageToAdmins(string);
    format(string, sizeof(string), "* Admin %s[%d] has given %d$ to everyone!", name, playerid, money);
    SendClientMessageToAll(COLOR_YELLOW, string);
   
    for (new i; i != MAX_PLAYERS; ++i)
    {
        if (!IsPlayerConnected(i)) continue;
        GivePlayerMoney(i, money);
    }
    return 1;
}
Reply


Messages In This Thread
/givescoreall and /givemoneyall - by Kyance - 20.12.2013, 18:28
Re: /givescoreall and /givemoneyall - by Konstantinos - 20.12.2013, 18:47
Re: /givescoreall and /givemoneyall - by CutX - 20.12.2013, 18:50
Re: /givescoreall and /givemoneyall - by Zamora - 20.12.2013, 18:53
Re: /givescoreall and /givemoneyall - by Kyance - 20.12.2013, 19:20

Forum Jump:


Users browsing this thread: 1 Guest(s)