• Concept of server hopping based on going through a certain part of a map?
    5 replies, posted
Hello, i'm asking about the concept of server hopping when going into a certain area since it's a well known and strived for concept which no one ends up following through on. I'm not going to ask someone to hold my and through it but after my exams are finished i'm planning on going into more depth with my Lua knowledge and figuring out how to do such a thing. From what I've heard it's a lot more complicated than creating an area with coordinates and having it run "connect gayIP.192.168" on the client when they enter it. If someone would be aware of the prerequisites i'd have to have knowledge on to perform such a thing could you kindly leave it in a reply to this thread. Thankyou, -Tom
[quote]From what I've heard it's a lot more complicated than creating an area with coordinates and having it run "connect gayIP.192.168" on the client when they enter it.[/quote] You heard wrong. It's as simple as checking if a player is in a certain area and if so, run the console command "connect" with the specified IP. You'll need to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/WithinAABox]Vector:WithinAABox[/url] [B]OR[/B] check for the [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/Distance]Vector:Distance[/url] from a certain point in the world to the player's position ([img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetPos]Entity:GetPos[/url]) Then run [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/ConCommand]Player:ConCommand[/url] on the player and tell him to connect to your IP
It technically is as simple as above, but if you want to have any kind of dynamic stuff going on with the player coming from another server then you'd need to have some kind of communication between the two. For example you had 2 servers that you wanted people to be able to connect to separately and spawn in as new players, but you also want people to be able to enter say a tunnel on the map on one server and when they connect to the new server spawn them at the exit to the same tunnel with the same weapons or whatever. Even this isn't all that difficult, you could for example have a sql database where when the player enters the area and leaves the server, the server saves an entry with all the info you need, then the new server just checks if an entry exists for that player and if so spawns them in the right spot and does any other necessary stuff to them, if not just spawns them as normal.
[QUOTE=Cushie;52281573]It technically is as simple as above, but if you want to have any kind of dynamic stuff going on with the player coming from another server then you'd need to have some kind of communication between the two. For example you had 2 servers that you wanted people to be able to connect to separately and spawn in as new players, but you also want people to be able to enter say a tunnel on the map on one server and when they connect to the new server spawn them at the exit to the same tunnel with the same weapons or whatever. Even this isn't all that difficult, you could for example have a sql database where when the player enters the area and leaves the server, the server saves an entry with all the info you need, then the new server just checks if an entry exists for that player and if so spawns them in the right spot and does any other necessary stuff to them, if not just spawns them as normal.[/QUOTE] I wouldn't say mysql/webserver isn't difficult, especially for a newcomer (Or anyone not familiar with the former)
I'm planning on using rp_florida anyway and it contains lots of different empty stores, i may just make a travel agent's office and allow them to travel to the different servers using a computer entity which opens a derma menu but have the server they FIRST JOIN/WERE LAST "TRAVELED on" as the only server they can connect from directly from ip, that i could use sql for. So i have a table and only one of the records could be set to true at a time (I know i'm definitely using the wrong words for what i mean in terms of sql), idk how to explain it but it'd have a structure like this; [IMG]http://i.imgur.com/aRBZ28d.png[/IMG] I imagine this would be a bit complex to achieve but i will have 12 weeks off after the 16th of June so i'll have time to learn. If anyone has any helpful input they could give to me about achieving this or what would be better than the aforementioned idea i'm completely open to criticism. Thanks, -Tom
To hook your database up with your server use: [code] require ("mysqloo") // Include the modules local DATABASE_HOST = "www.freesql.org" // database host (can be an ip) local DATABASE_PORT = 3306 // port to the database, you probably wont need to change this unless you get told to local DATABASE_NAME = "bamboserver" // name of the database local DATABASE_USERNAME = "bambo" // username which you use to access it local DATABASE_PASSWORD = "root" // password of the username function connectToDatabase() databaseObject = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT) databaseObject.onConnected = function() print("Database linked!") end databaseObject.onConnectionFailed = function() print("Failed to connect to the database.") end databaseObject:connect() end connectToDatabase() [/code] Then, you can create a function which runs a query to add the user to the database: [code] function initialJoin( ply ) local query = databaseObject:query("SELECT * FROM Players WHERE ID = '" .. ply:SteamID() .. "'") local evo = false local florida = false local rock = false query.onSuccess = function(q) if (string.find(string.lower(game.GetMap()), "evocity")) then evo = true elseif (string.find(string.lower(game.GetMap()), "florida")) then florida = true elseif (string.find(string.lower(game.GetMap()), "rockford")) then rock = true end if not checkQuery(q) then local insert = databaseObject:query("INSERT INTO Players(steamID, evocity, florida, rockford) VALUES ('" .. ply:SteamID() .. "', '" .. evo .. "', '" .. florida .. "', '" .. rock .. "')") insert:start() else //User already exists, just replace current map local update = databaseObject:query("UPDATE Players SET evocity = ' .. evo .. ', florida = ' .. florida .. ', rockford = ' .. rock .. ' WHERE steamID = ' .. ply:SteamID() .. '") update:start() end end hook.Add( "PlayerInitialSpawn", "PlayerInitialSpawn", initialJoin ) [/code] Then, make a function where the user enters the area, they join the other server and you can use the following query to get the player's previous map: [code] function getMap(ply) local get = databaseObject:query("SELECT evocity, florida, rockford FROM Players WHERE steamID = ' .. ply:SteamID() .. '") function get:OnSuccess(data) local row = data[1] local count = 0 for k, v in pairs(row) do count = count +1 if v == true then local map = data[count] end end end end hook.Add( "PlayerInitialSpawn", "PlayerInitialSpawn", getMap ) [/code] Untested, but it gives you an idea.
Sorry, you need to Log In to post a reply to this thread.