SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 16/11/2014, 09:54 PM   #11
jamjamnewbie
Little Clucker
 
Join Date: Jul 2013
Location: My home, Philippines
Posts: 32
Reputation: 7
Default Re: MySQL - Event scheduler

What the.. This is the first time I've seen this function

Code:
mysql_tquery(connectionHandler,
"CREATE EVENT `unbanall` ON SCHEDULE AT CURRENT_TIMESTAP() + INTERVAL 1 DAY \
DO \
UPDATE `mybans` SET `banSTATUS`=0", "", "");
//After 1 day, every bans will be expired from my table.
//Even if the server is shut down, this schedule will be running as long as MySQL server is up and if the event is enabled.
TIMESTAP or TIMESTAMP?

Anyways, good tutorial, can be used for many things, I know
__________________
jamjamnewbie is offline   Reply With Quote
Old 16/11/2014, 09:55 PM   #12
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,524
Reputation: 437
Default Re: MySQL - Event scheduler

TIMESTAMP, - probably just a typo. I could be wrong though.
Abagail is offline   Reply With Quote
Old 17/11/2014, 01:01 AM   #13
Lordzy
High-roller
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,767
Reputation: 1161
Default Re: MySQL - Event scheduler

Quote:
Originally Posted by Abagail View Post
Will something like this work?
Code:
new query[100];
new interval[30];
format(interval, sizeof(interval), "1 DAY");
mysql_format(connectionHandler, query, sizeof(query),
"CREATE EVENT `unbanall` ON SCHEDULE AT CURRENT_TIMESTAP() + INTERVAL '%s' \
DO \
UPDATE `mybans` SET `banSTATUS`=0", interval);

You seem to be an expert on this function, and I can't find anything relevant on the documentation page.
Yes it will work because the output query would look like : CREATE EVENT `unbanall` ON SCHEDULE AT CURRENT_TIMESTAMP() + INTERVAL 1 DAY DO UPDATE `mybans` SET `banSTATUS`=0
Though, I believe query's size should be increased.

NOTE : It's CURRENT_TIMESTAMP, not TIMESTAP because I had a little typo on my main post.


Quote:
Originally Posted by jamjamnewbie View Post
What the.. This is the first time I've seen this function


Code:
mysql_tquery(connectionHandler,
"CREATE EVENT `unbanall` ON SCHEDULE AT CURRENT_TIMESTAP() + INTERVAL 1 DAY \
DO \
UPDATE `mybans` SET `banSTATUS`=0", "", "");
//After 1 day, every bans will be expired from my table.
//Even if the server is shut down, this schedule will be running as long as MySQL server is up and if the event is enabled.
TIMESTAP or TIMESTAMP?

Anyways, good tutorial, can be used for many things, I know
It's CURRENT_TIMESTAMP. STAP was little typo there.
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.
Lordzy is offline   Reply With Quote
Old 17/11/2014, 01:07 AM   #14
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,524
Reputation: 437
Default Re: MySQL - Event scheduler

Quote:
Originally Posted by Lordzy View Post
Yes it will work because the output query would look like : CREATE EVENT `unbanall` ON SCHEDULE AT CURRENT_TIMESTAMP() + INTERVAL 1 DAY DO UPDATE `mybans` SET `banSTATUS`=0
Though, I believe query's size should be increased.

NOTE : It's CURRENT_TIMESTAMP, not TIMESTAP because I had a little typo on my main post.




It's CURRENT_TIMESTAMP. STAP was little typo there.
Thank you for clarifying this. Another question though, is this a new MySQL / phpmyadmin feature? I don't seem to see it on my phpMyAdmin, is this just a matter of updating it?
Abagail is offline   Reply With Quote
Old 17/11/2014, 01:13 AM   #15
Lordzy
High-roller
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,767
Reputation: 1161
Default Re: MySQL - Event scheduler

Quote:
Originally Posted by Abagail View Post
Thank you for clarifying this. Another question though, is this a new MySQL / phpmyadmin feature? I don't seem to see it on my phpMyAdmin, is this just a matter of updating it?
The event scheduler system had been supported since MySQL 5.1. You should also make sure if the user you use has got privileges to use "Events". Or else simply create an event using SQL command and then it might appear on as a tab. Also note that you should click on your database to view Events.
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.
Lordzy is offline   Reply With Quote
Old 17/11/2014, 01:14 AM   #16
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,524
Reputation: 437
Default Re: MySQL - Event scheduler

The last one was the one I needed. Thanks for the fast reply.
If I have any time tommorow I may make a temporary ban system using events(I coded one without using events a few days ago).

Cheers!
Abagail is offline   Reply With Quote
Old 17/11/2014, 07:33 AM   #17
Raefal
Big Clucker
 
Join Date: Feb 2014
Location: Indonesia
Posts: 124
Reputation: 2
Default Re: MySQL - Event scheduler

Nice tutorial i need it for delete unused character!, Thanks.
Raefal is offline   Reply With Quote
Old 17/11/2014, 12:41 PM   #18
RajatPawar
High-roller
 
RajatPawar's Avatar
 
Join Date: Aug 2011
Location: ヽ༼ຈل͜ຈ༽ノ
Posts: 2,289
Reputation: 311
Default Re: MySQL - Event scheduler

Nice! And thank you for the credits

You could add some more information about auto-backing up (which is also there in my topic) if we are on the topic of periodic functions!
RajatPawar is offline   Reply With Quote
Old 17/11/2014, 02:22 PM   #19
Lordzy
High-roller
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,767
Reputation: 1161
Default Re: MySQL - Event scheduler

Quote:
Originally Posted by RajatPawar View Post
Nice! And thank you for the credits

You could add some more information about auto-backing up (which is also there in my topic) if we are on the topic of periodic functions!
I thought about adding an example of automatic backups but since it's a tutorial in regarding event scheduler of MySQL, I thought to explain more regarding the scheduler. I might consider creating a tutorial using the same method for automatic backups of tables later. I should actually add some more about this topic because it's a shame that I've forgotten to add the methods of listing events through SQL commands and dropping down events if not needed, through queries.

I will be adding some more information regarding this when I'm getting some free time.
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.
Lordzy is offline   Reply With Quote
Old 17/11/2014, 02:26 PM   #20
CoaPsyFactor
Gangsta
 
Join Date: Jul 2010
Location: Belgrade, Serbia
Posts: 879
Reputation: 47
Default Re: MySQL - Event scheduler

you should create tutorial for TRASACTION and ROLLBACK
__________________
Quote:
Originally Posted by ThaiLuan View Post
Code:
C:\Users\Administrator\Downloads\Viet-RP\gamemodes\3mien.pwn(112016) : fatal error 101: cannot write to file: "disk full"

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Help me! How to fix error
CoaPsyFactor 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
[FilterScript] Rajat's Event system! (Lockable, Event wins, guns) RajatPawar Filterscripts 14 07/03/2015 06:30 PM
[FilterScript] S-Event (Advanced Event System) marcelodell Lançamentos/Releases 54 12/04/2014 03:54 AM
Task scheduler Dragony92 Scripting Help 4 17/02/2012 12:35 AM
How to make /event start an actual event Snowman12 Help Archive 7 03/04/2011 11:39 PM


All times are GMT. The time now is 04:32 AM.


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