Issue with timer
#7

That's strange, unless you have some modifications over your timer functions. Make sure if your "StoreRobbery" callback is being called only within the timer. In case if it's being called somewhere else, it could be a reason. You can either check through your whole code or simply change it to something else.


Quote:
Originally Posted by FunnyBear
Посмотреть сообщение
I followed what you suggested, and it seems to work but only on the second time you press the key; I pressed the key once and the timer started but continued very slowly, I pressed it again, and it continued at its normal pace.

Код:
if(newkeys & KEY_WALK)
	{
		for(new i = 0; i != sizeof(storeData); ++i)
		{
		    if(IsPlayerInRangeOfPoint(playerid, 1.0, storeData[i][cpPos][0],  storeData[i][cpPos][1], storeData[i][cpPos][2]))
		    {
                if( storeData[i][virtualID] == GetPlayerVirtualWorld(playerid) )
                {
					if( robTimer[playerid] != -1 )
					{
						SendClientMessage(playerid, -1, "You have begun a robbery");
     					robTimer[playerid] = SetTimerEx("StoreRobbery", 1000, true, "i", playerid);
					}
				}
		    }
		}
	}
The timer will not be affected on your second button press turn because as per the code, robTimer is not equal to -1 once the key is pressed and so it cannot call the timer again. Do note that time delays are not completely efficient. The do have some variations. You can check for "timerfix" plugin which almost fixes this issue.

PS : Check if the timer is running under the first if statement of the code you've given here. You don't have to simply loop around your storeData array each time the key is pressed.
Reply


Messages In This Thread
Issue with timer - by FunnyBear - 18.12.2016, 22:47
Re: Issue with timer - by Luicy. - 19.12.2016, 00:05
Re: Issue with timer - by FunnyBear - 19.12.2016, 01:35
Re: Issue with timer - by Lordzy - 19.12.2016, 07:00
Re: Issue with timer - by Luicy. - 19.12.2016, 08:18
Re: Issue with timer - by FunnyBear - 19.12.2016, 12:11
Re: Issue with timer - by Lordzy - 19.12.2016, 12:26
Re: Issue with timer - by SickAttack - 19.12.2016, 13:45
Re: Issue with timer - by Lordzy - 19.12.2016, 14:09
Re: Issue with timer - by SickAttack - 19.12.2016, 14:11

Forum Jump:


Users browsing this thread: 1 Guest(s)