[release]Virtual Server (Beta edition)

Newbie Spellweaver
Joined
Dec 11, 2008
Messages
87
Reaction score
1
Okay, this is a simple, yet useful tool for those servers who have too many users but can't get more channels. Basically, it creates an instance for a user's party and puts a 30 minute timer on their screen. When the timer runs out, it warps them out.


This should work for any version.


How to Use:

First, create a script in trunk/scripts/event/ called "virtualserv". Put the following into that file:

PHP:
/**
-- Odin JavaScript --------------------------------------------------------------------------------
	Virtual Server
-- By ---------------------------------------------------------------------------------------------
	Lios of Storybox
-- Version Info -----------------------------------------------------------------------------------
	1.0 - First Version by Lios
---------------------------------------------------------------------------------------------------
**/
importPackage(net.sf.odinms.world);

var exitMap;
var minPlayers = 1;
var instanceId;

function init() {
	instanceId = 1;
}

function setup() {
	exitMap = em.getChannelServer().getMapFactory().getMap(100000000); // <exit>
	var instanceName = "Story" + instanceId;
	var eim = em.newInstance(instanceName);
	instanceId++;
	em.setProperty("newInstance",instanceName);
	var eventTime = 30 * (1000 * 60);
	em.schedule("timeOut", eventTime);
	eim.startEventTimer(eventTime);
	return eim;
}

function playerEntry(eim, player) {
	var map = eim.getMapInstance(100000000);
	player.changeMap(map, map.getPortal(0));
}

function playerDisconnected(eim, player) {
	if (eim.isLeader(player)) { // Check for party leader
		// Boot whole party and end
		var party = eim.getPlayers();
		for (var i = 0; i < party.size(); i++) {
			if (party.get(i).equals(player)) {
				removePlayer(eim, player);
			} else {
				playerExit(eim, party.get(i));
			}
		}
		eim.dispose();
	} else { // Boot disconnected player
		var party = eim.getPlayers();
		if (party.size() < minPlayers) {
			for (var i = 0; i < party.size(); i++) {
				playerExit(eim,party.get(i));
			}
			eim.dispose();
		} else
			playerExit(eim, player);
	}
}

function playerExit(eim, player) {
	eim.unregisterPlayer(player);
	player.changeMap(exitMap, exitMap.getPortal(0));
}

// For offline players
function removePlayer(eim, player) {
	eim.unregisterPlayer(player);
	player.getMap().removePlayer(player);
	player.setMap(exitMap);
}

function timeOut() {
	var iter = em.getInstances().iterator();
	while (iter.hasNext()) {
		var eim = iter.next();
		if (eim.getPlayerCount() > 0) {
			var pIter = eim.getPlayers().iterator();
			while (pIter.hasNext()) {
				playerExit(eim, pIter.next());
			}
		}
		eim.dispose();
	}
}

After that, Open world.properties. Scroll to the bottom where you see where it loads event scripts. Add a comma and "virtualserv" (without the quotes) to that list. Save and close.

Next, take whichever NPC you want to be your instance creator and create a script for it. In that script, use this code:
PHP:
var status = 0;
var em;
var sub;
function start(){
status = -1;
action(1,0,0);
}

