Author Topic: Portal between Servers  (Read 1017 times)

Legacy_Jenna WSI

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Portal between Servers
« on: September 11, 2011, 06:23:27 pm »


               What's the best way to set this up? I'd like you to be able to see the players in both servers on one list, regardless of which server you're on... and be able to talk to them. I've seen this done but I'm not sure how. A look through the vault turned up the following, but is it the best way to do this?

http://nwvault.ign.c...r.Detail&id=661
http://nwvault.ign.c...s.Detail&id=176
http://nwvault.ign.c...ts.Detail&id=48
http://nwvault.ign.c...s.Detail&id=139
               
               

               
            

Legacy_Jenna WSI

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Portal between Servers
« Reply #1 on: September 11, 2011, 09:48:27 pm »


               Seems one of our linux guys can set up the servers, aside from the actual scripting portals part. So.. I'm curious if there's a way to use NWNx2 chat plugins to make server shouts go across both servers?
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Portal between Servers
« Reply #2 on: September 13, 2011, 09:31:42 pm »


               Cross Server shouts can 'possibly' be done on linux with a nwnx plugin.

I know there is alot of extensibility with the ruby plugin, but I think there was also a udp plugin too.

Basically, the problem you have, in trying to do cross server shouts, is that you need to send the information outside of nwn, and then receive it, and get it back into nwn on the otherside.

the UDP Plugin can send the data, I dont know about receiving it though.

Another way, would be to insert the data/shouts, into a common database/table, shared accross the 2 servers, when the second server sees a shout appear, it then relays it to all the players, and wipes it from the database, to prevent duplication.
               
               

               
            

Legacy_Jenna WSI

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Portal between Servers
« Reply #3 on: September 13, 2011, 10:14:46 pm »


               Sounds plausible... thanks, I'll look at those plugins and ask our linux guys.
               
               

               
            

Legacy_Birdman076

  • Sr. Member
  • ****
  • Posts: 320
  • Karma: +0/-0
Portal between Servers
« Reply #4 on: September 13, 2011, 11:33:23 pm »


               Almost positive HG has cross server shouts, might want to send a pm to Funky. There is also an NWNX_Vaultster plugin which I believe portals players between servers using the same server vault.
               
               

               


                     Modifié par Birdman076, 13 septembre 2011 - 10:52 .
                     
                  


            

Legacy_Jenna WSI

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Portal between Servers
« Reply #5 on: October 31, 2011, 02:55:40 pm »


               Looking into doing this now. On the server I saw it done on, the players in the main part of the server were still on the player list even when you logged into the intro server... and you could talk to them in tells between servers or join thier party. Any info on how this is done?
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Portal between Servers
« Reply #6 on: November 01, 2011, 03:39:58 am »


               Pretty sure it's a single server, using a nwnx plugin, I don't know the name off hand.  Probing around on the nwnx Forums should yeild something.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Portal between Servers
« Reply #7 on: November 01, 2011, 06:05:27 am »


               Interservers are easy, just use a mysql database accessible to all the involved servers to put messages in, and retrieve them from module heartbeats and broadcast to the player or channel specified - doesn't have to be a linux server. Portalling doesn't even require nwnx. Here's our portal command:

            } else if (GetStringLeft(sCText, 7) == "portal ") {
                DeleteLocalString(oCPC, "FKY_CHAT_LOCAL_CTEXT");

                int nServer;
                sCText = GetStringRight(sCText, GetStringLength(sCText) - 7);

                if (GetIsInCombat(oCPC) && !VerifyDMKey(oCPC) && !VerifyAdminKey(oCPC)) {
                    FloatingTextStringOnCreature(COLOR_RED + "You cannot portal during combat!" + COLOR_END, oCPC, FALSE);
                    return;
                }

                if (sCText == "here")
                    nServer = StringToInt(GetLocalString(GetModule(), "ServerNumber"));
                else
                    nServer = StringToInt(sCText);

                if (nServer < 110 || nServer > 999) {
                    FloatingTextStringOnCreature(COLOR_RED + "You cannot portal to that server!" + COLOR_END, oCPC, FALSE);
                    return;
                }

                SQLExecDirect("SELECT srv_id, srv_utime, srv_addr, srv_port FROM server_list WHERE srv_id = " + IntToString(nServer) +
                              " AND srv_utime + 60 >= (UNIX_TIMESTAMP() - srv_btime)");

                if (SQLFetch() != SQL_SUCCESS) {
                    FloatingTextStringOnCreature(COLOR_RED + "That server is not active!" + COLOR_END, oCPC, FALSE);
                    return;
                }

                if (!VerifyAdminKey(oCPC) && StringToInt(SQLGetData(2)) < 60) {
                    FloatingTextStringOnCreature(COLOR_RED + "That server has not been up for a minute yet!" + COLOR_END, oCPC, FALSE);
                    return;
                }

                string sAddr = SQLGetData(3) + ":" + SQLGetData(4);
                FloatingTextStringOnCreature(COLOR_GREEN + "Portaling you to " + sAddr + "!" + COLOR_END, oCPC, FALSE);

                ActivatePortal(oCPC, sAddr, "", "", FALSE);
                SetPlotFlag(oCPC, FALSE);
            }

