Ir para conteúdo
  • Cadastre-se

Posts Recomendados

TV System é um sistema que possibilita players assistirem outros jogadores pela tv em seu servidor, bom eu só irei deixar á parte dos códigos aqui vocês terão que desenvolver os scripts em lua para funcionar porém os códigos estão prontos e funcionais.

 

em luascript.cpp adicione:

//getCreatureNoMove(cid)
	lua_register(m_luaState, "getCreatureNoMove", LuaScriptInterface::luaGetCreatureNoMove);

	//doCreatureSetNoMove(cid, block)
	lua_register(m_luaState, "doCreatureSetNoMove", LuaScriptInterface::luaDoCreatureSetNoMove);

	//doInviteToPrivateChannel(cid, msg)
	lua_register(m_luaState, "doInviteToPrivateChannel", LuaScriptInterface::luaDoInviteToPrivateChannel);
	
	//doRemoveIntoPrivateChannel(cid, msg)
	lua_register(m_luaState, "doRemoveIntoPrivateChannel", LuaScriptInterface::luaDoRemoveIntoPrivateChannel);
	
	//doDeletePrivateChannel(cid)
	lua_register(m_luaState, "doDeletePrivateChannel", LuaScriptInterface::luaDoDeletePrivateChannel);
		
	//getCreatureHideHealth(cid)
	lua_register(m_luaState, "getCreatureHideHealth", LuaScriptInterface::luaGetCreatureHideHealth);

	//doCreatureSetHideHealth(cid, hide)
	lua_register(m_luaState, "doCreatureSetHideHealth", LuaScriptInterface::luaDoCreatureSetHideHealth);
	
	//doCreatePrivateChannel(cid)
	lua_register(m_luaState, "doCreatePrivateChannel", LuaScriptInterface::luaDoCreatePrivateChannel);

ainda em luascript.cpp:

int32_t LuaScriptInterface::luaGetCreatureHideHealth(lua_State* L)
{
	//getCreatureHideHealth(cid)
	ScriptEnviroment* env = getEnv();

	if(Creature* creature = env->getCreatureByUID(popNumber(L)))
		lua_pushboolean(L, creature->getHideHealth());
	else
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}
	return 1;
}

int32_t LuaScriptInterface::luaDoCreatureSetHideHealth(lua_State* L)
{
	//doCreatureSetHideHealth(cid, hide)
	bool hide = popNumber(L);

	ScriptEnviroment* env = getEnv();
	if(Creature* creature = env->getCreatureByUID(popNumber(L)))
	{
		creature->setHideHealth(hide);
		g_game.addCreatureHealth(creature);
		lua_pushboolean(L, true);
	}
	else
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}
	return 1;
}
	
	int32_t LuaScriptInterface::luaDoRemoveIntoPrivateChannel(lua_State* L)
{
	//doRemoveIntoPrivateChannel(cid, string)
	std::string name = popString(L);
	uint32_t cid = popNumber(L);

	ScriptEnviroment* env = getEnv();
	if(Player* player = env->getPlayerByUID(cid))
	{
            if(g_game.playerChannelExclude(player->getID(), name)) 
			   lua_pushboolean(L, true);
            else
               lua_pushboolean(L, false);
	}
	else
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 1;
}

int32_t LuaScriptInterface::luaDoDeletePrivateChannel(lua_State* L)
{
	//doDeletePrivateChannel(cid)
	uint32_t cid = popNumber(L);

	ScriptEnviroment* env = getEnv();
	if(Player* player = env->getPlayerByUID(cid))
	{
            if(g_chat.deleteChannel(player, g_chat.getPrivateChannel(player)->getId()))
			   lua_pushboolean(L, true);
            else
               lua_pushboolean(L, false);
	}
	else
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 1;
}


int32_t LuaScriptInterface::luaDoInviteToPrivateChannel(lua_State* L)
{
	//doCreatePrivateChannel(cid)
	std::string name = popString(L);
	uint32_t cid = popNumber(L);

	ScriptEnviroment* env = getEnv();
	if(Player* player = env->getPlayerByUID(cid))
	{
			if(g_game.playerChannelInvite(player->getID(), name))
			   lua_pushboolean(L, true);
            else
               lua_pushboolean(L, false);
	}
	else
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 1;
}

int32_t LuaScriptInterface::luaDoCreatePrivateChannel(lua_State* L)
{
	//doCreatePrivateChannel(cid)
	//std::string loot = popString(L);
	uint32_t cid = popNumber(L);

	ScriptEnviroment* env = getEnv();
	if(Player* player = env->getPlayerByUID(cid))
	{
			if(g_game.playerCreatePrivateChannel(player->getID()))
			   lua_pushboolean(L, true);
            else
               lua_pushboolean(L, false);
	}
	else
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 1;
}	

