Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Measuring time lapsed during callouts

Featured Replies

Hey there!

I'm trying to find a way to find a way to measure the time it takes for the player to make their way to the location of the callout from when they accepted it. The problem is I'm having trouble figuring out exactly how to do that. The closest variable and function I found for this task was TimeSpan where it says I can return a TimeSpan that represents a specified number on seconds or minutes but I'm not exactly sure how to use it. Am I on the right track? Any help would be greatly appreciated :)

Cheers!

TimeSpan ts = date2 - date1;

int responseInSeconds = ts.TotalSeconds;

Stealth22
LSPDFR Tester | Plugin Developer
My Plugins: Code 3 Callouts | Traffic Control | Keep Calm | ALPR+

Please do not PM me for any kind of technical support.
I unfortunately do not have enough free time to answer every PM that I get. For issues with my plugins, please post in the comments section of the file, or it's forum thread. You'll get a much quicker response from me there than if you send me a PM; I do my best to respond to every question in the comments sections. For API/programming questions, please post them in the API Development forum, so all developers can benefit from the answer as well. Thanks!

6 hours ago, Stealth22 said:

TimeSpan ts = date2 - date1;

int responseInSeconds = ts.TotalSeconds;

That's actually really smart, I used to just sleep a GameFiber but this is much more efficient :smile:

For the OP: just to clarify the above pseudocode a bit:

DateTime now = DateTime.Now; //when call is accepted
//Wait until the player is at the location
DateTime later = DateTime.Now;
TimeSpan elapsedtime = later - now;
int responsetime = (int)Math.Round(elapsedtime.TotalSeconds);

Hope it helps :smile:

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

If you end up making this, it would be cool if the user could get statistics from it. I don't know if your planning on releasing it with a callout mod or completely standalone to work with all callouts, but things like average response time, slowest and fastest response times and stuff like that would be really neat.

Sorry I can't help with what your doing, I couldn't code to save my life..

3 hours ago, Albo1125 said:

That's actually really smart, I used to just sleep a GameFiber but this is much more efficient :smile:

For the OP: just to clarify the above pseudocode a bit:


DateTime now = DateTime.Now; //when call is accepted
//Wait until the player is at the location
DateTime later = DateTime.Now;
TimeSpan elapsedtime = later - now;
int responsetime = (int)Math.Round(elapsedtime.TotalSeconds);

Hope it helps :smile:

For time calculations I would use DateTime.UtcNow instead of DateTime.Now. Using this approach it will have better performance since it doesn't need to convert the time to the current user time zone, I would use DateTime.Now only for cases where the current time needs to be displayed to the user.(https://blogs.msdn.microsoft.com/kirillosenkov/2012/01/10/datetime-utcnow-is-generally-preferable-to-datetime-now/)
Though probably you won't notice the performance gain unless you need to get the current time lots of times in loop.
 

I don't think the OP will need a better time accuracy for what he wants but in case he needs it, he can use System.Diagnostics.Stopwatch

Stopwatch sw = new Stopwatch();
sw.Start();
//...
sw.Stop();

TimeSpan elapsedTs = sw.Elapsed;
long elapsedMs = sw.ElapsedMilliseconds;
long elapsedTicks = sw.ElapsedTicks;
Just now, alexguirre said:

For time calculations I would use DateTime.UtcNow instead of DateTime.Now. Using this approach it will have better performance since it doesn't need to convert the time to the current user time zone, I would use DateTime.Now only for cases where the current time needs to be displayed to the user.(https://blogs.msdn.microsoft.com/kirillosenkov/2012/01/10/datetime-utcnow-is-generally-preferable-to-datetime-now/)
Though probably you won't notice the performance gain unless you need to get the current time lots of times in loop.
 

I don't think the OP will need a better time accuracy for what he wants but in case he needs it, he can use System.Diagnostics.Stopwatch


Stopwatch sw = new Stopwatch();
sw.Start();
//...
sw.Stop();

TimeSpan elapsedTs = sw.Elapsed;
long elapsedMs = sw.ElapsedMilliseconds;
long elapsedTicks = sw.ElapsedTicks;

There you have it! :biggrin:

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

  • Author

Hey Guys,

Thanks for your responses this has helped me immensely!

I'll be sure to keep in touch on the forums and let you know how things go :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.