The servers are distinguished using the get port portion of the ip, which DOES require nwnx. The set a local on the server as it loads, so that all the servers can run the same version of the module. On pulling up the code to post it, I see we no longer do it that way. Instead, we now read from a file using another nwnx function, though we still do use the SQL code to check ip. Either way, if you're linking different ips, or if you just want to manaully enter the data in script for all the servers, you don't need this command - it just allows us to drop and add servers without recoding anything. Here's the load code, in two parts:


    string sSQL, sServerNumber = FileReadAll("serverid.txt");
    int nServerNumber = StringToInt(sServerNumber);

    if (nServerNumber >= 100) {
        sServerNumber = IntToString(nServerNumber);
    } else {
        string sServerIP;

        sSQL = "select substring_index(user(), '@', -1) as ip;";
        SQLExecDirect(sSQL);

        if (SQLFetch() == SQL_SUCCESS)
            sServerIP = SQLGetData(1);
        else
            sServerIP == "";

        sServerNumber = GetStringRight(sServerIP, 3);
        nServerNumber = StringToInt(sServerNumber);
    }

    if ((nServerNumber >= 100) && (nServerNumber <= 999)) {
        WriteTimestampedLogEntry("running as server " + sServerNumber + " (module object " + ObjectToString(GetModule()) + ")");
        SetLocalString(OBJECT_SELF, "ServerNumber", sServerNumber);
    } else {
        WriteTimestampedLogEntry("Error finding server ip!");

        nServerNumber = 101;
        sServerNumber = "101";

        SetLocalString(OBJECT_SELF, "ServerNumber", "101");
    }

    if (nServerNumber % 10 == 9) {
        SetLocalInt(oMod, "FKY_CHAT_ENABLE_PARTY_TO_AREA", 1);
        SetLocalInt(oMod, "FKY_CHAT_ENABLE_SHOUT_TO_AREA", 1);
        SetLocalInt(oMod, "FKY_CHAT_ENABLE_TELL_OOC_PREFIX", 1);
        SetLocalInt(oMod, "FKY_CHAT_DISALLOW_SPEECH_WHILE_DEAD", 1);
        SetLocalInt(oMod, "FKY_CHAT_DISALLOW_SPEECH_WHILE_SILENCED", 1);
    }


Here's part 2:



    if (SQLFetch() == SQL_SUCCESS) {
        string sBootTime = SQLGetData(1);
        string sServerAddr = FileReadAll("serveraddr.txt");
        string sServerPort = FileReadAll("serverport.txt");

        if (StringToInt(sServerPort) < 5000)
            sServerPort = "512" + IntToString(nServerNumber % 10);

        SetLocalInt(oMod, "boottime", StringToInt(sBootTime));
        SetLocalString(oMod, "ServerAddr", sServerAddr);
        SetLocalString(oMod, "ServerPort", sServerPort);

        SQLExecDirect("REPLACE INTO server_list (srv_id, srv_btime, srv_utime, srv_memory, srv_players, srv_addr, srv_port, srv_last) VALUES ('"
                      + sServerNumber + "', " + sBootTime + ", 0, 0, 0, '" + sServerAddr + "', " + sServerPort + ", NOW())");
    }

LMK if you have any questions.

Funky
               
               

               


                     Modifié par FunkySwerve, 01 novembre 2011 - 06:14 .
                     
                  


            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Portal between Servers
« Reply #8 on: November 01, 2011, 03:34:07 pm »


               Can read info here: http://www.nwnx.org/...er=asc&start=15

Page 2 contains a supposedly fixed plugin.   This comes with it's own issues, read all the posts on page 2 and you'll understand better.


nwnx_haks
- New alpha plugin. Allows abitrarily hiding haks and setting a
fallback TLK for players logging in. Currently the script that
checks whether a login is 'enhanced' or not is hardcoded. Haks
can be hidden by level. E.g. a 'basic level' (1) that includes
a top hak with custom classes & a 'full level' that includes
tilesets, etc. It would be up to the builder to ensure that
a player didn't go places that had content he/she did not have the
haks to see. I use it to add custom haks and also a fallback
to CEP and hiding server side HAKs from players.
- Functions: exposed to scripts
int SetFallBackTLK(string sTLK);
int SetHakHidden(string sHak, int nLevel = 1);
void DumpHakList();
void SetPlayerEnhanced(object oPC, int nEnhanced);


               
               

               


                     Modifié par Calvinthesneak, 01 novembre 2011 - 03:42 .