C++ help :) menu

Shout-Out

User Tag List

Thread: C++ help :)

Results 1 to 7 of 7
  1. #1
    zla7ko0o's Avatar Member
    Reputation
    1
    Join Date
    Jun 2009
    Posts
    5
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    C++ help :)

    I want recall port command to not be allowed when player is in combat
    i`m using aspire
    Code:
    #include "StdAfx.h"
    
    bool ChatHandler::HandleRecallGoCommand(const char* args, WorldSession *m_session)
    {
    	if( args == NULL )
    		return false;
    
    	if( !*args )
    		return false;
    
    	if( m_session == NULL )
    		return false;
    
    	QueryResult *result = WorldDatabase.Query( "SELECT * FROM recall ORDER BY name" );
    
    	if( result == NULL)
    		return false;
    
    	do
    	{
    		Field* fields = result->Fetch();
    		const char* locname = fields[1].GetString();
    		uint32 locmap = fields[2].GetUInt32();
    		float x = fields[3].GetFloat();
    		float y = fields[4].GetFloat();
    		float z = fields[5].GetFloat();
    
    		if( strnicmp( const_cast< char* >( args ), locname, strlen( args ) ) == 0 )
    		{
    			if( m_session->GetPlayer() != NULL )
    			{
    				m_session->GetPlayer()->SafeTeleport(locmap, 0, LocationVector(x, y, z));
    				delete result;
    				return true;
    			}
    			else
    			{
    				delete result;
    				return false;
    			}
    		}
    
    	}while (result->NextRow());
    
    	delete result;
    	return false;
    }
    
    bool ChatHandler::HandleRecallAddCommand(const char* args, WorldSession *m_session)
    {
    	if(!*args)
    		return false;
    	
    	QueryResult *result = WorldDatabase.Query( "SELECT name FROM recall" );
    	if(!result)
    		return false;
    	do
    	{
    		Field *fields = result->Fetch();
    		const char * locname = fields[0].GetString();
    		if (strncmp((char*)args,locname,strlen(locname))==0)
    		{
    			RedSystemMessage(m_session, "Name in use, please use another name for your location.");
    			delete result;
    			return true;
    		}
    	}while (result->NextRow());
    	delete result;
    
    	PlayerPointer plr = m_session->GetPlayer();
    	std::stringstream ss;
    	
    	string rc_locname = string(args);
    
    	ss << "INSERT INTO recall (name, mapid, positionX, positionY, positionZ) VALUES ('"
    	<< WorldDatabase.EscapeString(rc_locname).c_str() << "' , "
    	<< plr->GetMapId() << ", "
    	<< plr->GetPositionX() << ", " 
    	<< plr->GetPositionY() << ", "
    	<< plr->GetPositionZ() << ");";
    	WorldDatabase.Execute( ss.str( ).c_str( ) );
    
    	char buf[256]; 
    	snprintf((char*)buf, 256, "Added location to DB with MapID: %d, X: %f, Y: %f, Z: %f",
    		(unsigned int)plr->GetMapId(), plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ());
    	GreenSystemMessage(m_session, buf);
    	sGMLog.writefromsession(m_session, "used recall add, added \"%s\" location to database.", rc_locname.c_str());
    
    	return true;
    }
    
    bool ChatHandler::HandleRecallDelCommand(const char* args, WorldSession *m_session)
    {
    	   if(!*args)
    		return false;
    
    	QueryResult *result = WorldDatabase.Query( "SELECT id,name FROM recall" );
    	if(!result)
    		return false;
    
    	do
    	{
    		Field *fields = result->Fetch();
    		float id = fields[0].GetFloat();
    		const char * locname = fields[1].GetString();
    
    		if (strnicmp((char*)args,locname,strlen(locname))==0)
    		{
    			std::stringstream ss;
    			ss << "DELETE FROM recall WHERE id = "<< (int)id <<";";
    			WorldDatabase.Execute( ss.str( ).c_str( ) );
    			GreenSystemMessage(m_session, "Recall location removed.");
    			sGMLog.writefromsession(m_session, "used recall delete, removed \"%s\" location from database.", args);
    			delete result;
    			return true;
    		}
    
    	}while (result->NextRow());
    
    	delete result;
    	return false;
    }
    
    bool ChatHandler::HandleRecallListCommand(const char* args, WorldSession *m_session)
    {
    	QueryResult *result;
    	if( args == NULL )
    		result = WorldDatabase.Query( "SELECT id,name FROM recall ORDER BY name" );
    	else
    		result = WorldDatabase.Query( "SELECT id,name FROM recall WHERE name LIKE '%s%s' ORDER BY name",args,"%" );
    
    
    	if(!result)
    		return false;
    	std::string recout;
    	uint32 count = 0;
    
    	recout = "|cff00ff00Recall locations|r:\n\n";
    	do
    	{
    		Field *fields = result->Fetch();
    		//float id = fields[0].GetFloat();
    		const char * locname = fields[1].GetString();
    		recout += "|cff00ccff";
    		recout += locname;
    		recout += "|r, ";
    		count++;
    		
    		if(count == 5)
    		{
    			recout += "\n";
    			count = 0;
    		}
    	}while (result->NextRow());
    	SendMultilineMessage(m_session, recout.c_str());
    
    	delete result;
    	return true;
    }
    
    bool ChatHandler::HandleRecallPortPlayerCommand(const char* args, WorldSession * m_session)
    {
    	char location[255];
    	char player[255];
    	if(sscanf(args, "%s %s", player, location) != 2)
    		return false;
    
    	PlayerPointer plr = objmgr.GetPlayer(player, false);
    	if(!plr) return false;
    
    	QueryResult *result = WorldDatabase.Query( "SELECT * FROM recall ORDER BY name" );
    	if(!result)
    		return false;
    
    	do
    	{
    		Field *fields = result->Fetch();
    		const char * locname = fields[1].GetString();
    		uint32 locmap = fields[2].GetUInt32();
    		float x = fields[3].GetFloat();
    		float y = fields[4].GetFloat();
    		float z = fields[5].GetFloat();
    
    		if (strnicmp((char*)location,locname,strlen(args))==0)
    		{
    			if(plr->GetInstanceID() != m_session->GetPlayer()->GetInstanceID())
    				sEventMgr.AddEvent(plr, &Player::EventSafeTeleport, locmap, uint32(0), LocationVector(x, y, z), EVENT_PLAYER_TELEPORT, 1, 1,EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
    			else
    				plr->SafeTeleport(locmap, 0, LocationVector(x, y, z));
    			delete result;
    			return true;
    		}
    
    	}while (result->NextRow());
    
    	delete result;
    	return false;
    }
    Last edited by zla7ko0o; 08-11-2009 at 11:02 AM.

    C++ help :)
  2. #2
    Performer's Avatar Contributor
    Reputation
    212
    Join Date
    Nov 2007
    Posts
    874
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol? Atleast put it in code tags and post the error your getting?


  3. #3
    zla7ko0o's Avatar Member
    Reputation
    1
    Join Date
    Jun 2009
    Posts
    5
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Done i don`t get error

  4. #4
    namelessgnome's Avatar Contributor
    Reputation
    108
    Join Date
    May 2007
    Posts
    263
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hm...

    at the top of the recall port function add a check to see if we are in combat (m_session->GetPlayer()...) if we are in combat just return and broadcast a message to them using the session object..

  5. #5
    zla7ko0o's Avatar Member
    Reputation
    1
    Join Date
    Jun 2009
    Posts
    5
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Post fully code please

  6. #6
    namelessgnome's Avatar Contributor
    Reputation
    108
    Join Date
    May 2007
    Posts
    263
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First of all I never actually coded that thing.

    And IMO the only way to learn is to do it your self. There are many, many examples of what explained to you. You can find them in almost any teleporter script.

  7. #7
    zla7ko0o's Avatar Member
    Reputation
    1
    Join Date
    Jun 2009
    Posts
    5
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried if can i would`t post it .. So s.b help please

Similar Threads

  1. Help WoW Fish-Bot
    By Eliteplague in forum World of Warcraft General
    Replies: 2
    Last Post: 12-10-2024, 05:46 PM
  2. HELP: Gold Scam Exploit
    By GoldDragon in forum World of Warcraft General
    Replies: 11
    Last Post: 01-23-2007, 07:26 PM
  3. Banner Ad Redesign help
    By Matt in forum Community Chat
    Replies: 57
    Last Post: 07-08-2006, 08:40 PM
  4. Hit points and talent points? Please help
    By hankusdankus in forum World of Warcraft General
    Replies: 6
    Last Post: 05-04-2006, 02:00 PM
  5. bot help
    By xwhitedeathx in forum World of Warcraft General
    Replies: 3
    Last Post: 05-01-2006, 03:50 AM
All times are GMT -5. The time now is 05:44 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