Delay Command menu

Shout-Out

User Tag List

Results 1 to 6 of 6
  1. #1
    4BOLTMAIN's Avatar Sergeant
    Reputation
    2
    Join Date
    Dec 2010
    Posts
    63
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Delay Command

    I want to delay a player port function by 1 second so the player will see a cosmetic spell visual before they port.

    What is the function to do this for Trinity core?
    Last edited by 4BOLTMAIN; 04-23-2011 at 10:36 PM.

    Delay Command
  2. #2
    SpellEffects's Avatar Sergeant
    Reputation
    64
    Join Date
    Apr 2011
    Posts
    69
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    uint32 Timer = 3000; //3000 = 3 seconds
    if (Timer <= uiDiff) {
    	//Do stuff here
    }
    Not really sure, but I think this might do the trick.

  3. #3
    4BOLTMAIN's Avatar Sergeant
    Reputation
    2
    Join Date
    Dec 2010
    Posts
    63
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What should I define uiDiff as ?

    Here is the code I am using now, the wait function I found using google but I have heard that this will sleep the entire thread that updates units on the map. I should use a delayed execution instead but I have no idea how to do that.

    This is my generic game object script that needs to be changed.


    Code:
    #include "ScriptPCH.h"
    
    
    void wait(unsigned int mseconds)    // This is the function I would like changed, this is no good.
    {
            clock_t goal = mseconds + clock();
            while (goal > clock());
    } 
    
    class generic_gobject : public GameObjectScript
    {
            public: generic_gobject(): GameObjectScript("generic_gobject") {}
    
        bool OnGossipHello(Player* player, GameObject* gameobject)
        {
                    
                    uint32 nNowait = 0, sSpell1 = 54190, sSpell2 = 52096, mMap = 1, wWait1 = 80, wWait2 = 900;
                    float xCoord = 0.0f, yCoord = 0.0f, zCoord = 0, oOrient = 0.0f;
                                    
                    switch (gameobject->GetEntry())  //determine what game object was used
                            {
                            case 2: //Shattrath Portal to Dalaran gob entry
                                    if (player->getLevel() <= 79)
                                    {
                                            //player is not level 80 do not port
                                            player->GetSession()->SendNotification("You must reach level 80 to use this portal.");
                                            return false;
                                    }
                                    else
                                    {
                                            nNowait = 1;
                                            mMap = 571;
                                            xCoord = 5820.606f;
                                            yCoord = 544.037f;
                                            zCoord = 652.932f;
                                            oOrient = 1.858341f;
                                    }
                                    break;
    
                            case 3: //Shattrath Orb of Teleportation gob entry
                                    mMap = 530;
                                    xCoord = -1823.818f;
                                    yCoord = 5350.067f;
                                    zCoord = -11.428f;
                                    oOrient = 5.154526f;
                                    break;
    
                            case 4: //Dalaran Orb of Teleportation gob entry
                                    mMap = 571;
                                    xCoord = 5820.606f;
                                    yCoord = 544.037f;
                                    zCoord = 652.932f;
                                    oOrient = 1.858341f;
                                    break;
    
                            case 6: //Thunder Bluff Orb of Teleportation gob entry
                                    xCoord = -1276.706f;
                                    yCoord = 124.102f;
                                    zCoord = 132.266f;
                                    oOrient = 5.466212f;
                                    break;
    
                            case 7: //Iron Forge Orb of Teleportation gob entry
                                    mMap =0;
                                    xCoord = -4937.491f;
                                    yCoord = -935.506f;
                                    zCoord = 504.144f;
                                    oOrient = 5.411f;
                                    break;
    
                            case 8: //Hyjal Teleporter (Hyjal Entrance) gob entry
                                    if (player->getLevel() <= 79)
                                    {
                                            //player is not level 80 do not port
                                            player->GetSession()->SendNotification("You must reach level 80 to use this portal.");
                                            return false;
                                    }
                                    else if (player->HasAura(54643))
                                    {
                                            //player player has recently teleported do not port
                                            player->GetSession()->SendNotification("You are unable to teleport right now.");
                                            return false;
                                    }
                                    else
                                    {
                                            xCoord = 4612.435f;
                                            yCoord = -3862.041f;
                                            zCoord = 944.936f;
                                            oOrient = 1.071263f;
                                            sSpell2 = 54643;  // add teleport buff to player
                                    }
                                    break;
    
                            case 9: //Island Orb of Teleportation gob entry
                                    xCoord = 16200.689f;
                                    yCoord = 16206.03f;
                                    zCoord = 1.142f;
                                    oOrient = 1.563672f;
                                    break;
    
                            case 10: //Winterspring Teleporter (Hyjal Exit) gob entry
                                    if (player->HasAura(54643))
                                    {
                                            //player player has recently teleported do not port
                                            player->GetSession()->SendNotification("You are unable to teleport right now.");
                                            return false;
                                    }
                                    else
                                    {
                                    xCoord = 4560.639f;
                                    yCoord = -3935.394f;
                                    zCoord = 943.289f;
                                    oOrient = 4.200279f;
                                    sSpell2 = 54643;  // add teleport buff to player
                                    }
                                    break;
    
                            case 11: //Ratchet Orb of Teleportation gob entry
                                    xCoord = -894.037f;
                                    yCoord = -3773.568f;
                                    zCoord = 12.479f;
                                    oOrient = 2.432517f;
                                    break;
    
                            case 12: //Booty Bay Orb of Teleportation gob entry
                                    mMap = 0;
                                    xCoord = -14446.071f;
                                    yCoord = 513.053f;
                                    zCoord = 27.333f;
                                    oOrient = 4.620865f;
                                    break;
    
                            case 14: //Wintergrasp Orb of Teleportation gob entry
                                    mMap = 571;
                                    xCoord = 5050.265f;
                                    yCoord = 2845.859f;
                                    zCoord = 394.149f;
                                    oOrient = 6.242441f;
                                    break;
    
    						case 17: //Argent Tournament Grounds Orb of Teleportation gob entry
    								mMap = 571;
    								xCoord = 8347.061f;
    								yCoord = 801.276f;
    								zCoord = 545.257f;
    								oOrient = 6.116282f;
    								break;
    
                            default:
                            break;
    						}
    
                    if (xCoord == 0)  //no port location set, do nothing
                    {
                            return true;
                    }
                    else
                    {
                            if (nNowait == 1) // Player used portal in Shattrath keep the port blizzlike.
                            {
                                    player->CastSpell(player, sSpell2, true);
                            }
                            else
                            {
                                    player->CastSpell(player, sSpell1, true);
                                   wait(wWait1);
    								
                                    player->CastSpell(player, sSpell2, true);
                                   wait(wWait2);
                            }
                            
                            player->TeleportTo(mMap, xCoord, yCoord, zCoord, oOrient);
                            return false;   
                    }
            }
    };
    
    void AddSC_generic_gobject()
    {
        new generic_gobject();
    }
    Basically what this does is allows me to use one script for various teleporter game objects. Eventually this code will grow bigger as I add more custom objects to my server but for now I would just like the wait function changed to pause the port the 'correct' way.

  4. #4
    DrakeFish's Avatar Lazy Leecher

    Reputation
    634
    Join Date
    Nov 2008
    Posts
    569
    Thanks G/R
    0/14
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think it's a good idea to put a loop like this in a private server code. Depending on how it handles it you could make it freeze a part of the server for the time you're making it sleep. Can't you use events? You could look at the existing events in the TrinityCore source and try to make your own. This would be the best way to do it.

  5. #5
    4BOLTMAIN's Avatar Sergeant
    Reputation
    2
    Join Date
    Dec 2010
    Posts
    63
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by DrakeFish View Post
    I don't think it's a good idea to put a loop like this in a private server code. Depending on how it handles it you could make it freeze a part of the server for the time you're making it sleep. Can't you use events? You could look at the existing events in the TrinityCore source and try to make your own. This would be the best way to do it.
    Yes I agree, thats why I need to change it. I dont have a lot of experience with c++, Im the type of person that learns by looking at other code examples. I saw this wait function on google and it looked better then the for i = 1000000 example. lol! Ive searched the source for "delay" and "pause" but couldnt find anything. Where would I look to find an event example?

  6. #6
    SpellEffects's Avatar Sergeant
    Reputation
    64
    Join Date
    Apr 2011
    Posts
    69
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by 4BOLTMAIN View Post
    Yes I agree, thats why I need to change it. I dont have a lot of experience with c++, Im the type of person that learns by looking at other code examples. I saw this wait function on google and it looked better then the for i = 1000000 example. lol! Ive searched the source for "delay" and "pause" but couldnt find anything. Where would I look to find an event example?
    Look on the official trinity repository, they must have some boss scripts or what ever there that includes delayed events.
    uint32 = -1;
    I guess some people just find it hard to input their question into a field and press enter.

    Check out my blog here on the forums

Similar Threads

  1. Whats the command to level up ranks?
    By sabend in forum World of Warcraft General
    Replies: 2
    Last Post: 11-24-2006, 06:45 AM
  2. add a radio command to your server?
    By WoWLegend in forum World of Warcraft General
    Replies: 2
    Last Post: 10-29-2006, 04:43 AM
  3. slash commands
    By alex2630 in forum World of Warcraft Guides
    Replies: 0
    Last Post: 10-25-2006, 12:47 PM
  4. 5 Priest Raiding Commandments
    By Squirllz in forum World of Warcraft Guides
    Replies: 1
    Last Post: 10-11-2006, 07:43 PM
  5. [Guide] Command List
    By oninuva in forum World of Warcraft Guides
    Replies: 5
    Last Post: 05-17-2006, 08:28 PM
All times are GMT -5. The time now is 08:45 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search