Problem with my C++ script menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    XxCyanidexX's Avatar Member
    Reputation
    56
    Join Date
    Nov 2008
    Posts
    138
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with my C++ script

    Hi, I wrote a GM event system in C++ today when I found out that the reason all of the others werent working was because it had to be changed to a bool. Well, I am having two major problems with it in-game:

    1. When I join the event, instead of teleporting me to the set coordinates, it teleports me really high up in the sky and I fall to death.

    2. My whole block of code starting from if(Message == end && pPlayer->GetSession()->CanUseCommand('a')) does not work in-game but I am getting no errors compiling.

    If someone can tell me what is wrong with this, I would give you +Rep and I will release it to mmowned.


    Code:
    //EventSystem coded by Cyanide
    //Copyright (c) Cyanide 2009
    
       #include "StdAfx.h"
       #include "Setup.h"
       #include <string>
       #include <iostream>
    
    	using namespace std;
    	static string infoHelp, join, start, end;
    	float sx,sy,sz;
    	uint32 smapid;
    	bool evon;
    
    bool EventSystem(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
    {
    	join = "#join";
    	start = "#eventstart";
    	end = "#eventend";
    
    	if(Message == join)
    	{
    		if(evon)
    		{
    			if(pPlayer->CombatStatus.IsInCombat())
    			{
    				pPlayer->BroadcastMessage("You cannot teleport in combat.");
    				return true;
    			}
    			else
    			{
    				pPlayer->EventTeleport(smapid, sx, sy, sz);
    				return true;
    			}
    			return false;
    		}
    		else
    		{
    			return true;
    		}
    		return false;
    	}
    	if(Message == start && pPlayer->GetSession()->CanUseCommand('a'))
    	{
    		if(evon)
    		{
    			pPlayer->BroadcastMessage("There is already an event summoning wait for it to finish.");
    			return true;
    		}
    		else
    		{
    			evon = true;
    			char Msg[255];
    			sprintf(Msg, "|cff0066cc[Event System]|r |cff00ff00%s has started an event! Type #join to join!|r", pPlayer->GetName());
    			sWorld.SendWorldText(Msg);
    			return true;
    			sx = pPlayer->GetPositionX();
    			sy = pPlayer->GetPositionY();
    			sz = pPlayer->GetPositionZ();
    			smapid = pPlayer->GetMapId();
    			return true;
    		}
    		return false;
    	}
    	else
    	{
    		return true;
    	}
    	if(Message == end && pPlayer->GetSession()->CanUseCommand('a'))
    	{
    		if(evon)
    		{
    			evon = false;
    			char Msg[255];
    			sprintf(Msg, "|cff0066cc[Event System]|r |cff00ff00%s has ended summons to the event.", pPlayer->GetName());
    			sWorld.SendWorldText(Msg);
    			return true;
    		}
    		else
    		{
    			pPlayer->BroadcastMessage("There is no event summoning going on right now.");
    			return true;
    		}
    		return false;
    	}
    	else
    	{
    		return true;
    	}
    	return false;
    }
    
    void SetupEventCmd(ScriptMgr * mgr)
    {
     evon = false;
     mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, (bool *) EventSystem);
    }
    Well there ya go, hope you can help me

    Thanks

    Problem with my C++ script
  2. #2
    Herleybob's Avatar Contributor
    Reputation
    178
    Join Date
    Jul 2007
    Posts
    663
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What core? Arcemu im guessing?

    Nom Nom Nom :P

  3. #3
    XxCyanidexX's Avatar Member
    Reputation
    56
    Join Date
    Nov 2008
    Posts
    138
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, rev 2468 I believe.

  4. #4
    Herleybob's Avatar Contributor
    Reputation
    178
    Join Date
    Jul 2007
    Posts
    663
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For the teleport, you should probably use SafeTeleport, and maby try making them a float if needed.

    Nom Nom Nom :P

  5. #5
    XxCyanidexX's Avatar Member
    Reputation
    56
    Join Date
    Nov 2008
    Posts
    138
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    float sx,sy,sz;
    And doesn't safe teleport have different arguments?

  6. #6
    Herleybob's Avatar Contributor
    Reputation
    178
    Join Date
    Jul 2007
    Posts
    663
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah, yea SafeTeleport uses mapid, instanceid, x, y, z, o.
    Code:
    //EventSystem coded by Cyanide
    //Copyright (c) Cyanide 2009
    
       #include "StdAfx.h"
       #include "Setup.h"
       #include <string>
       #include <iostream>
    
        using namespace std;
        static string infoHelp, join, start, end;
        float sx,sy,sz,so;
        uint32 smapid,sinstanceid;
        bool evon;
    
    bool EventSystem(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
    {
        join = "#join";
        start = "#eventstart";
        end = "#eventend";
    
        if(Message == join)
        {
            if(evon)
            {
                if(pPlayer->CombatStatus.IsInCombat())
                {
                    pPlayer->BroadcastMessage("You cannot teleport in combat.");
                    return true;
                }
                else
                {
                    pPlayer->SafeTeleport(smapid, sinstanceid, sx, sy, sz, so);
                    return true;
                }
                return false;
            }
            else
            {
                return true;
            }
            return false;
        }
        if(Message == start && pPlayer->GetSession()->CanUseCommand('a'))
        {
            if(evon)
            {
                pPlayer->BroadcastMessage("There is already an event summoning wait for it to finish.");
                return true;
            }
            else
            {
                evon = true;
                char Msg[255];
                sprintf(Msg, "|cff0066cc[Event System]|r |cff00ff00%s has started an event! Type #join to join!|r", pPlayer->GetName());
                sWorld.SendWorldText(Msg);
                return true;
                sx = pPlayer->GetPositionX();
                sy = pPlayer->GetPositionY();
                sz = pPlayer->GetPositionZ();
                so = pPlayer->GetOrientation();
                smapid = pPlayer->GetMapId();
                sinstanceid = pPlayer->GetInstanceID();
                return true;
            }
            return false;
        }
        else
        {
            return true;
        }
        if(Message == end && pPlayer->GetSession()->CanUseCommand('a'))
        {
            if(evon)
            {
                evon = false;
                char Msg[255];
                sprintf(Msg, "|cff0066cc[Event System]|r |cff00ff00%s has ended summons to the event.", pPlayer->GetName());
                sWorld.SendWorldText(Msg);
                return true;
            }
            else
            {
                pPlayer->BroadcastMessage("There is no event summoning going on right now.");
                return true;
            }
            return false;
        }
        else
        {
            return true;
        }
        return false;
    }
    
    void SetupEventCmd(ScriptMgr * mgr)
    {
     evon = false;
     mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, (bool *) EventSystem);
    }

    Nom Nom Nom :P

  7. #7
    XxCyanidexX's Avatar Member
    Reputation
    56
    Join Date
    Nov 2008
    Posts
    138
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, I'll try that out.

    But what about that block of code that wasn't working.

    EDIT: Damn, that didn't work, I still fall out of the sky. I fall out in Dalaran Crater if that is relevant. Maybe it's my rev of ArcEmu?

    Seems like it is trying to teleport me to Alterac Valley, because that is where my corpse releases.


    EDIT 2: I fixed the teleport part, it was because I had return true before the part where you get the coordinates, so it cut it off there. As far as the part of the code that is not working, I am confused :P
    Last edited by XxCyanidexX; 04-05-2009 at 11:26 PM.

  8. #8
    xX EPIC Xx's Avatar Active Member
    Reputation
    37
    Join Date
    Apr 2008
    Posts
    238
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you did not make this script lol
    https://Fileusher.com

  9. #9
    1ns0mnia's Avatar Active Member
    Reputation
    67
    Join Date
    Nov 2007
    Posts
    428
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by xX EPIC Xx View Post
    you did not make this script lol
    irrelevant

    goodluck with the script.

  10. #10
    xX EPIC Xx's Avatar Active Member
    Reputation
    37
    Join Date
    Apr 2008
    Posts
    238
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes it is XD
    i don't like people that steal things :O
    https://Fileusher.com

  11. #11
    XxCyanidexX's Avatar Member
    Reputation
    56
    Join Date
    Nov 2008
    Posts
    138
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I made it myself.
    Last edited by XxCyanidexX; 04-06-2009 at 11:38 AM.

  12. #12
    Clain's Avatar Banned
    Reputation
    179
    Join Date
    Jan 2008
    Posts
    1,396
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, no you didn't. Coolmanbob did and you just edited and renamed some variables. >_<
    Last edited by Clain; 04-06-2009 at 04:26 PM.

  13. #13
    Jotox's Avatar Contributor
    Reputation
    250
    Join Date
    Mar 2008
    Posts
    282
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    >_> This thread is frustrating to watch.

    Here's a fixed version of your code.

    Code:
    #include "StdAfx.h"
    #include "Setup.h"
    #include <string>
    #include <iostream>
    
    using namespace std;
    static string infoHelp, join, start, end;
    static float sx,sy,sz,so;
    static uint32 smapid,sinstanceid;
    static bool evon;
    
    bool EventSystem(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
    {
    	
        if(Message == join)
        {
            if(evon)
            {
                if(pPlayer->CombatStatus.IsInCombat())
                    pPlayer->BroadcastMessage("You cannot teleport in combat.");
                else
                    pPlayer->SafeTeleport(smapid, sinstanceid, sx, sy, sz, so);
            }
    		return true;
        }
        if(Message == start && pPlayer->GetSession()->CanUseCommand('a'))
        {
            if(evon)
                pPlayer->BroadcastMessage("There is already an event summoning wait for it to finish.");
            else
            {
                evon = true;
                char Msg[255];
                sprintf(Msg, "|cff0066cc[Event System]|r |cff00ff00%s has started an event! Type #join to join!|r", pPlayer->GetName());
                sWorld.SendWorldText(Msg);
                sx = pPlayer->GetPositionX();
                sy = pPlayer->GetPositionY();
                sz = pPlayer->GetPositionZ();
                so = pPlayer->GetOrientation();
                smapid = pPlayer->GetMapId();
                sinstanceid = pPlayer->GetInstanceID();
            }
    		return true;
        }
    
        if(Message == end && pPlayer->GetSession()->CanUseCommand('a'))
        {
            if(evon)
            {
                evon = false;
                char Msg[255];
                sprintf(Msg, "|cff0066cc[Event System]|r |cff00ff00%s has ended summons to the event.", pPlayer->GetName());
                sWorld.SendWorldText(Msg);
            }
            else
                pPlayer->BroadcastMessage("There is no event summoning going on right now.");
            return true;
        }
    
        return false;
    }
    
    void SetupEventCmd(ScriptMgr * mgr)
    {
    	join = "#join";
    	start = "#eventstart";
    	end = "#eventend";
    	evon = false;
    
    	mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, (bool *) EventSystem);
    }
    I neatened it up a lot, as well.
    Last edited by Jotox; 04-06-2009 at 04:51 PM.

  14. #14
    Jotox's Avatar Contributor
    Reputation
    250
    Join Date
    Mar 2008
    Posts
    282
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your error was that you returned before setting the coordinates, and you had a number of unnecessary else{return false;} statements which prevented proper execution.

  15. #15
    XxCyanidexX's Avatar Member
    Reputation
    56
    Join Date
    Nov 2008
    Posts
    138
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Clain View Post
    No, no you didn't. Coolmanbob did and you just edited and renamed some variables. >_<
    Shutup, I have seen coolmanbobs script ,and his is written with a void, which would disable chat all together. If you are smart enough to look at my script, you would see it's written with a bool, which makes it very different from his, and I wrote it from scratch, so stfu? kthxbai.

    and @Jotox1: That disabled my whole chat system.
    Last edited by XxCyanidexX; 04-06-2009 at 10:22 PM.

Page 1 of 2 12 LastLast

Similar Threads

  1. Problem with online players script and vote system
    By Obly in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 09-29-2010, 03:16 AM
  2. [ArcEmu] Problem with C++ House Script!
    By BloodgultchWoW in forum WoW EMU Questions & Requests
    Replies: 9
    Last Post: 03-11-2010, 10:43 PM
  3. [Help Plzzzz] LUA Problem with KJ Script
    By Arthas117 in forum WoW EMU Questions & Requests
    Replies: 3
    Last Post: 08-16-2008, 05:25 PM
  4. Problem with lua boss script
    By nickeg in forum WoW EMU Questions & Requests
    Replies: 13
    Last Post: 08-16-2008, 09:22 AM
  5. Problems with my C++ script
    By Sylex in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 02-07-2008, 08:04 AM
All times are GMT -5. The time now is 05:26 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search