Toll Booth System SPAM - 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: Toll Booth System SPAM (
/showthread.php?tid=486144)
Toll Booth System SPAM -
Blademaster680 - 07.01.2014
Hey guys.
So I am making a tollbooth system for my server but when the player gets into range it will open the gate and spam the chat and keeps taking money while they are in range. I have also made a timer but it isn't closing the gate in 5 seconds.
This is the code:
Код:
new TollBoothLV = 0;
OnPlayerUpdate
Код:
if(IsPlayerInRangeOfPoint(playerid, 5, 1626.1011,124.8513,36.3228))
{
if(TollBoothPaid[playerid] == 0)
{
new string[128];
PlayerInfo[playerid][pCash] -= TOLL_BOOTH_FEE;
MoveDynamicObject(TollBoothLV, 1624.5881, 136.6429, 35.8382, 1, -0.0, -0.0, -0.0);
format(string, sizeof(string), "The toll booth has cost you: $%i. You have 5 seconds to get through.", TOLL_BOOTH_FEE);
SendClientMessage(playerid, COLOR_YELLOW, string);
TollBoothPaid[playerid] = 1;
SetTimer("tollboothlv", 5000, false);
return 1;
}
}
forward tollboothlv(playerid);
public tollboothlv(playerid)
{
TollBoothPaid[playerid] = 0;
MoveDynamicObject(TollBoothLV, 1624.58130, 136.62405, 35.83821, 1, -0.0, -0.0, -0.0);
}
OnGameModeInit
Код:
TollBoothLV = CreateDynamicObject(968, 1624.58130, 136.62405, 35.83821, 0.00000, 270.00000, 167.99652);
Hopefully one of you can solve this?
Thanks
Re: Toll Booth System SPAM -
offon - 07.01.2014
In which public do you call this? You can check if the player already paid with a variable and then, when the timer executes you can remove the variable.
Re: Toll Booth System SPAM -
BlackSirrah239 - 07.01.2014
Don't use OnPlayerUpdate, that is called 30 times a second. Mix timers & variables to check if they are in range and if they have already paid the toll recently.
Re: Toll Booth System SPAM -
Blademaster680 - 07.01.2014
And the timer? why isnt it closing the gate after 5 seconds?
Ok I have added the variable and it resets in the timer but the gate still doesnt close. Why is that?
Re: Toll Booth System SPAM -
offon - 07.01.2014
Once I had a similliar problem. Try to put the forward at the top of the script. If that doesn't work, try to use SetTimer instead SetTimerEx.
Re: Toll Booth System SPAM -
Blademaster680 - 07.01.2014
I tried this "SetTimer("tollboothlv", 5000, false);"
But still no luck
Code updated so you can see it now.
Any other ideas?