SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 20/05/2019, 08:04 AM   #1
Misiek
Big Clucker
 
Join Date: May 2006
Posts: 111
Reputation: 15
Default samp-precise-timers ⌚: A timer plugin written in the memory-safe Rust language. Check it out, you might like Rust!

Briefly
Developed for net4game.com (RolePlay), this SA-MP plugin provides precise timers for the server. It is written in Rust, a memory-safe language.

Why rewrite timers?
I had a lot of safety concerns with some of the existing solutions. They weren't written with data integrity, memory safety or preventing server crashes in mind and seemed to have quite a few bugs. As privacy and safety is our primary concern at net4game, I wrote this in Rust, which combines high-level ergonomics with the performance of a low-level language. ⚡

Please check out the code to see the benefits. You might like Rust a lot. The code is much simpler than C++ equivalents, especially the ones which still use *char, free() and delete[] instead of modern C++ idioms such as std::unique_ptr, but as Rust has no runtime, there is no overhead 😉

We would like your help! 💃
Oh, and if you enjoy working on servers, we are looking for a team to help our international expansion. 🎉 net4game has been around for a decade as the biggest Polish server. We introduced a lot of innovations over the years and we are almost ready to become international. Shoot me an e-mail at bm+code@net4game.com if you're interested.

Downloads on GitHub
Also available on sampctl:
Code:
bmisiak/samp-precise-timers
__________________
Ex-SA-MP beta tester 😉
net4game.com

Last edited by Misiek; 21/05/2019 at 05:53 PM.
Misiek is offline   Reply With Quote
Old 20/05/2019, 09:09 PM   #2
cSharp
Big Clucker
 
Join Date: Oct 2018
Posts: 64
Reputation: 13
Default Re: samp-precise-timers ⌚: A timer plugin written in the memory-safe Rust language. Check it out, you might like Rust!

<3

The message you have entered is too short. Please lengthen your message to at least 4 characters.
__________________
cSharp is offline   Reply With Quote
Old 21/05/2019, 12:23 PM   #3
Mobtiesgangsa
Big Clucker
 
Join Date: Oct 2016
Location: Somewhere in San Fierro near Binco.
Posts: 101
Reputation: 16
Default Re: samp-precise-timers ⌚: A timer plugin written in the memory-safe Rust language. Check it out, you might like Rust!

Great respect for u polish developers for presenting such a unique plugin, as soon as reach my destination I might give a try, BTW great introduction of your release +rep:
__________________

this thread seems to amaze me
Quote:
Bolex_
Good question, simply when a reaction test appear you'r are going to type randm numbers and earn some cash & money!
Me: Earn some cash and Money hahahahahahah, or maybe Dolars and Euros XD
Mobtiesgangsa is offline   Reply With Quote
Old 21/05/2019, 04:27 PM   #4
Chaprnks
Gangsta
 
Chaprnks's Avatar
 
Join Date: Sep 2007
Location: Soviet America
Posts: 568
Reputation: 69
Default Re: samp-precise-timers ⌚: A timer plugin written in the memory-safe Rust language. Check it out, you might like Rust!

Do you know if this is compatible with y_timers?
__________________
Chaprnks is offline   Reply With Quote
Old 21/05/2019, 06:06 PM   #5
Misiek
Big Clucker
 
Join Date: May 2006
Posts: 111
Reputation: 15
Default Re: samp-precise-timers ⌚: A timer plugin written in the memory-safe Rust language. Check it out, you might like Rust!

Quote:
Originally Posted by Chaprnks View Post
Do you know if this is compatible with y_timers?
Yeah, it is fully compatible with y_timers. The plugin defines two new natives:
Code:
/* 
    # SetPreciseTimer returns timer_number, or 0 on failure.
        interval: miliseconds before the callback is triggered.
        repeat:  true/false. If false, the callback will only be called once.

    # Examples:
    SetPreciseTimer("EveryMinute",60000,true);
    SetPreciseTimer("EverySecond",1000,true,"ds",playerid,"Hello");
    new array[2] = {42,2}; SetPreciseTimer("AfterFiveSecs",5000,false,"dsaA",playerid,"world",array,sizeof(array));
*/
native SetPreciseTimer(const callback_name[], const interval, const repeat, const types_of_arguments[]="", {Float,_}:...);

/* 
    Returns 1 if the timer existed or 0 on failure.
*/
native DeletePreciseTimer(const timer_number);
The argument syntax is compatible with SetTimerEx.