int32_t LuaScriptInterface::luaDoCreatureSetNoMove(lua_State* L)
{
	//doCreatureSetNoMove(cid, block)
	bool block = popNumber(L);

	ScriptEnviroment* env = getEnv();
	if(Creature* creature = env->getCreatureByUID(popNumber(L)))
	{
		creature->setNoMove(block);
		lua_pushboolean(L, true);
	}
	else
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 1;
}

int32_t LuaScriptInterface::luaGetCreatureNoMove(lua_State* L)
{
	//getCreatureNoMove(cid)
	ScriptEnviroment* env = getEnv();
	if(Creature* creature = env->getCreatureByUID(popNumber(L)))
		lua_pushboolean(L, creature->getNoMove());
	else
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 1;
}

agora em luascript.h adicione:

        static int32_t luaDoCreatePrivateChannel(lua_State* L);
		static int32_t luaDoInviteToPrivateChannel(lua_State* L);
		static int32_t luaDoRemoveIntoPrivateChannel(lua_State* L);
		static int32_t luaDoDeletePrivateChannel(lua_State* L);
		static int32_t luaGetCreatureNoMove(lua_State* L);
		static int32_t luaDoCreatureSetNoMove(lua_State* L);
		static int32_t luaGetCreatureHideHealth(lua_State* L);
		static int32_t luaDoCreatureSetHideHealth(lua_State* L);

agora vai em chat.cpp e adicione:

ChatChannel* Chat::createChannel(Player* player, uint16_t channelId) // tv cam system
{
	if(!player || player->isRemoved() || getChannel(player, channelId))
		return NULL;

	switch(channelId)
	{
		case CHANNEL_GUILD:
		{
			ChatChannel* newChannel = NULL;
			if((newChannel = new ChatChannel(channelId, player->getGuildName(), ChatChannel::staticFlags)))
				m_guildChannels[player->getGuildId()] = newChannel;

			return newChannel;
		}

		case CHANNEL_PARTY:
		{
			ChatChannel* newChannel = NULL;
			if(player->getParty() && (newChannel = new ChatChannel(channelId, partyName, ChatChannel::staticFlags)))
				m_partyChannels[player->getParty()] = newChannel;

			return newChannel;
		}

		case CHANNEL_PRIVATE:
		{
			//only 1 private channel for each premium player
			if(!player->isPremium() || getPrivateChannel(player))
				return NULL;

			//find a free private channel slot
			for(uint16_t i = 100; i < 10000; ++i)
			{
				if(m_privateChannels.find(i) != m_privateChannels.end())
					continue;

				uint16_t flags = 0;
				if(dummyPrivate)
					flags = dummyPrivate->getFlags();

				PrivateChatChannel* newChannel = NULL;
				//std::stringstream msg; = "Canal " + (player->getSex(false) ? "do " : "da ") + player->getName();
				if((newChannel = new PrivateChatChannel(i, player->getName() + "'s channels", ChatChannel::staticFlags)))
				{
					newChannel->setOwner(player->getGUID());
					m_privateChannels[i] = newChannel;
				}

				return newChannel;
			}
		}

		default:
			break;
	}

	return NULL;
}

depois vá em chat.h e adicione:

class Player;
enum ChannelFlags_t
{
	CHANNELFLAG_NONE = 0,
	CHANNELFLAG_ENABLED = 1 << 0,
	CHANNELFLAG_ACTIVE = 1 << 1,
	CHANNELFLAG_LOGGED = 1 << 2,
};

typedef std::map<uint32_t, Player*> UsersMap;
typedef std::list<uint32_t> InviteList;

class ChatChannel
{
	public:
		ChatChannel(uint16_t id, const std::string& name, uint16_t flags, uint32_t access = 0,
			uint32_t level = 1, Condition* condition = NULL, int32_t conditionId = -1,
			const std::string& conditionMessage = "", VocationMap* vocationMap = NULL);
		virtual ~ChatChannel()
		{
			if(m_condition)
				delete m_condition;

			if(m_vocationMap)
				delete m_vocationMap;
		}
		static uint16_t staticFlags;

		uint16_t getId() const {return m_id;}
		const std::string& getName() const {return m_name;}
		uint16_t getFlags() const {return m_flags;}

		int32_t getConditionId() const {return m_conditionId;}
		const std::string& getConditionMessage() const {return m_conditionMessage;}
		const UsersMap& getUsers() {return m_users;}

