SA-MP Forums Archive
Toll Booth System Gate not closing - 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 Gate not closing (/showthread.php?tid=486579)



Toll Booth System Gate not closing - Blademaster680 - 09.01.2014

Hey guys,

So I have made a tollbooth for my server. When you get in range of the booth, it takes the money and the gate opens. Then I have made a timer that counts 5 seconds and the boom should close, but its not. Any help?
Everything works perfectly fine except the boom isn't moving back into place after 5 seconds.

At the top of the script:
Код:
new TollBoothPaid[MAX_PLAYERS];
new TollBoothLV = 0;
OnGameModeInit:
Код:
TollBoothLV = CreateDynamicObject(968, 1624.58130, 136.62405, 35.83821,   0.00000, 270.00000, 167.99652);
OnPlayerUpdate:
Код:
if(IsPlayerInRangeOfPoint(playerid, 5, 1626.1011,124.8513,36.3228))
		{
		    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		    {
			    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);
					TollBoothLV = 1;
				    TollBoothPaid[playerid] = 1;
				    SetTimer("tollboothlv", 5000, false);
				    return 1;
			    }
		    }
		}
Timer:
Код:
forward tollbothlv(playerid)
public tollboothlv(playerid)
{
	TollBoothPaid[playerid] = 0;
	if(TollBoothLV == 1)
	{
		TollBoothLV = 0;
    	MoveDynamicObject(TollBoothLV, 1624.5813, 136.6241, 35.8382, 1, -0.0, -0.0, -0.0);
    }
}



Re: Toll Booth System Gate not closing - J4mmyHD - 09.01.2014

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 5, 1626.1011,124.8513,36.3228))
        {
            if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                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);
                    TollBoothLV = 1;
                    TollBoothPaid[playerid] = 1;
                    SetTimer("tollboothlv", 5000, false, "i", playerid);
                    return 1;
                }
            }
        }
Try That.


Re: Toll Booth System Gate not closing - Burridge - 09.01.2014

Quote:
Originally Posted by J4mmyHD
Посмотреть сообщение
-code-
You need to use SetTimerEx if you're doing a timer per player! SetTimer doesn't have the extra parameters!


Re: Toll Booth System Gate not closing - Blademaster680 - 09.01.2014

Then that comes up.
"warning 202: number of arguments does not match definition"
I have already tried SetTimerEx also but still nothing


Re: Toll Booth System Gate not closing - iBots - 09.01.2014

try this ,instead of settimer:
pawn Код:
SetTimerEx("tollboothlv", 5000, false, "i", playerid);



Re: Toll Booth System Gate not closing - Blademaster680 - 09.01.2014

Ok I have fixed the issue. For those of you who also are having this problem make sure you set the rotations.
for example:
Код:
MoveDynamicObject(TollBoothLV, 1624.58130, 136.62405, 35.83821, 1, -0.0, -0.0, -0.0);
the rotations are the 3 at the end. So that will rotate the object to point straight up to the sky.
Then when you want it closed you use:
Код:
MoveDynamicObject(TollBoothLV, 1624.58130, 136.62405, 35.83821, 1, -0.0, -90.0, -0.0);
This will then rotate the object 90 degrees.
You need to play around with your rotations because its [Rotation:X][Rotation:Y][Rotation:Z]
Hope this helped