Toll Booth System SPAM
#1

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
Reply
#2

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.
Reply
#3

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.
Reply
#4

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?
Reply
#5

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.
Reply
#6

I tried this "SetTimer("tollboothlv", 5000, false);"
But still no luck

Code updated so you can see it now.

Any other ideas?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)