What's new

Welcome to Onforum.net - Web and gaming resource community

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Ask question

Ask Questions and Get Answers from Our Community

Answer

Answer Questions and Become an Expert on Your Topic

Contact Staff

Our Experts are Ready to Answer your Questions

Tutorial Channel Switcher Metin2

Antharas

Member
Joined
Mar 3, 2019
Messages
42
Reaction score
19
Points
8
Location
Munchen, Germany
Credits
0
Code:
cmd.cp:
    after:
        ACMD(do_warp);
    add:
        ACMD(do_channel_switch);

    after:
        { "mall_close",    do_mall_close,        0,            POS_DEAD,    GM_PLAYER    },
    add:
        { "channel",        do_channel_switch,        0,            POS_DEAD,    GM_PLAYER    },
    

cmd_general.cpp:
    
    after:
        ACMD(do_set_run_mode)
        {
            ch->SetNowWalking(false);
            ch->SetWalking(false);
        }
    add:
        ACMD(do_channel_switch)
        {
    
            char arg1[256];
            one_argument(argument, arg1, sizeof(arg1));
            if (!*arg1)
                    return;
            
            int new_ch;
            str_to_number(new_ch, arg1);
            if( new_ch <1 || new_ch >4)   // REPLACE 2 WITH YOUR MAX_CHANNEL
                return;
            if (!ch->IsPC())
                return;
            ch->ChannelSwitch(new_ch);
            
        }

char.h:
    
    after:
        void                StartWarpNPCEvent();
    add:
        void                            ChannelSwitch(int new_ch);
 

char.cpp:
    after:
        EVENTFUNC(warp_npc_event)
        {
            char_event_info* info = dynamic_cast<char_event_info*>( event->info );
            if ( info == NULL )
            {
                sys_err( "warp_npc_event> <Factor> Null pointer" );
                return 0;
            }
            LPCHARACTER    ch = info->ch;
            if (ch == NULL) { // <Factor>
                return 0;
            }   
            if (!ch->GetSectree())
            {
                ch->m_pkWarpNPCEvent = NULL;
                return 0;
            }
            FuncCheckWarp f(ch);
            if (f.Valid())
                ch->GetSectree()->ForEachAround(f);
            return passes_per_sec / 2;
        }

    add:
        void CHARACTER::ChannelSwitch(int new_ch){
            long lAddr;
            long lMapIndex;
            WORD wPort;
            long x = this->GetX();
            long y = this->GetY();
            if (!CMapLocation::instance().Get(x, y, lMapIndex, lAddr, wPort))
            {
                    sys_err("cannot find map location index %d x %d y %d name %s", lMapIndex, x, y, GetName());
                    return;
            }
            if(lMapIndex >= 10000){
                return;
            }
            
            std::map<WORD, int>micha;
            
            for(int i = 0; i < 4; i++){ //replace with maximum channels -1   actual 1300x - 1330x
                for(int i2 = 2; i2 < 9; i2++){ //replace with your core values actual  13x02 - 13x08
                    micha[13*1000 + i*100 + i2] = i+1;
                }       
            }
            //micha[13002] = 1;
            int chan;
            if(micha.find(wPort) != micha.end()){
                chan = micha[wPort];
            }else{return;}
            Stop();
            Save();
            
            if(GetSectree()){
                GetSectree()->RemoveEntity(this);
                ViewCleanup();
                EncodeRemovePacket(this);
            }
            TPacketGCWarp p;
            p.bHeader    = HEADER_GC_WARP;
            p.lX    = x;
            p.lY    = y;
            p.lAddr    = lAddr;
            p.wPort    = (wPort - 100*(chan-1) + 100*(new_ch-1));
            
            GetDesc()->Packet(&p, sizeof(TPacketGCWarp));
        }
Edit :
ch1:
13002 - 13008
ch2:
13102 - 13108
ch3:
13202 - 13208
ch4:
13302 - 13308 with your ports.

Py script + how to in description
have fun with it.
Mega Download.
 
Last edited:

Sentura

