Loop bug
#1

I have loop problem with SendClientMessage - in the following picture you can see the message "All player accounts updated successfully." and it sends this message according to player numbers - we were 2 players in the server but when we will be 5 it will send 5 times.
btw when i use break; it gives me tag mismatch....



Код:
CMD:savechars(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >= 99999) 
	foreach(Player, i)
	{
		OnPlayerStatsUpdate(i);
        SaveEventPoints();
        SaveAccountsUpdate();
        SaveHouses();
        SendClientMessageEx(playerid, COLOR_YELLOW, "All player accounts updated successfully.");
    }
    else {
        SendTDMessage(playerid, COLOR_WHITE, "You are not authorized to use this command.");
	}
    return 1;
}
Reply
#2

pawn Код:
CMD:savechars(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] < 99999) return SendTDMessage(playerid, COLOR_WHITE, "You are not authorized to use this command.");
    foreach(Player, i) OnPlayerStatsUpdate(i);
    SaveEventPoints();
    SaveAccountsUpdate();
    SaveHouses();
    SendClientMessageEx(playerid, COLOR_YELLOW, "All player accounts updated successfully.");
    return 1;
}
You need to use only OnPlayerStatsUpdate to the loop. Any other function should be called only once and outside of the loop.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)