User Tag List

Results 1 to 7 of 7

Thread: Do something in X time

  1. #1
    Member
    Join Date
    Jul 2016
    Posts
    33
    XP
    370
    Level
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Do something in X time

    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

  2. #2
    Founder <span style='color: #FF4500'>Tommy</span>'s Avatar
    Join Date
    Apr 2013
    Posts
    7,391
    XP
    3,449,104
    Level
    378
    Thanks
    889
    Thanked 1,858 Times in 1,120 Posts
    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.

  3. #3
    Original Poster
    Member
    Join Date
    Jul 2016
    Posts
    33
    XP
    370
    Level
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  4. #4
    Founder <span style='color: #FF4500'>Tommy</span>'s Avatar
    Join Date
    Apr 2013
    Posts
    7,391
    XP
    3,449,104
    Level
    378
    Thanks
    889
    Thanked 1,858 Times in 1,120 Posts
    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?

  5. #5
    Original Poster
    Member
    Join Date
    Jul 2016
    Posts
    33
    XP
    370
    Level
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  6. #6
    Super Moderator <span style='color: #FFFF00'><span class='glow_000000'>Kaev</span></span>'s Avatar

    Join Date
    Jan 2014
    Location
    Germany
    Posts
    535
    XP
    2,925,342
    Level
    335
    Thanks
    76
    Thanked 102 Times in 70 Posts
    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 by Kaev; 07-22-2016 at 05:06 AM.
    Achievements:
    Shopper Member 1 year registered Level XL Level C
    Awards:
    Raffle Winner Member of Staff Support LOL Drunk Donator


    Read the rules before posting.

    Do you have an unsolved issue? Give us more informations about your problem.

    Do you have problems with compiling or installing TrinityCore? Unknown96's Tutorial will help you.

    Visit our other helpful sites:
    EmuDevs SQL Generator

  7. #7
    Original Poster
    Member
    Join Date
    Jul 2016
    Posts
    33
    XP
    370
    Level
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •