Raised This Month: $51 Target: $400
 12% 

Timer Order


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
minimoney1
SourceMod Donor
Join Date: Dec 2010
Old 09-23-2012 , 03:34   Timer Order
Reply With Quote #1

Hey, I had a question.
I'm trying to reprint a usermessage, so I block the original and reprint one through a timer.
But having hooked TextMsg, there may be times in which multiple messages get fired at the same frame, in which timers get created with the same interval, and that's where my question comes.
What determines the timer order?
I talked to dvander about this on IRC, he said:
Code:
[23:37] <dvander`home> minimoney1: the order timers occur in is not defined
Which makes me wonder how I can get around this.
Example: Something like this http://pastebin.com/iGQJ62Qb
Prints this:
3
2
1
__________________
Need help? PM me or add me on Steam.
My Steam




Quote:
Originally Posted by Rp.KryptoNite View Post
For some reason his Plugin never worked for me ,
@credits were added
im not stealing any plugins dude its my THING
minimoney1 is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 09-23-2012 , 10:08   Re: Timer Order
Reply With Quote #2

Well, the solution is pretty simple, don't leave the ordering to the timer system.
Use your own queue (a string array). When you put something into the queue, you can use OnGameFrame with a bool variable, to check if there are any new entries in the queue, and print them. If you wish you can also use a 0.1 seconds timer.
That would also eliminate the need to create timer for every message.

Have you already tried using a usermessage POST hook ? I assume that you can print messages there without having to create a timer.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
minimoney1
SourceMod Donor
Join Date: Dec 2010
Old 09-23-2012 , 14:40   Re: Timer Order
Reply With Quote #3

Quote:
Originally Posted by berni View Post
Well, the solution is pretty simple, don't leave the ordering to the timer system.
Use your own queue (a string array). When you put something into the queue, you can use OnGameFrame with a bool variable, to check if there are any new entries in the queue, and print them. If you wish you can also use a 0.1 seconds timer.
That would also eliminate the need to create timer for every message.

Have you already tried using a usermessage POST hook ? I assume that you can print messages there without having to create a timer.
Yeah, I was hoping I wasn't going to have to do that, but it seems way more reliable (i.e 0.1 interval isn't the next tick while OnGameFrame can do that)
Thanks for the solution.

EDIT: No I haven't tried using a post hook. Let me give that a try.
__________________
Need help? PM me or add me on Steam.
My Steam




Quote:
Originally Posted by Rp.KryptoNite View Post
For some reason his Plugin never worked for me ,
@credits were added
im not stealing any plugins dude its my THING

Last edited by minimoney1; 09-23-2012 at 14:41.
minimoney1 is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 04:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode