Taking too much money - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Taking too much money (
/showthread.php?tid=610331)
Taking too much money -
GoldenLion - 22.06.2016
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");
}
}
Re: Taking too much money -
Vince - 22.06.2016
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.
Re: Taking too much money -
Konstantinos - 22.06.2016
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.
Re: Taking too much money -
GoldenLion - 23.06.2016
Thank you guys.