PDA

View Full Version : Toll Bug


BeesSi
25/03/2015, 11:43 PM
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..


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;
}



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;
}




forward ShowAgain(playerid);
public ShowAgain(playerid)
{
return cmd_kufini(playerid, " ");
}

BeesSi
25/03/2015, 11:54 PM
Bump..

SickAttack
25/03/2015, 11:55 PM
Why are you even using OnPlayerUpdate for this? It's really unnecessary.

And this will be setting a timer every 20 milliseconds (overlapping):
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;
}

BeesSi
25/03/2015, 11:57 PM
Because i want when the player gets near the range of point . It will show the dialog. It'll be like an automatic gate..

SickAttack
26/03/2015, 12:05 AM
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.