SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 25/03/2015, 11:43 PM   #1
BeesSi
Big Clucker
 
BeesSi's Avatar
 
Join Date: Jun 2014
Location: Macedonia
Posts: 103
Reputation: 8
Default Toll Bug

So, i got a toll system that is with a command /tolls and it will show you a dialog if you accept it that would take 2.5k blabla. So, i've put it at OnPlayerUpdate. So when the player gets near the range of point it will set a timer like 3 seconds and show you the dialog of the tolls. But the bug is that when i press Yes ( I accept ) it will open them and the dialog will show again after 5 secs ( this works ). But when i press No the dialog keeps showing me after 1 milisecond so i have to CTRL+ALT+DELETE and close the gta.

Code: It's in albanian language..

pawn Code:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 8.0, 1702.24023, 387.75421, 30.00490))
    {
        SetTimer("DialogKufini", 3000, false);
    }
    else if(IsPlayerInRangeOfPoint(playerid, 8.0, 1698.76074, 380.91251, 30.11920))
    {
        SetTimer("DialogKufini", 3000, false);
    }
    return 1;
}

pawn Code:
forward DialogKufini(playerid);
public DialogKufini(playerid)
{
    if(KufiniStatus[playerid] == 1)
    {
        KillTimer(DialogKufini(playerid));
    }
    else
    {
        SetTimer("ShowAgain", 3000, false); // It's supposed if the Toll status its 0 ( closed ) to Show the dialog again after 3 secs but it wont work.
    }
    return 1;
}

pawn Code:
forward ShowAgain(playerid);
public ShowAgain(playerid)
{
    return cmd_kufini(playerid, " ");
}
__________________
My works :

BesAdmin System v1.2

BeesSi is offline   Reply With Quote
Old 25/03/2015, 11:54 PM   #2
BeesSi
Big Clucker
 
BeesSi's Avatar
 
Join Date: Jun 2014
Location: Macedonia
Posts: 103
Reputation: 8
Default Re: Toll Bug

Bump..
__________________
My works :

BesAdmin System v1.2

BeesSi is offline   Reply With Quote
Old 25/03/2015, 11:55 PM   #3
SickAttack
High-roller
 
Join Date: Dec 2013
Posts: 4,761
Reputation: 754
Default Re: Toll Bug

Why are you even using OnPlayerUpdate for this? It's really unnecessary.

And this will be setting a timer every 20 milliseconds (overlapping):
pawn Code:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 8.0, 1702.24023, 387.75421, 30.00490))
    {
        SetTimer("DialogKufini", 3000, false);
    }
    else if(IsPlayerInRangeOfPoint(playerid, 8.0, 1698.76074, 380.91251, 30.11920))
    {
        SetTimer("DialogKufini", 3000, false);
    }
    return 1;
}
SickAttack is offline   Reply With Quote
Old 25/03/2015, 11:57 PM   #4
BeesSi
Big Clucker
 
BeesSi's Avatar
 
Join Date: Jun 2014
Location: Macedonia
Posts: 103
Reputation: 8
Default Re: Toll Bug

Because i want when the player gets near the range of point . It will show the dialog. It'll be like an automatic gate..
__________________
My works :

BesAdmin System v1.2

BeesSi is offline   Reply With Quote
Old 26/03/2015, 12:05 AM   #5
SickAttack
High-roller
 
Join Date: Dec 2013
Posts: 4,761
Reputation: 754
Default Re: Toll Bug

Quote:
Originally Posted by BeesSi View Post
Because i want when the player gets near the range of point . It will show the dialog. It'll be like an automatic gate..
But it's called every 20 milliseconds, which is 50 times in a second.

And the problem is that you're overlapping the timers, so you got 50 timers called constantly every second, plus 50 more the next second, plus 50 more the next second and so on as long as you're in range of the point.

The solution would be to add an if-statement exception, but I would suggest that you use a pickup or even a checkpoint instead of OnPlayerUpdate with range checks, but that's up to you, you can do what ever you want, I'm just given you advise.
SickAttack is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pay at toll livests Scripting Help 7 26/06/2012 03:58 PM
help /toll cmd Dw.UsHer Scripting Help 0 13/06/2012 07:53 AM
[HELP] TOLL quark Scripting Help 4 02/01/2012 09:01 AM
Toll thimo Scripting Help 12 25/12/2011 03:32 PM
[GM Add-On] Toll :D [FBI]AG3NT Filterscripts 18 17/05/2010 01:21 PM


All times are GMT. The time now is 07:59 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.