Member
Joined
Apr 6, 2019
Messages
74
Reaction score
6
Points
8
Credits
0
Ty for share :) i will see if works :p

For change ports for my ports How i can do this ? ( for(int i2 = 2; i2 < 9; i2++){ )
 

[RaffaeL]

Administrator
Administrator
Joined
Apr 12, 2019
Messages
99
Reaction score
74
Points
18
Location
Everywhere
Credits
0
Ty for share :) i will see if works :p

For change ports for my ports How i can do this ? ( for(int i2 = 2; i2 < 9; i2++){ )
Reading the code, you'll get it...
We have this
C++:
for(int i = 0; i < 4; i++){ //replace with maximum channels -1     actual 1300x - 1330x
                for(int i2 = 2; i2 < 9; i2++){ //replace with your core values actual  13x02 - 13x08
                    micha[13*1000 + i*100 + i2] = i+1;
                }
            }
so there, you can read like: micha[13000 + i multiplyed by100(where i is a value from 1 to 4 in this case )+ i2(where i2 is the min value from your core port)]

Now, let's assume that you have channel1/core1 port like 21003, into the code will be
C++:
for(int i = 0; i < 4; i++){
                for(int i2 = 3; i2 < 9; i2++){
                    micha[21*1000 + i*100 + i2] = i+1;
                }
            }
Then, your core2 port for the same channel should be 21103, and so on, and so forward...
I hope you\re getting the idea.
 

Sentura

Member
Joined
Apr 6, 2019
Messages
74
Reaction score
6
Points
8
Credits
0
Reading the code, you'll get it...
We have this
C++:
for(int i = 0; i < 4; i++){ //replace with maximum channels -1     actual 1300x - 1330x
                for(int i2 = 2; i2 < 9; i2++){ //replace with your core values actual  13x02 - 13x08
                    micha[13*1000 + i*100 + i2] = i+1;
                }
            }
so there, you can read like: micha[13000 + i multiplyed by100(where i is a value from 1 to 4 in this case )+ i2(where i2 is the min value from your core port)]

Now, let's assume that you have channel1/core1 port like 21003, into the code will be
C++:
for(int i = 0; i < 4; i++){
                for(int i2 = 3; i2 < 9; i2++){
                    micha[21*1000 + i*100 + i2] = i+1;
                }
            }
Then, your core2 port for the same channel should be 21103, and so on, and so forward...
I hope you\re getting the idea.


So my cores is

Ch1 game1 core: 13001 and game2 core: 13002
Ch2 game1 core: 13011 and game2 core: 13012
Ch3 game1 core: 13021 and game2 core: 13022
Ch4 game1 core: 13031 and game2 core: 13032

Gona be like this ?

for(int i = 0; i < 4; i++){
for(int i2 = 3; i2 < 9; i2++){
micha[13*1000 + i*100 + i2] = i+1;
}
}

Is that?
 

Sentura

Member
Joined
Apr 6, 2019
Messages
74
Reaction score
6
Points
8
Credits
0
Someone i think i know the preblem is serverinfo.py but i'm not shor :\

sys

 

Sonia

Administrator
Administrator
Joined
Jan 27, 2019
Messages
965
Reaction score
2,428
Points
93
Location
Bucharest
Website
dozadeblog.ro
Credits
128
So my cores is

Ch1 game1 core: 13001 and game2 core: 13002
Ch2 game1 core: 13011 and game2 core: 13012
Ch3 game1 core: 13021 and game2 core: 13022
Ch4 game1 core: 13031 and game2 core: 13032

Gona be like this ?

for(int i = 0; i < 4; i++){
for(int i2 = 3; i2 < 9; i2++){
micha[13*1000 + i*100 + i2] = i+1;
}
}

Is that?
Stop asking for support here... You have a special category for this! Bump for what???
 

Sentura

Member
Joined
Apr 6, 2019
Messages
74
Reaction score
6
Points
8
Credits
0
Stop asking for support here... You have a special category for this! Bump for what???

My question is about system so :\ why i gona creat a Post if all ready exist ?

but ok i creat a Post Sonia
 
shape1
shape2
shape3
shape4
shape7
shape8
Top