Jump to content
  • We need you!

    You must register to discover all the features of our community!

  • 0

Is it possible to check if a channel is running?


TMP4

Question

Posted (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? :D 

Edited by TMP4 (see edit history)
Link to post

10 answers to this question

Recommended Posts

  • 0
Posted (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 by ridetpro (see edit history)
Link to post
  • 0
Posted (edited)

It's not gonna work because this channel is normal channel like channel1, i just decided to set it as channel98 :D

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 by TMP4 (see edit history)
Link to post
  • 0
Posted (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 :D

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 by ridetpro (see edit history)
Link to post
  • 0
Posted (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 by TMP4 (see edit history)
Link to post
  • 0
Posted (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 :D 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 by ridetpro (see edit history)
Link to post
  • 0
Posted (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 by TMP4 (see edit history)
Link to post
  • 0
Posted (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 by ridetpro (see edit history)
Link to post
  • 0
Posted (edited)

No problem :D

 

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 by TMP4 (see edit history)
Link to post
  • 0

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 !

 

  • Love 1
Link to post
  • 0
Posted (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 by TMP4 (see edit history)
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.