function action(mode, type, selection) { 
 if (mode == -1) { 
  cm.dispose(); 
 } else { 
  if (status >= 0 && mode == 0) { 
   cm.sendOk("Ok, feel free to hang around until you're ready to go!"); 
   cm.dispose(); 
   return; 
  } 
  if (mode == 1) 
   status++; 
  else 
   status--; 
	if(status == 0){
cm.sendSimple("Hey there! What can I do for you?\r\n\r\n#b#L3#I would Like to go into the virtual world!#l\r\n");
	}else if(status == 1){
if(cm.getParty() != null){
	cm.sendYesNo("I can let you and your party into your very own training world for a half hour, but it'll cost you 5 million mesos to go there! Would you like to go there?");
	sub = "partywarp";
	}else{
	cm.sendOk("You need a party for that!")
	cm.dispose();
	}
	}else if(status == 2){
	if(sub == "partywarp"){
	if(cm.getChar().getMeso() >= 5000000){
					em = cm.getEventManager("virtualserv");
					em.getIv().invokeFunction("setup", null);
					eim = em.getInstance(em.getProperty("newInstance"));
					if(em == null || eim == null){
					cm.sendOk("Error");
					cm.dispose();
					}else{
					cm.gainMeso(-5000000);
					eim.registerParty(cm.getParty(), cm.getChar().getMap());
					cm.sendOk("Welcome to #bVirtualServ#k-#rBeta Edition!#k It's not quite the same as another server, but it's similar.\r\nHere are a few simple rules to follow:\r\n1) Do exploit glitches you may find. Report them instead\r\n2)If you wish to cut your time short, or DC, do not go crying to a GM for a refund. We are not responsible for you choosing to use this feature in beta\r\nIf you have any questions at all, simply ask one of the GM's!\r\nGood luck, and happy mapling~!");
					cm.dispose();
					}
	}else{
	cm.sendOk("You don't have enough mesos!");
	cm.dispose();
	}
	}
	}
}
}


Edit the price out if you wish. Also feel free to change the rules.

After that, restart the server and you should be good to go.

Here's a list of known things that will cause the user to exit the instance:
Code:
--+Changing Channels
--+Using Return Scrolls
--+Using "Goto" commands.

Teleport NPC's still work. If the player wishes to cut the instance short, they may simply Change channels.

I know it's simple, but hey, my players seem to like it =]

If you have any bugs, feel free to post them.

Screenshots coming soon!
This is the NPC that lets you in:
og.Lios - [release]Virtual Server (Beta edition) - RaGEZONE Forums



The rules:
og.Lios - [release]Virtual Server (Beta edition) - RaGEZONE Forums



Notice the chat bar:
og.Lios - [release]Virtual Server (Beta edition) - RaGEZONE Forums

If this release helped you, or if you're using it, please let me know~! Constructive criticism is welcomed.
 
Last edited:
Re: Virtual Server (Beta edition)

What it does is it creates a second instance for all maps. For example. Think of the free-market on channel 1. Usually a lot of people are there. Well this creates a separate instance for the user for 30 minutes. It's like they're playing with just their party for those 30 minutes.

It's hard to explain. It's like a mini-dungeon throughout the world.

Instances are very hard to grasp, but if you understand them, you can do a lot with them.
 
Re: Virtual Server (Beta edition)

hey this is really nice and unique. i never thought this was possible. will it lag the hel;l out of the server if there are many instances at a time?
 
Re: Virtual Server (Beta edition)

lol his release does this : eg. u are training in skele map and the server only has 2 chnls, therefore many people are training in that map right? thus causing alot of ks wars. to prevent this, this guy added this timer so that it warps the player out of the map after the player has stayed 30mins in that map, thus prevents overcrowding and ksing in tha map to some extend
 
Re: Virtual Server (Beta edition)

Can GMs warp to peoples instances...or is this officially 'Hackers Heaven'?
 
Re: Virtual Server (Beta edition)

what does his do im lost..

Learn to read (and I've come to a conclusion, the activity award, is the how much I can spam award. I guess this guy, viinnh is continuing ihatehaxor's legacy :rolleyes:

What it does is it creates a second instance for all maps. For example. Think of the free-market on channel 1. Usually a lot of people are there. Well this creates a separate instance for the user for 30 minutes. It's like they're playing with just their party for those 30 minutes.

It's hard to explain. It's like a mini-dungeon throughout the world.

Instances are very hard to grasp, but if you understand them, you can do a lot with them.
 
It actually tends to save the lag for the user, simply because they don't have to see the skills and other things on the map.
 
Back