Quote:
Originally Posted by Mobtiesgangsa View Post
Great respect for u polish developers for presenting such a unique plugin, as soon as reach my destination I might give a try, BTW great introduction of your release +rep:
Thank you. I tried to make the code easy to understand. Give it a go, I would love to get some feedback 😊
__________________
Ex-SA-MP beta tester 😉
net4game.com
Misiek is offline   Reply With Quote
Old 21/05/2019, 07:36 PM   #6
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,183
Reputation: 384
Default Re: samp-precise-timers ⌚: A timer plugin written in the memory-safe Rust language. Check it out, you might like Rust!

Quote:
Originally Posted by Misiek View Post
Yeah, it is fully compatible with y_timers. The plugin defines two new natives:
Code:
/* 
    # SetPreciseTimer returns timer_number, or 0 on failure.
        interval: miliseconds before the callback is triggered.
        repeat:  true/false. If false, the callback will only be called once.

    # Examples:
    SetPreciseTimer("EveryMinute",60000,true);
    SetPreciseTimer("EverySecond",1000,true,"ds",playerid,"Hello");
    new array[2] = {42,2}; SetPreciseTimer("AfterFiveSecs",5000,false,"dsaA",playerid,"world",array,sizeof(array));
*/
native SetPreciseTimer(const callback_name[], const interval, const repeat, const types_of_arguments[]="", {Float,_}:...);

/* 
    Returns 1 if the timer existed or 0 on failure.
*/
native DeletePreciseTimer(const timer_number);
The argument syntax is compatible with SetTimerEx.


Thank you. I tried to make the code easy to understand. Give it a go, I would love to get some feedback 😊
I thought we were unable to pass strings through the settimer function, does that mean your plugin fixes it?
__________________
Quote:
Originally Posted by Andy
I offer paid scripting services, I can do anything except mapping because fuck mapping.

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link


RogueDrifter is offline   Reply With Quote
Old 22/05/2019, 12:06 AM   #7
nickdodd25
Huge Clucker
 
nickdodd25's Avatar
 
Join Date: Jan 2012
Location: Unknown
Posts: 443
Reputation: 109
Default Re: samp-precise-timers ⌚: A timer plugin written in the memory-safe Rust language. Check it out, you might like Rust!

Quote:
Originally Posted by RogueDrifter View Post
I thought we were unable to pass strings through the settimer function, does that mean your plugin fixes it?
Fairly certain that you can pass a string as long as it is not empty. Kind of like CallRemote/LocalFunction.
__________________
Nick
nickdodd25 is offline   Reply With Quote
Old 22/05/2019, 12:20 AM   #8
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,183
Reputation: 384
Default Re: samp-precise-timers ⌚: A timer plugin written in the memory-safe Rust language. Check it out, you might like Rust!

Quote:
Originally Posted by nickdodd25 View Post
Fairly certain that you can pass a string as long as it is not empty. Kind of like CallRemote/LocalFunction.
https://wiki.sa-mp.com/wiki/SetTimerEx

Quote:
Originally Posted by Wiki.sa-mp
Specifier Meaning
i Integer.
d Integer.
a Array. The next parameter must be an integer ("i") with the array's size. [CURRENTLY UNUSABLE]
s String. [CURRENTLY UNUSABLE]
f Float.
b Boolean (true/false).
Are you sure?
__________________
Quote:
Originally Posted by Andy
I offer paid scripting services, I can do anything except mapping because fuck mapping.

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link


RogueDrifter is offline   Reply With Quote
Old 22/05/2019, 11:34 AM   #9
kocurek
Little Clucker
 
Join Date: Dec 2017
Posts: 1
Reputation: 0
Default Re: samp-precise-timers ⌚: A timer plugin written in the memory-safe Rust language. Check it out, you might like Rust!

great plugin!

but, will you add IsValidPreciseTimer and SetPreciseTimerInterval?
kocurek is offline   Reply With Quote
Old 22/05/2019, 08:11 PM   #10
MisterTickle
Huge Clucker
 
MisterTickle's Avatar
 
Join Date: Jul 2007
Posts: 366
Reputation: 70
Default Re: samp-precise-timers ⌚: A timer plugin written in the memory-safe Rust language. Check it out, you might like Rust!

Going to go ahead and implement this. Good job.
__________________
MisterTickle is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tool/Web/Other] Rust SA:MP SDK EvaBaka Plugin Development 12 15/03/2018 10:59 PM
Rust On 4GB RAM K0P Everything and Nothing 20 28/12/2016 12:34 AM
[Projeto] San Andreas Rust (DayZ/Rust/Survival) JPedro Português/Portuguese 38 15/10/2015 02:31 AM
[Off] Rust para SA-MP PratesPlay Português/Portuguese 17 27/02/2014 07:29 PM


All times are GMT. The time now is 12:58 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.