Advertisement
Rochet2

GOMove ~ C++ edition skeleton

May 26th, 2012
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.22 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. // #include "Chat.h"
  3.  
  4. class GOMove_commandscript : public CommandScript
  5. {
  6. public:
  7.     GOMove_commandscript() : CommandScript("GOMove_commandscript") { }
  8.  
  9.     ChatCommand* GetCommands() const
  10.     {
  11.         static ChatCommand HelloWorldCommandTable[] =
  12.         {
  13.             { "gomove",         SEC_GAMEMASTER,     true,   &GOMove_Command,                "", NULL },
  14.             { NULL,             0,                  falseNULL,                           "", NULL }
  15.         };
  16.         return HelloWorldCommandTable;
  17.     }
  18.  
  19.     static bool GOMove_Command(ChatHandler* handler, const char* args)
  20.     {
  21.         enum eEnums
  22.         {
  23.             TEST    = 0,
  24.             SPAWN   = 1,
  25.         };
  26.         struct GOMove_Data
  27.         {
  28.             GameObject* pGob;bool Face;uint32 Entry;float x;float y;float z;float o;float scale;uint8 Phase;
  29.         };
  30.         static std::map<uint64, GOMove_Data> GOMove;
  31.         static std::map<uint64, bool> GOSaved;
  32.         static std::map<uint64, bool> GOSpawned;
  33.  
  34.         Player* pPlayer = handler->GetSession()->GetPlayer();
  35.         uint64 GUID = pPlayer->GetGUID();
  36.  
  37.         if(!args)
  38.             return false;
  39.  
  40.         char* ID_t = strtok((char*)args, " "); // change (char*)args incase of a crash
  41.         if(!ID_t)
  42.             return false;
  43.         uint32 ID = atoi(ID_t);
  44.  
  45.         char* ARG_t = strtok(NULL, " ");
  46.         uint32 ARG;
  47.         if(ARG_t)
  48.             ARG = atoi(ARG_t);
  49.  
  50.         if(GOMove.find(GUID) == GOMove.end())
  51.             GOMove[GUID].Face = false;
  52.  
  53.         if(!ARG) // no args
  54.         {
  55.             switch(ID)
  56.             {
  57.             case TEST:
  58.                 pPlayer->GetSession()->SendAreaTriggerMessage(pPlayer->GetName());
  59.                 // printf(pPlayer->GetName());
  60.                 return true;
  61.                 break;
  62.             }
  63.         }
  64.         else if(!ARG < 1) // args, needs a number, bigger than 0
  65.         {
  66.             switch(ID)
  67.             {
  68.             case SPAWN:
  69.                 pPlayer->GetSession()->SendNotification("Entry inserted was: %u", ARG);
  70.                 /*
  71.                 GameObject* Sel = pPlayer->GetGameObject(1); // GO(str,ARG,x,y,z,o,1,pPlayer:GetPhase(),pPlayer)
  72.                 if(!Sel)
  73.                 pPlayer->GetSession()->SendNotification("No gameobject found with entry %u", ARG);
  74.                 else
  75.                 {
  76.                 GOMove[GUID].pGob = Sel;
  77.                 // SEND_USED(pPlayer, str)
  78.                 pPlayer->GetSession()->SendAreaTriggerMessage("%s spawned", Sel->GetName());
  79.                 }
  80.                 */
  81.                 return true;
  82.                 break;
  83.             }
  84.         }
  85.         else
  86.             pPlayer->GetSession()->SendNotification("Only numbers above 0");
  87.         return false;
  88.     }
  89. };
  90.  
  91. void AddSC_GOMove_commandscript()
  92. {
  93.     new GOMove_commandscript();
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement