- Joined
- Dec 11, 2008
- Messages
- 87
- Reaction score
- 1
Yeah, I know, you're probably sick of all these instance releases, but they're fun for me :3
Anyway, it basically gives players their own room for a certain amount of mesos.
Changelog:
Todo:
How to do it:
First, create a file called playerHangout.js in your events folder in scripting. Put the following code in it:
Save that and close it. Next, add the instance to world.properties. This should be simple.
After that, stick this into any NPC you'd like. This will be your warper:
Save that and close that.
Next, put the following NPC script in the NPC that is in your Hangout map.
Save and Close.
Restart the server and you should be good.
I'm hoping by now you all know how to work with instances. I've commented the lines so that hopefully anyone who can analyze a script can learn to script themselves.
Credits to myself on everything.
Screen Shots:
If you have any suggestions/questions/comments, please do make them!
Just a note, this, along with most of my releases, are Storybox originals. If you plan to use them in a repack, please give credit to "Lios of Storybox"
Thank you for using this release!
Also, please post if you're planning to use this for your server. I like to know where my releases are going and if they're popular
<3
Anyway, it basically gives players their own room for a certain amount of mesos.
Changelog:
Code:
Version 1.0.0 - Lios. Initial Version
Todo:
Code:
--+Add passwords.
How to do it:
First, create a file called playerHangout.js in your events folder in scripting. Put the following code in it:
PHP:
/**
-- StoryBox JavaScript --------------------------------------------------------------------------------
Hangout instances
-- By ---------------------------------------------------------------------------------------------
Lios of Storybox
Ragezone Account: og.Lios
-- Version Info -----------------------------------------------------------------------------------
1.0 - Lios. First version.
---------------------------------------------------------------------------------------------------
**/
var eim;
var exitMap;
var instanceName;
var prh;
var exitMapNum = 910000000; //Edit this to whichever map you please. Default is Free Market
var HangoutMap;
var HangoutMapInt = 920011200; //Edit this to whichever map you would like the home to be. Default is OPQ End Map.
function init(){
instanceName = "Hangout_";
em.getIv().invokeFunction("setup",null);
}
function setup(){
exitMap = em.getChannelServer().getMapFactory().getMap(exitMapNum); // exits to exitMapNum
var eim = em.newInstance(instanceName); //These two lines are basically Worthless, as the default instance is never used.
return eim; //However, we need to call an instance whenever initiating an event.
}
function playerEntry(eim, player){
var mostRecentRoom = "Hangout_" + em.getProperty("mRR");
if(em.getInstance(mostRecentRoom) == null){
em.newInstance(mostRecentRoom); //Only occurs when player makes a n
}
prh = em.getInstance(mostRecentRoom);
map = prh.getMapInstance(HangoutMapInt); //You may change this to any map you would like.
player.changeMap(map, map.getPortal(0));
}
function playerDisconnected(eim, player) {
playerExit(eim, player);
}
function playerExit(eim, player) {
eim.unregisterPlayer(player);
player.changeMap(exitMap, exitMap.getPortal(0));
}
//For those dced
function removePlayer(eim, player) {
eim.unregisterPlayer(player);
player.getMap().removePlayer(player);
player.setMap(exitMap);
}
Save that and close it. Next, add the instance to world.properties. This should be simple.
After that, stick this into any NPC you'd like. This will be your warper:
PHP:
var roomName;
var Pass;
var em;
var eim;
var lazy;
var cost = 1000000; //Cost of the hangout. Defaults to 1,000,000
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!");
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendNext("Hey there! I'm in charge of #rPlayer Hangouts!#k");
}else if(status == 1){
cm.sendSimple("How may I help you?#b\r\n\r\n#L0#What are Player Hangouts About?#l\r\n#L1#I would like to create a room#l\r\n#L2#I would like to enter a room#l\r\n#k");
}else if(status == 2){
if(selection == 0){
cm.sendNext("Player hangouts are personalized rooms that allow you to hang out with friends. They're private places where you can have discussions with your friends and others. It costs #r" + cost + "#k Mesos to create a hangout, but once you leave the hangout, you can go back for free, so long as there isn't a server restart and you remember your room name!");
status = 0;
}else if(selection == 1){
status = 1336;
cm.sendGetText("Please enter the name of the room you wish to create");
}else{
cm.sendGetText("Please enter the name of the room you wish to enter");
}
}else if(status == 3){
roomName = "Hangout_" + cm.getText();
lazy = cm.getText();
em = cm.getEventManager("playerHangout");
teim = em.getInstance(roomName);
if(teim == null){
cm.sendOk("Either you made a mistake, or that room doesn't exist! Try again.");
status = 1;
}else{
cm.sendNext("Perfect! We'll be on our way!");
}
}else if(status == 4){
eim = em.getInstance("Hangout_");
em.setProperty("mRR", lazy);
eim.registerPlayer(cm.getChar());
cm.sendOk("All right! Have fun~!");
cm.dispose();
}else if(status == 1337){
em = cm.getEventManager("playerHangout");
roomName = cm.getText();
var teim = em.getInstance("Hangout_" + roomName);
if(teim != null){
cm.sendOk("There's already a room with that name taken! Please enter another room name.");
status = 0;
}else{
cm.sendAcceptDecline("Please confirm the following details:\r\n\r\nRoom Name: #r" + roomName + "#k\r\n\r\nCreating this room will cost #b" + cost + "#k mesos.\r\n\r\nNote: When giving your friends this information, remember that rooms are CaSe-sEnSiTiVe!\r\n\r\nDo you accept all information above?");
}
}else if(status == 1338){
em.setProperty("mRR", roomName);
eim = em.getInstance("Hangout_");
if(eim == null){
cm.sendOk("Something went wrong...");
cm.dispose();
}else{
eim.registerPlayer(cm.getChar());
cm.gainMeso(-cost);
cm.sendOk("Have fun!");
cm.dispose();
}
}
}
}
Save that and close that.
Next, put the following NPC script in the NPC that is in your Hangout map.
PHP:
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0) {
cm.sendOk("Alright, see you next time.");
cm.dispose();
return;
}
status++;
if (status == 0) {
cm.sendYesNo("Would you like to leave the player hangout?");
}else if(status == 1) {
var em = cm.getEventManager("playerHangout");
var eim = em.getInstance("Hangout_");
eim.removePlayer(cm.getChar());
cm.dispose();
}
}
}
Save and Close.
Restart the server and you should be good.
I'm hoping by now you all know how to work with instances. I've commented the lines so that hopefully anyone who can analyze a script can learn to script themselves.
Credits to myself on everything.
Screen Shots:



If you have any suggestions/questions/comments, please do make them!
Just a note, this, along with most of my releases, are Storybox originals. If you plan to use them in a repack, please give credit to "Lios of Storybox"
Thank you for using this release!
Also, please post if you're planning to use this for your server. I like to know where my releases are going and if they're popular

Last edited: