View Full Version : TrinityCore 3.3.5 Do something in X time

07-21-2016, 09:49 PM
Hey, what's up.

I'm making a script and I'm implementing QueryResult, so, when the QueryResult returns X value, the script will delete a row inside the db after 2 hours.

Is simple, QueryResult returns 5 (for ex), if (result == 5) delete row from table after 2 hours.

I hope u can help me.


07-21-2016, 11:12 PM
Could we have more info on what you are deleting? Might help with the process of thinking up the right code to place this in.

07-21-2016, 11:20 PM
Well, I have "onPVPkill" function. So, it will increase a field in the table and if the field == 5 (field + 1), it will block the users join to queue bg.

It works properly, but it will be forever if i don't delete the row, so I wanna delete the row after 2 hours from the fields gets 5.

if(nivelFarmeo >= 4){
WorldDatabase.PExecute("DELETE FROM `antifarm_sys` WHERE `nombreKiller`='%s' AND `nombreKilled`='%s'", pjKiller, pjKilled);


I tried with "Sleep" but it seems the server crashes for 1 minute, and then returns to normal.

07-21-2016, 11:40 PM
Sleep freezes the server until it is released. Not at all the recommended thing to do. So what I got from this is: When the player reaches 5 kills (or whatever "nivelFarmeo" is) you want to prevent them from joining a battleground queue for 2 hours?

07-21-2016, 11:49 PM
EXACTLY. That's what I want to do.

yeah, i know sleep freeze the server. I was so confused, I thought it was a coding error.

07-22-2016, 05:03 AM
You can use a BasivEvent for such things, i've got a template on my Pastebin account. You can find it here: http://pastebin.com/w0EBXif7

4000 milliseconds is the time when the event will occur and the code in the Execute function is the code that will be executed.

(@Tommy: You can add this to the template thread if you want)

07-22-2016, 06:47 PM
How can I implement this to a Delete Query inside my .cpp file?

I wanna do something like:

if(nivelFarmeo == 5){

Yes, I know I have the code, but, where I need to write that?