		uint32_t getLevel() const {return m_level;}
		uint32_t getAccess() const {return m_access;}
		virtual const uint32_t getOwner() {return 0;}

		bool hasFlag(uint16_t value) const {return ((m_flags & (uint16_t)value) == (uint16_t)value);}
		bool checkVocation(uint32_t vocationId) const
			{return !m_vocationMap || m_vocationMap->empty() || m_vocationMap->find(
				vocationId) != m_vocationMap->end();}

		bool addUser(Player* player);
		bool removeUser(Player* player);

		bool talk(Player* player, SpeakClasses type, const std::string& text, uint32_t _time = 0);

	protected:
		uint16_t m_id, m_flags;
		int32_t m_conditionId;
		uint32_t m_access, m_level;
		std::string m_name, m_conditionMessage;

		Condition* m_condition;
		VocationMap* m_vocationMap;

		UsersMap m_users;
		boost::shared_ptr<std::ofstream> m_file;
};

class Chat
{
	public:
		Chat(): statement(0), dummyPrivate(NULL), partyName("Party") {}
		virtual ~Chat();

		bool reload();
		bool loadFromXml();
		bool parseChannelNode(xmlNodePtr p);

		ChatChannel* createChannel(Player* player, uint16_t channelId);
		bool deleteChannel(Player* player, uint16_t channelId);

		ChatChannel* addUserToChannel(Player* player, uint16_t channelId);
		bool removeUserFromChannel(Player* player, uint16_t channelId);
		void removeUserFromAllChannels(Player* player);

		bool talkToChannel(Player* player, SpeakClasses type, const std::string& text, uint16_t channelId);

		ChatChannel* getChannel(Player* player, uint16_t channelId);
		ChatChannel* getChannelById(uint16_t channelId);

		std::string getChannelName(Player* player, uint16_t channelId);
		ChannelList getChannelList(Player* player);

		PrivateChatChannel* getPrivateChannel(Player* player);
		bool isPrivateChannel(uint16_t channelId) const {return m_privateChannels.find(channelId) != m_privateChannels.end();}

		uint32_t statement;
		StatementMap statementMap;

	private:
		void clear();

		typedef std::map<uint16_t, ChatChannel*> NormalChannelMap;
		NormalChannelMap m_normalChannels;

		typedef std::map<uint16_t, PrivateChatChannel*> PrivateChannelMap;
		PrivateChannelMap m_privateChannels;

		typedef std::map<Party*, ChatChannel*> PartyChannelMap;
		PartyChannelMap m_partyChannels;

		typedef std::map<uint32_t, ChatChannel*> GuildChannelMap;
		GuildChannelMap m_guildChannels;

		ChatChannel* dummyPrivate;
		std::string partyName;
};

agora em game.cpp adicione:

bool Game::playerBroadcastMessage(Player* player, SpeakClasses type, const std::string& text)
{
	if(!player->hasFlag(PlayerFlag_CanBroadcast) || type < SPEAK_CLASS_FIRST || type > SPEAK_CLASS_LAST)
		return false;

	for(AutoList<Player>::iterator it = Player::autoList.begin(); it != Player::autoList.end(); ++it)
		it->second->sendCreatureSay(player, type, text);

	//TODO: event handling - onCreatureSay
	std::cout << "> " << player->getName() << " broadcasted: \"" << text << "\"." << std::endl;
	return true;
}

bool Game::playerCreatePrivateChannel(uint32_t playerId)
{
	Player* player = getPlayerByID(playerId);
	if(!player || player->isRemoved() || !player->isPremium())
		return false;

	ChatChannel* channel = g_chat.createChannel(player, 0xFFFF);
	if(!channel || !channel->addUser(player))
		return false;
		
	player->sendCreatePrivateChannel(channel->getId(), channel->getName());
	return true;
}

bool Game::playerChannelInvite(uint32_t playerId, const std::string& name)
{
	Player* player = getPlayerByID(playerId);
	if(!player || player->isRemoved())
		return false;

    Player* invitePlayer = getPlayerByName(name);
	if(!invitePlayer)
		return false;
		
	PrivateChatChannel* channel = g_chat.getPrivateChannel(player);
	if(!channel)
		return false;
    
    channel->invitePlayer(player, invitePlayer);
    channel->addInvited(invitePlayer);
    
    ChatChannel* teste = (ChatChannel*) channel; teste->addUser(invitePlayer);
    
    invitePlayer->sendChannel(channel->getId(), channel->getName());
    return true;
}

bool Game::playerChannelExclude(uint32_t playerId, const std::string& name)
{
	Player* player = getPlayerByID(playerId);
	if(!player || player->isRemoved())
		return false;

	PrivateChatChannel* channel = g_chat.getPrivateChannel(player);
	if(!channel)
		return false;

	Player* excludePlayer = getPlayerByName(name);
	if(!excludePlayer)
		return false;
	
    if (player->getID() == excludePlayer->getID()){
        g_chat.deleteChannel(player, g_chat.getPrivateChannel(player)->getId());
        return true;
    }	

	channel->excludePlayer(player, excludePlayer);
	return true;
}

bool Game::playerRequestChannels(uint32_t playerId)
{
	Player* player = getPlayerByID(playerId);
	if(!player || player->isRemoved())
		return false;

	player->sendChannelsDialog();
	return true;
}

bool Game::playerOpenChannel(uint32_t playerId, uint16_t channelId)
{
	Player* player = getPlayerByID(playerId);
	if(!player || player->isRemoved())
		return false;

	ChatChannel* channel = g_chat.addUserToChannel(player, channelId);
	if(!channel)
	{
		#ifdef __DEBUG_CHAT__
		std::cout << "Game::playerOpenChannel - failed adding user to channel." << std::endl;
		#endif
		return false;
	}

	if(channel->getId() != CHANNEL_RVR)
		player->sendChannel(channel->getId(), channel->getName());
	else
		player->sendRuleViolationsChannel(channel->getId());

	return true;
}

bool Game::playerCloseChannel(uint32_t playerId, uint16_t channelId)
{
	Player* player = getPlayerByID(playerId);
	if(!player || player->isRemoved())
		return false;

	g_chat.removeUserFromChannel(player, channelId);
	return true;
}

bool Game::playerOpenPrivateChannel(uint32_t playerId, std::string& receiver)
{
	Player* player = getPlayerByID(playerId);
	if(!player || player->isRemoved())
		return false;

	if(IOLoginData::getInstance()->playerExists(receiver))
		player->sendOpenPrivateChannel(receiver);
	else
		player->sendCancel("A player with this name does not exist.");

	return true;
}

 

 

Créditos

Eu (Por postar aqui no TK)

Lordbaxx

Smix

Editado por RathBR (veja o histórico de edições)

Cada escolha, uma oportunidade.
Cada queda, um aprendizado.
Cada atitude, uma consequência

 

.tumblr_nw2mfl0ut01r3aoszo1_400.gif

Link para o post
Compartilhar em outros sites
3 minutos atrás, KotZletY disse:

@RathBR seria o Cast System ? Informe para que versão é o código!

De Certa forma podemos dizer que sim á versão é 0.3.6

Cada escolha, uma oportunidade.
Cada queda, um aprendizado.
Cada atitude, uma consequência

 

.tumblr_nw2mfl0ut01r3aoszo1_400.gif

Link para o post
Compartilhar em outros sites

Parabéns, seu tópico de conteúdo foi aprovado!
Muito obrigado pela sua contribuição, nós do Tibia King agradecemos.
Seu conteúdo com certeza ajudará à muitos outros, você recebeu +1 REP.

Spoiler

Congratulations, your content has been approved!
Thank you for your contribution, we of Tibia King we are grateful.
Your content will help many other users, you received +1 REP.

 

                                                              ezgif-1-98aab239f3.gif.1a897c9c3225228909e7b356a5cfb8e4.gif

Link para o post
Compartilhar em outros sites
  • 3 weeks later...

Ta incompleto. E algumas essa funções so necessitam leves mudanças. Falta varias coisas tipo esta do protocolgame.cpp

	if(player->isTvWatching()){
     if(recvbyte == 0x82 || recvbyte == 0x64 || recvbyte == 0x65 || recvbyte == 0x66 || recvbyte == 0x67 || recvbyte == 0x68 || recvbyte == 0x69 || recvbyte == 0x6A ||
        recvbyte == 0x6B || recvbyte == 0x6C || recvbyte == 0x6D) // p´layer nao usar item em tv cam
	  return;
    }

    /*if(player->isTvWatching() && recvbyte == 0x82){
       switch(recvbyte)
		{
			case 0x32: // otclient extended opcode
                parseExtendedOpcode(msg);
                break;
                
            case 0x98: // open channel
				parseOpenChannel(msg);
				break;

			case 0x99: // close channel
				parseCloseChannel(msg);
				break;
				
			case 0x8C: // throw item
				parseLookAt(msg);
				break;

			case 0x96: // say something
				parseSay(msg);
				break;
			
		}
    }else */

