- 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:
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:
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:
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!
If this release helped you, or if you're using it, please let me know~! Constructive criticism is welcomed.
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:
The rules:
Notice the chat bar:
![og.Lios - [release]Virtual Server (Beta edition) - RaGEZONE Forums og.Lios - [release]Virtual Server (Beta edition) - RaGEZONE Forums](https://forum.ragezone.com/images/404_image.png)
The rules:
![og.Lios - [release]Virtual Server (Beta edition) - RaGEZONE Forums og.Lios - [release]Virtual Server (Beta edition) - RaGEZONE Forums](https://forum.ragezone.com/images/404_image.png)
Notice the chat bar:
![og.Lios - [release]Virtual Server (Beta edition) - RaGEZONE Forums og.Lios - [release]Virtual Server (Beta edition) - RaGEZONE Forums](https://forum.ragezone.com/images/404_image.png)
If this release helped you, or if you're using it, please let me know~! Constructive criticism is welcomed.
Last edited: