Taking too much money
#1

Hi,
I made an advertising command and set the price to $500. The problem is that it takes $2500 instead of $500. And if the price is $800 it takes $2600. What's the problem? Here is the code of the advertising part:
Код:
    if (strlen(params) > 64)
	{
                foreach (new i : Player)
		{
		       SendClientMessageEx(i, COLOR_GREEN, "[Advertisement]: %.64s", params);
		       SendClientMessageEx(i, COLOR_GREEN, "...%s | Ph: %d", params[64], PlayerData[playerid][pPhone]);
			GiveMoney(playerid, -500);
			Advertisements = 0;
			SetTimerEx("AllowAdvertisements", 30000, false, "i");
		}
	}
	else
	{
                foreach (new i : Player)
		{
		        SendClientMessageEx(i, COLOR_GREEN, "[Advertisement]: %s | Ph: %d", params, PlayerData[playerid][pPhone]);
			GiveMoney(playerid, -500);
			Advertisements = 0;
			SetTimerEx("AllowAdvertisements", 30000, false, "i");
		}
	}
Reply
#2

No, it takes $500 Ч the amount of connected players because you have the GiveMoney statement inside the loop. Only the message themselves should be inside the loop. And even then, it would probably be better to format the messages before entering the loop and using the regular SendClientMessage.
Reply
#3

Or simply use SendClientMessageToAll instead of a loop since you don't have any condition to check.

Furthermore you have forgot to pass an argument in SetTimerEx function.
Reply
#4

Thank you guys.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)