Hello & Welcome to our community. Is this your first visit? Register
Follow us on
Follow us on Facebook Follow us on Twitter Watch us on YouTube


MMOCoin

Likes Likes:  0
Results 1 to 5 of 5
  1. #1
    Contributor
    Cocain's Avatar
    Join Date
    Mar 2010
    Posts
    208
    Post Thanks / Like
    Rep Power
    16
    Reputation
    92

    [C++] PlayerCommands.


    Register to remove this ad
    As it has been done many times before in Lua, I'm now going to demonstrate a C++ script including player commands. (Yuh, I wanne be unique.) To start of I'm keeping this basic commands, but while progressing I might add more functions on request.


    Code:
    /* Credits claimed by AuxProductions.
    
    More functions WILL be added on request.
    */
    
    #include "StdAfx.h"
    #include "Setup.h"
    
    #ifdef WIN32
    #pragma warning(disable:4305) // Disables the funky warning.
    #endif
    
    // Defines.
    #define FOOD 35953 // http://www.wowhead.com/?item=35953
    #define DRINK 33445 // http://www.wowhead.com/?item=33445
    
    // Command Registration
    static string food     = "%food";                 // Adds the item '35953'.
    static string drink     = "%drink";         // Adds the item '33445'.
    static string buffs        ="%buffs";       // Buffs the player.
    
    
    /*            FOOOD COMMAND     */
    if(Message == food && !Plr->CombatStatus.IsInCombat()) {                             //Combat check
                Item * item;                                                                                 
                item = objmgr.CreateItem(food, Plr);                                                         
                item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 10);                                            
                if(!Plr->GetItemInterface()->AddItemToFreeSlot(item)) 
                {                                     
                    Plr->BroadcastMessage("No free slots were found in your inventory!");                     
                    item->DeleteMe();                                                                         
                } 
                else 
                { 
                    SlotResult * sr;                                                                                         
                    sr = Plr->GetItemInterface()->LastSearchResult();                                                         
                    Plr->GetSession()->SendItemPushResult(item, false, true, false, true, sr->ContainerSlot, sr->Slot, 1);    
                }
                } 
                else 
                {
                    Plr->BroadcastMessage("You cannot use this command when in combat!");                     
                }
            
    /*        DRINK COMMAND        */
    if(Message == drink && !Plr->CombatStatus.IsInCombat()) {                             //Combat check
                Item * item;                                                                                 
                item = objmgr.CreateItem(DRINK, Plr);                                                         
                item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 10);                                            
                if(!Plr->GetItemInterface()->AddItemToFreeSlot(item)) 
                {                                     
                    Plr->BroadcastMessage("No free slots were found in your inventory!");                     
                    item->DeleteMe();                                                                         
                } 
                else 
                { 
                    SlotResult * sr;                                                                                         
                    sr = Plr->GetItemInterface()->LastSearchResult();                                                         
                    Plr->GetSession()->SendItemPushResult(item, false, true, false, true, sr->ContainerSlot, sr->Slot, 1);    
                }
                } 
                else 
                {
                    Plr->BroadcastMessage("You cannot use this command when in combat!");                     
                }
                
    /*       BUFFS                  */
            if(Message == buffs && !Plr->CombatStatus.IsInCombat()) 
            {                             
                Plr->CastSpell(Plr, 20217, true);          // BoK
                plr->CastSpell(Plr, 48469, true);         // Mark of the wild.
                
                Plr->BroadcastMessage("You are now buffed!");     
                     }

    Have fun, and note this is NOT copied from anyone.

    Note : I havn't got the chance to test this yet, so might be missing a bracket perhaps. Would be nice if someone tested it. ^^


    › See More: [C++] PlayerCommands.

  2. #2
    Banned

    Join Date
    Aug 2008
    Location
    Scotland
    Posts
    652
    Post Thanks / Like
    Rep Power
    0
    Reputation
    103
    Nice release mate. Will test it when I have a chance.

  3. #3
    Contributor
    StickyIcky's Avatar
    Join Date
    Jul 2008
    Location
    127.0.0.1
    Posts
    747
    Post Thanks / Like
    Rep Power
    18
    Reputation
    188
    Uhm...

    I made this a while back...

    All it seems is that commands and a few lines are changed.

  4. #4
    Banned

    Join Date
    Aug 2008
    Location
    Scotland
    Posts
    652
    Post Thanks / Like
    Rep Power
    0
    Reputation
    103
    Hmm, I've never seen it before, but you guys know me, I forget pretty much everything I see. Anyway, quite alot of LUA's, C++ scripts etc have been done before, but people modify and edit a few things, although I dont class that as a release, I still think it's okay for them to release it, as long as they say what script they've modifed and who wrote it, in this case you. And possibly have a link to the Original owner's Profile page if he is on this forum, for us to go over and him aswell.

  5. #5
    Grunt
    Sdyess94's Avatar
    Join Date
    Jan 2009
    Posts
    36
    Post Thanks / Like
    Rep Power
    16
    Reputation
    60

    Register to remove this ad
    A bit of a necro, but I have fixed his commands

    Code:
    /* Credits claimed by AuxProductions.
    
    More functions WILL be added on request.
    */
    
    #include "StdAfx.h"
    #include "Setup.h"
    
    #ifdef WIN32
    #pragma warning(disable:4305) // Disables the funky warning.
    #endif
    
    // Defines.
    #define FOOD 35953 // http://www.wowhead.com/?item=35953
    #define DRINK 33445 // http://www.wowhead.com/?item=33445
    
    // Command Registration
    static string food     = "%food";                 // Adds the item '35953'.
    static string drink     = "%drink";         // Adds the item '33445'.
    static string buffs        ="%buffs";       // Buffs the player.
    
    bool AuxChat(Player * Plr, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
    {
    
        if(Message == food)
        {
            Item * item;
            item = objmgr.CreateItem(FOOD, Plr);                                                         
            item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 10);
    
            if(Plr->CombatStatus.IsInCombat())
            {
                Plr->BroadcastMessage("You are in combat!");
                item->DeleteMe();
                return true;
            }
            else if(!Plr->GetItemInterface()->AddItemToFreeSlot(item))
            {
                Plr->BroadcastMessage("No free slots were found in your inventory!");
                item->DeleteMe();
            }
            else 
            { 
    
                SlotResult * sr = Plr->GetItemInterface()->LastSearchResult(); 
                Plr->GetItemInterface()->AddItemById(DRINK, 10, 0);    
            }
        }
        else if(Message == drink)
        {
            Item * item;
            item = objmgr.CreateItem(DRINK, Plr);                                                         
            item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 10);
    
            if(Plr->CombatStatus.IsInCombat())
            {
                Plr->BroadcastMessage("You are in combat!");
                item->DeleteMe();
                return true;
            }
            else if(!Plr->GetItemInterface()->AddItemToFreeSlot(item))
            {
                Plr->BroadcastMessage("No free slots were found in your inventory!");
                item->DeleteMe();
            }
            else 
            { 
                SlotResult * sr = Plr->GetItemInterface()->LastSearchResult();                                                         
                Plr->GetItemInterface()->AddItemById(DRINK, 10, 0);    
            }
        }
        if(Message == buffs) 
        {                             
            Plr->CastSpell(Plr, 20217, true);          // BoK
            Plr->CastSpell(Plr, 48469, true);         // Mark of the wild.
            Plr->BroadcastMessage("You are now buffed!"); //orly?    
        }
        return true;
    }
    
    void SetupChat(ScriptMgr *mgr)
    {
        mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &AuxChat);
    }





  6. Related Threads - Scroll Down after related threads if you are only interested to view replies for above post/thread

 

 

Visitors found this page by searching for:

c trinitycore2 script for player buff command

SEO Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -5. The time now is 10:25 AM.
Powered by vBulletin® Copyright ©2000-2024, Jelsoft Enterprises Ltd.
See More links by ForumSetup.net. Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
vBulletin Licensed to: MMOPro.org