A cron plugin for samp/open.mp in Rust. Made using this library
- Download suitable binary files from releases for your operating system.
- Add it to your
plugins
folder - Add
samp_cron
to server.cfg (config.json if you're using open.mp) orsamp_cron.so
(for linux) - Add samp_cron.inc in includes folder
- Clone the repo
git clone https://github.com/Tiaansu/samp-cron.git
- Install Rust
rustup update stable-i686 --no-self-update && rustup default stable-i686
- Build using
cargo build
cargo build --release
Important
Here's the scheduling format
You must follow it to work
sec min hour day of month month day of week year
* * * * * * *
-
pattern[]
- cron patterncallback[]
- callback to execute every callargs[]
- custom arguments
Returns
the cron job idExample
new CRON:cron_id = INVALID_CRON_ID; main() { cron_id = cron_new("* * * * * *", "SecondTimer", "i", 5); } forward SecondTimer(); public SecondTimer() { printf("Hi! I am called by cron id: %i and I also have a custom args: %i!", _:cron_id, num); }
-
id
- id of cron job
Returns
true - valid
false - invalidExample
new CRON:cron_id = INVALID_CRON_ID; main() { printf("Is cron job id %i valid? %i", _:cron_id, cron_is_valid(cron_id)); }
-
id
- id of cron job
Returns
true - succeed
false - failedExample
new CRON:cron_id = INVALID_CRON_ID, current = 0; main() { cron_id = cron_new("* * * * * *", "SecondTimer"); } forward SecondTimer(); public SecondTimer() { if (++ current <= 10) { printf("%i/10", current + 1); } else { printf("Is cron job id %i deleted? %i", _:cron_id, cron_delete(cron_id)); } }
Note
Most of the part of this README is from/based on samp-bcrypt
I'm open for suggestions and corrections as I'm still learning Rust.