Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] SetTimer looping through players with gettime() function

 
  • 0 Vote(s) - 0 Average
Pawn SetTimer looping through players with gettime() function
unix
Offline

Burgershot Member
Posts: 20
Threads: 5
Joined: Apr 2019
Reputation: 1
Location: Kosovo
#1
2019-07-09, 10:40 AM (This post was last modified: 2021-04-24, 02:16 AM by unix.)
-delete
Cada
Offline

Burgershot Member
Posts: 11
Threads: 2
Joined: Apr 2019
Reputation: 0
#2
2019-07-09, 01:54 PM (This post was last modified: 2019-07-09, 02:13 PM by Cada.)
1. first Checker call time - second Checker call time != 1.

2. i think the result will be changed as initial value of TickChecker[0].

gettime() | TickChecker[0]
[23:08:45] 1562681325 1562681327
[23:08:45] [dbg] Sent checkertick
[23:08:46] 1562681326 1562681327
[23:08:46] [dbg] Sent checkertick
[23:08:47] 1562681327 1562681328
[23:08:47] [dbg] Sent checkertick
[23:08:48] 1562681328 1562681329
[23:08:48] [dbg] Sent checkertick
[23:08:49] 1562681329 1562681330
[23:08:49] [dbg] Sent checkertick
[23:08:50] 1562681330 1562681331
[23:08:50] [dbg] Sent checkertick
[23:08:52] 1562681332 1562681332
[23:08:53] 1562681333 1562681332
[23:08:54] 1562681334 1562681332
[23:08:55] 1562681335 1562681332
[23:08:56] 1562681336 1562681332
[23:08:58] 1562681337 1562681332
[23:08:58] 1562681338 1562681332

this happens because next TickChecker[0]`s value is based on pre gettime(), and this not mean +2 seconds
unix
Offline

Burgershot Member
Posts: 20
Threads: 5
Joined: Apr 2019
Reputation: 1
Location: Kosovo
#3
2019-07-09, 01:57 PM
(2019-07-09, 01:54 PM)Cada Wrote: gettime(&hour=0,&minute=0,&second=0)

your function usage is wrong

No it is not wrong, if not using the syntax inside the function it returns the year,hour,month,second,day in seconds e.g 15206501548
unix
Offline

Burgershot Member
Posts: 20
Threads: 5
Joined: Apr 2019
Reputation: 1
Location: Kosovo
#4
2019-07-11, 10:31 AM
Anyone?
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#5
2019-07-13, 06:38 PM
You have a 0 element array. I'm surprised that code even compiles.
unix
Offline

Burgershot Member
Posts: 20
Threads: 5
Joined: Apr 2019
Reputation: 1
Location: Kosovo
#6
2019-07-17, 08:43 PM
(2019-07-13, 06:38 PM)Y_Less Wrote: You have a 0 element array.  I'm surprised that code even compiles.

I have tried without a 0 element array although, still having the same problem. :(
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#7
2019-07-21, 07:27 PM
It could be crashing. It's hard to say without the rest of the code. Have you run this with crashdetect active?
fusez
Offline

Burgershot Member
Posts: 6
Threads: 2
Joined: Jul 2019
Reputation: 0
Location: Sweden
#8
2019-07-23, 11:10 PM
This is how i would solve the problem.
I didn't try compiling it but it should work, let me know.

Code:
#define CHECKER_EXEC_INTERVAL_S     2
#define CHECKER_TIMER_INTERVAL_MS 1000

new nextCheckerTime;

public OnGameModeInit()
{
   SetTimer("Checker", CHECKER_TIMER_INTERVAL_MS, true);
}

forward Checker();
public Checker()
{
   prinft("[DEBUG] Checker(): gettime() = %i, nextCheckerTime = %i", gettime(), nextCheckerTime);

   if( gettime() >= nextCheckerTime )
   {
       print("[DEBUG] Checker(): gettime() >= nextCheckerTime");
       // do shit here..
       nextCheckerTime = gettime() + CHECKER_EXEC_INTERVAL_S ; // Apply the next time value to this variable. When gettime() exceeds or equals this value the code within these brackets will be called again.
   }
}
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode