Contributor TMP4 10993 Posted May 28, 2020 Contributor Share Posted May 28, 2020 (edited) The base situation: i have an event channel (channel98) and i want to check in a quest if the event channel is running or not. I know there is no such quest function, so i need a c++ code for questlua_global or questlua_game.cpp. Spoiler I want something like this if ChannelRunning(98) then chat("channel is running!") else chat("channel is offline!") end Anyone have a clue how can i check if a channel is running? Edited May 28, 2020 by TMP4 Link to comment Share on other sites More sharing options...
ridetpro 116 Posted May 28, 2020 Share Posted May 28, 2020 (edited) You have a quick method here, first of all identify a map on that channel. This method only checks a respective core, if you have a channel on the cores. int pc_is_map_alive(lua_State* L) { LPCHARACTER ch = CQuestManager::Instance().GetCurrentCharacterPtr(); lua_pushboolean(L, map_allow_find(lua_tonumber(L, 1))); return 1; } {"is_map_alive", pc_is_map_alive}, I think is better to check if a core is up/down because when u get crash it won't crash whole channel usage : local channel = pc.is_map_alive(41) or pc.is_map_alive(100) -- map 41 , check core 1 -- map 100, check core 2 if channel then -- Do something end So, basically check if the map is found. If the map is found then the channel is alive. You can add in questlua_global, since channels/cores works for everyone not for a single player.. How u wish Edited May 28, 2020 by ridetpro Link to comment Share on other sites More sharing options...
Contributor TMP4 10993 Posted May 28, 2020 Author Contributor Share Posted May 28, 2020 (edited) It's not gonna work because this channel is normal channel like channel1, i just decided to set it as channel98 So it's not an "exclusive-maps" channel like channel99 where i could check metin2_map_oxevent. Edit: It is possible to check if a port is open? Then the channel is running. Edited May 28, 2020 by TMP4 Link to comment Share on other sites More sharing options...
ridetpro 116 Posted May 28, 2020 Share Posted May 28, 2020 (edited) 2 minutes ago, TMP4 said: It's not gonna work because this channel is normal channel like channel1, i just decided to set it as channel98 So it's not an "exclusive-maps" channel like channel99 where i could check metin2_map_oxevent. just read over and over what i wrote, you can't check a whole channel.. Because a channel is made from cores.. If you want to check only ch99, identify some maps on all cores from ch99 and do the checks as i said above What if you get a crash on a single core? on ch99.. you can't read the status of whole channel. Edited May 28, 2020 by ridetpro Link to comment Share on other sites More sharing options...
Contributor TMP4 10993 Posted May 28, 2020 Author Contributor Share Posted May 28, 2020 (edited) Okey then it's ok if i can check a channel's first core. (If the first core is running, the second core should running so it's ok) Do you have any reccomendation? Again: It is a normal channel, not exclusive maps channel. Also the check happens in ch1 core1 before it channel_switchs the player to ch98 core1. Edited May 28, 2020 by TMP4 Link to comment Share on other sites More sharing options...
ridetpro 116 Posted May 28, 2020 Share Posted May 28, 2020 (edited) 18 minutes ago, TMP4 said: Okey then it's ok if i can check a channel's first core. (If the first core is running, the second core should running so it's ok) Do you have any reccomendation? Again: It is a normal channel, not exclusive maps channel. local ch1_core1_on = pc.is_map_alive(41) -- Check a map from ch1_core1 local ch1_core2_on = pc.is_map_alive(100) --Check a map from ch1_core2 local ch2_core1_on = pc.is_map_alive(200) --Check a map from ch2_core1 if ch1_core1_on then say("ch1_core1_online") end if ch1_core1_on and ch1_core2_on then say("Whole ch1 is on") end Check how it should look a whole chanel online/offline.. Or you can check just core1 As you wish And btw, u should rename is_ And you set an unique map, without any usage in client.. in each channel core 1 Edited May 28, 2020 by ridetpro Link to comment Share on other sites More sharing options...
Contributor TMP4 10993 Posted May 28, 2020 Author Contributor Share Posted May 28, 2020 (edited) The problem is your map checking solution is not working at all. You don't understand how cores working. Example: 41 is defined in all ch core1 (except ch99 of course) If we want to check channel2 core1 (or channel 98 core 1 in my case, does not matter) when the character is in channel1 core1. It will always return true because channel1 contains 41 too. Edited May 28, 2020 by TMP4 Link to comment Share on other sites More sharing options...
ridetpro 116 Posted May 28, 2020 Share Posted May 28, 2020 (edited) 2 minutes ago, TMP4 said: The problem is your map checking solution is not working at all. You don't understand how cores working. Example: 41 is defined in all ch core1 (except ch99 of course) I want to check channel2 core1 when the character is in channel1 core1. It will always return true because channel1 contains 41 too. AHHH, well.. i will check when i am back home.. U are right, i am driving right now xD :::: You can just set a fake unique map, on each channel core1 btw Edited May 28, 2020 by ridetpro Link to comment Share on other sites More sharing options...
Contributor TMP4 10993 Posted May 28, 2020 Author Contributor Share Posted May 28, 2020 (edited) No problem So i think the best way is to check for open ports. Anyone have a clue how to do it in source questlua? -------------------------------- 10 minutes ago, ridetpro said: You can just set a fake unique map, on each channel core1 btw It will still not work because it only checks the map in that core where the character is. So example the char is in channel1 core1, i put an index250 map in channel2 core1, and i try pc.is_map_alive(250) it will look the map 250 in channel1 core1, not in channel2 core1, because the character is in channel1. Edited May 28, 2020 by TMP4 Link to comment Share on other sites More sharing options...
ElRenardo 25 Posted May 28, 2020 Share Posted May 28, 2020 Hi, To check if a channel is running, you could eventually look at the set of the connected p2p peers ("m_set_pkPeers" defined in "p2p.h"). Every channel are sending some data to each others this way. If the channel is not connected, it won't be listed. I found out that there is a function in desc_manager.cpp that is looking for an existing connection regarding the P2P port of it. "bool DESC_MANAGER::IsP2PDescExist(const char * szHost, WORD wPort)" You can create a new one and use the "GetP2PChannel()" function instead of the "GetP2PPort()". Then you just have to create a simple lua function. That could be a way to do that. But for your usage, I would definitly stick to a global quest_flag. Good luck ! 1 Link to comment Share on other sites More sharing options...
Contributor TMP4 10993 Posted May 29, 2020 Author Contributor Share Posted May 29, 2020 (edited) Thanks i solved with that! The channel is not running every time, that's why i don't use a gameflag (/e something) Anyway it can be good for channel changer too if someone want to use the GF one. questlua_global (cpp) int _is_channel_online(lua_State * L) { if (true == DESC_MANAGER::instance().IsP2PDescExistNew(g_szPublicIP, (BYTE)lua_tonumber(L, 1))) { lua_pushboolean(L, true); return 1; } lua_pushboolean(L, false); return 1; } { "is_channel_online", _is_channel_online }, desc_manager (cpp+h) bool DESC_MANAGER::IsP2PDescExistNew(const char * szHost, BYTE bChannel) { CLIENT_DESC_SET::iterator it = m_set_pkClientDesc.begin(); while (it != m_set_pkClientDesc.end()) { LPCLIENT_DESC d = *(it++); if (!strcmp(d->GetP2PHost(), szHost) && d->GetP2PChannel() == bChannel) return true; } return false; } bool IsP2PDescExistNew(const char * szHost, BYTE bChannel); Edited May 29, 2020 by TMP4 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now