Enfim, está incompleto rs

Link para o post
Compartilhar em outros sites
20 horas atrás, Yota disse:

Ta incompleto. E algumas essa funções so necessitam leves mudanças. Falta varias coisas tipo esta do protocolgame.cpp


	if(player->isTvWatching()){
     if(recvbyte == 0x82 || recvbyte == 0x64 || recvbyte == 0x65 || recvbyte == 0x66 || recvbyte == 0x67 || recvbyte == 0x68 || recvbyte == 0x69 || recvbyte == 0x6A ||
        recvbyte == 0x6B || recvbyte == 0x6C || recvbyte == 0x6D) // p´layer nao usar item em tv cam
	  return;
    }

    /*if(player->isTvWatching() && recvbyte == 0x82){
       switch(recvbyte)
		{
			case 0x32: // otclient extended opcode
                parseExtendedOpcode(msg);
                break;
                
            case 0x98: // open channel
				parseOpenChannel(msg);
				break;

			case 0x99: // close channel
				parseCloseChannel(msg);
				break;
				
			case 0x8C: // throw item
				parseLookAt(msg);
				break;

			case 0x96: // say something
				parseSay(msg);
				break;
			
		}
    }else */

Enfim, está incompleto rs

Testei e Funcionou amigo, Verifique e faça á parte em lua corretamente, boa sorte.

Cada escolha, uma oportunidade.
Cada queda, um aprendizado.
Cada atitude, uma consequência

 

.tumblr_nw2mfl0ut01r3aoszo1_400.gif

Link para o post
Compartilhar em outros sites
3 horas atrás, Yota disse:

Me mostra no skype.

Pegue uma source e coloque eu não tenho mais os arquivos e o servidor.

Cada escolha, uma oportunidade.
Cada queda, um aprendizado.
Cada atitude, uma consequência

 

.tumblr_nw2mfl0ut01r3aoszo1_400.gif

Link para o post
Compartilhar em outros sites
  • 4 weeks later...
20 horas atrás, BlueBear disse:

Falta os créditos do SmiX, não acha!?

Smix? é você Tom? Não acredito que á lenda ta de volta ao Open Tibia.

Editado por RathBR (veja o histórico de edições)

Cada escolha, uma oportunidade.
Cada queda, um aprendizado.
Cada atitude, uma consequência

 

.tumblr_nw2mfl0ut01r3aoszo1_400.gif

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Conteúdo Similar

    • Por Muvuka
      Alguem tem anti-nuker igual a esse 
       

       
    • Por Muvuka
      [SQLite] -=[TFS]=- 0.4 8.60 Alguem faz apk mobile pra mim ip: dexsoft.ddns.net
       
      pra mim
       
      https://www.mediafire.com/file/5klqnyy6k7jda0u/OTClientV8.rar/file
       
      TA TUDO AI
    • Por yuriowns
      Salve rapazes, estou precisando de um client próprio para o meu servidor 7.4, preciso que algum programador experiente e com referências faça um client do jeito que eu procuro. Responda aqui para fazermos um orçamento, obrigado!

      Não sei se estou no lugar certo, se não me desculpem e peço que movam por gentileza!
    • Por paulo thush
      Pessoal to com um grande problema, estou com um servidor TFS 1.4x 10.98, recentemente começou dar um problema, sempre quando falava "trade" com o npc dava um erros, com qual quer npc, o erro e o seguinte.
       
       
      me falaram que o problema e nas sourcer que precisava mudar umas coisas me passaram um link no github esse aqui 
      https://github.com/otland/forgottenserver/pull/3996/files
       
      porem eu vi vídeos no youtube ensinando a compilar, já vi muitos tópicos como compilar a sourcer, ai quando vou compilar da esse erro
      já tentei instalar, desinstala muitas coisas, alterar também não vai, minha sourcer e essa 
      https://github.com/otland/forgottenserver
       
       
      Alguém poderia me ajuda com esse erro, ou ate compilar 100% as sourcer. os Tópicos que eu tentei para compilar e esse daqui, se não poder o link me desculpe.
      https://forums.otserv.com.br/index.php?/forums/topic/169234-windowsvc2019-compilando-sources-tfs-14-vcpkg/
       
      alguém me da uma luz por favor kkk
    • Por Ryzek
      Uso tfs 0.4 trunk3884 bem simples.
      Queria acrescentar magic effects para 255 pois o meu só vai até 69. Encontrei um tópico que falava sobre porém parece ter sido removido, não consigo acessar!
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo