need help with tolls
#1

i have the problem that when i go up to the toll it goes down and then shoots up straight away, then if i go up to it again it just goes down a little bit and back up again so there is no chance to pass it . any help ?

i did have an idea to use a checkpoint , but i havent got a clue how to add that in as im just learning , and dont really want a checkpoint showing up where the toll is


pawn Code:
#include <a_samp>
#include <streamer>
#include <foreach>

new toll1;

forward Tolls();// The FUNCTION To Make The Tolls Work
forward Timer_TollsClose(playerid, tollid); // The Timer Making The Tolls Close

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("Toll script by Bally for Long Haul Trucking");
    print("--------------------------------------\n");
   
    toll1 = CreateDynamicObject(3578, 1651.2354736328, -43.643432617188, 36.139217376709, 0, 0, 21.5);
   
    SetTimer("Tolls", 1500, true);
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public Tolls()
{
    foreach(Player, playerid)
    {
        if(IsPlayerInRangeOfPoint(playerid, 15, 1651.2354736328, -43.643432617188, 36.139217376709)) // Checking If The Player Is In Range Of Any Of The Tolls
        {
            MoveDynamicObject(toll1, 1651.2353515625, -43.642578125, 34.464115142822, 2.5); // Moves Toll1
            GivePlayerMoney(playerid, -10); // Takes 10 Off Players Money LEAVE THIS AS IT IS
            GameTextForPlayer(playerid, "~r~THANK YOU~n~~b~$10", 30000, 3);
            SetTimerEx("Timer_TollsClose",18000,true,"ii",playerid, 0);
           
        }
       
 }
}

public Timer_TollsClose(playerid, tollid)
{
    switch(tollid)
    {
        case 0: MoveDynamicObject(toll1, 1651.2354736328, -43.643432617188, 36.139217376709, 2.5); // Moves The Toll Back Cords found On the original CreateDynamicObject function
       
    }
}
Reply
#2

Most likely because Timer_TollsClose function is moving the wrong object ID.
pawn Code:
SetTimerEx("Timer_TollsClose",18000,true,"ii",playerid, 0);
With this line you are going to move the object ID of 0, which is invalid (object IDs start with 1). Since the object you move originally is 'toll1', you should make sure it closes (and keep the ID constant).
pawn Code:
SetTimerEx("Timer_TollsClose",18000,true,"ii",playerid, toll1);
I'm also curious, why do you pass the playerid parameter to the function when it's never used?
Reply
#3

i use the playerid parameter because the person who learned me to script has shown me that way to do it like i say im very basic , and trying to learn more so i can benefit from other peoples methods of scripting
Reply
#4

Well seeing as it's not needed, since you never use it in the function, you can remove it:
pawn Code:
public Timer_TollsClose(tollid)
{
    switch(tollid)
    {
        case 0: MoveDynamicObject(toll1, 1651.2354736328, -43.643432617188, 36.139217376709, 2.5); // Moves The Toll Back Cords found On the original CreateDynamicObject function
       
    }
}
With that done, however, you'll need to edit the SetTimerEx function to not pass the playerid parameter:
pawn Code:
SetTimerEx("Timer_TollsClose",18000,true,"i",0);
Also, did my previous post fix your problem?
Reply
#5

yes it did thankyou very much , i gave some rep
Reply
#6

im now using it like this . is this how you ment it to be?

pawn Code:
#include <a_samp>
#include <streamer>
#include <foreach>

new toll1;

forward Tolls();// The FUNCTION To Make The Tolls Work
forward Timer_TollsClose(tollid); // The Timer Making The Tolls Close

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("Toll script by Bally for Long Haul Trucking");
    print("--------------------------------------\n");
   
    toll1 = CreateDynamicObject(3578, 1651.2354736328, -43.643432617188, 36.139217376709, 0, 0, 21.5);
   
    SetTimer("Tolls", 1500, true);
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public Tolls()
{
    foreach(Player, playerid)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5, 1651.2354736328, -43.643432617188, 36.139217376709)) // Checking If The Player Is In Range Of Any Of The Tolls
        {
            MoveDynamicObject(toll1, 1651.2353515625, -43.642578125, 34.464115142822, 2.5); // Moves Toll1
            GivePlayerMoney(playerid, -10); // Takes 10 Off Players Money LEAVE THIS AS IT IS
            GameTextForPlayer(playerid, "~r~THANK YOU~n~~b~$10", 30000, 3);
            SetTimerEx("Timer_TollsClose",5000,true,"i",0);
           
        }
       
 }
}

public Timer_TollsClose(tollid)
{
    switch(tollid)
    {
        case 0: MoveDynamicObject(toll1, 1651.2354736328, -43.643432617188, 36.139217376709, 2.5); // Moves The Toll Back Cords found On the original CreateDynamicObject function

    }
}
Reply
#7

Sorry, my last post was slightly off. That is correct, besides the SetTimerEx line, change it to so:
pawn Code:
SetTimerEx("Timer_TollsClose",5000,true,"i",toll1);
Explanation as to why is in my first reply.
Reply
#8

thankyou they are workingish now , the problem ive got now is they come up to fast but i just need to work out a good timer to use so i guess its just trial and error
Reply
#9

Yes, it's all trial and error for that, as it is with many precise things for SA:MP. To adjust the speed at which the object will move (in case you don't already know), change the last parameter in the MoveDynamicObject function.
Reply
#10

i didnt no that, i just changed it from 2.5 to 1.5 if that will make it slower
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)