• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

TrinityCore 3.3.5 Do something in X time

zhier

Member
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.

Regards
 

Tommy

Founder
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.
 

zhier

Member
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.

Code:
if(nivelFarmeo >= 4){
						Sleep(60000);
						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.
 

Tommy

Founder
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?
 

zhier

Member
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.
 

Kaev

Super Moderator
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)
 
Last edited:

zhier

Member
How can I implement this to a Delete Query inside my .cpp file?

I wanna do something like:

Code:
if(nivelFarmeo == 5){
   //WAIT 2 HOURS
   //DELETE SQL ROW
}

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

Thanks
 
Top