19.12.2016, 12:26
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.
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.
Quote:
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); } } } } } |
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.