[Add-On]GMS Like 'The Ticket Reader'.

I'm overrated.
Decennium
Joined
Apr 10, 2008
Messages
4,094
Reaction score
1,271
So Kevin wanted me to do this for MoopleDEV, and I did this. This is fully GMS - Like (almost, gotta work on the event of NLC ride) text, features, etc, etc.

The Ticket Gate (1052007).
Copy this as a text, save as 1052007.js
to your NPC scripts.
PHP:
/* @Author Gilbert.
        Name: Kerning subway portal.
        Map(s): Kerning City Subway (103000100).
        Info: Portal to enter subway.
*/

var tickets = Array(4031036, 4031037, 4031038);
var maps = Array(103000900, 103000903, 103000906);
var mapnames = Array("Construction Site B1", "Construction Site B2", "Construction Site B3");
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.dispose(); 
            return;     
        } 
        if (mode == 1) { 
            status++; 
        } 
        else { 
            status--; 
        } 
        if (status == 0) {
	cm.sendSimple("Please select your desired destination.\r\n#b#L0##eSubway Line 1 Area 1 #r(caution: Striges, Wraiths etc.)#n#b#l\r\n#L1#Kerning Square Shopping Center (ride subway)#l\r\n\r\n#L2#Construction Site#l\r\n#L3#New Leaf City#l#k");
        } else if (status == 1) {
        if (selection == 0) {	
	cm.warp(103000101);
	cm.dispose();
        } else if (selection == 1) {
	cm.getPlayer().timedRide(103000300, 103000310, "The next stop is at Kerning Square Station. The exit is on your left.", 10000);
	cm.dispose();
         } else if (selection == 2) {
	if (!cm.haveItem(4031711) && !cm.haveItem(4031036) && !cm.haveItem(4031037)) {
	cm.sendOk("Here's the ticket reader. You are not allowed in without the ticket.");
	cm.dispose();
	} else {
	menu = "Here's the ticket reader. You will be brought in immediately. Which ticket would you like to use?";
	for (i = 0; i < tickets.length; i++) {
	if (cm.haveItem(tickets[i])) {
		menu += "\r\n#b#L" + i +"##b" + mapnames[i] + "#k#l\r\n";
	}
	}
	cm.sendSimple(menu);
	}
         } else if (selection == 3) {
	cm.sendOk("RING THE BELLZ");
	cm.dispose();
         } else if (status == 2) {
         if (selection < 3) {
	cm.gainItem(tickets[selection], -1);
	cm.warp(maps[selection]);
	cm.dispose();
	}
	}
	}

}

Now to portals. Save each one in the name
of it .js in the 'portal' in scripts.

Back to Kerning City (Depart_ToKerning).
PHP:
/*
  Original name: Depart_ToKerning.
  Map(s): Kerning Square Station (103000310).
  Duties: Takes you back to kerning from kerning square.
*/

function enter(pi) {
 pi.getPlayer().timedRide(103000300, 103000100, "The next stop is at Kerning Subway Station. The exit is on your left.", 10000);
 return true;
}

Ride to Kerning Square (subway_in2).
PHP:
/*
  Original name: subway_in2.
  Map(s): Kerning Subway Station (103000100).
  Duties: Opens the ticket reader gate NPC.
*/

function enter(pi) {
   pi.openNpc(1052007);
   return true;
 }

And now, add those to your MapleCharacter.
Credits: BloodAngel13: Shortening all of this.
PHP:
    public void timedRide(int startMap, final int endMap, String message, int clockTime) {
        client.getPlayer().changeMap(client.getChannelServer().getMapFactory().getMap(startMap));
    	getMap().broadcastMessage(MaplePacketCreator.getClock(clockTime));
    	getMap().broadcastMessage(MaplePacketCreator.earnTitleMessage(message));
    	dropMessage(6, message);
    	TimerManager.getInstance().schedule(new Runnable() {
            public void run() {
            	 client.getPlayer().changeMap(client.getChannelServer().getMapFactory().getMap(endMap));
            }
            }, clockTime);
    }

Havefun :).
Going to make NLC ride soon. :):
 
Last edited by a moderator:
Re: GMS Like 'The Ticket Reader'.

Oh, yeah.. You can either put this in AbstractPlayerInteraction
or MapleCharacter.
 
Last edited:
Re: GMS Like 'The Ticket Reader'.

Wow this is actually impressive. Good job. :)

Code:
dropMessage(6, "This next stop is at Kerning Square Station. The ext is on your left.")
Typo.

EDIT: I love seeing GMS-like **** like this still being released. Makes me feel like there is still hope.
 
Last edited:
Re: GMS Like 'The Ticket Reader'.

Wow this is actually impressive. Good job. :)

Code:
dropMessage(6, "This next stop is at Kerning Square Station. The ext is on your left.")
Typo.

EDIT: I love seeing GMS-like **** like this still being released. Makes me feel like there is still hope.

Oh yeah, thanks, fixed it. Yeah, I also love
seeing them. Makes me happy :blush:
 
Re: GMS Like 'The Ticket Reader'.

I edited the method so you don't need to make 1 for each ride. Oh and my source didn't have earnTitleMessage so I commented it out. Uncomment if you do.
PHP:
    public void timedRide(int startMap, final int endMap, String message, int clockTime) {
        client.getPlayer().changeMap(client.getChannelServer().getMapFactory().getMap(startMap));
    	getMap().broadcastMessage(MaplePacketCreator.getClock(clockTime));
    	//getMap().broadcastMessage(MaplePacketCreator.earnTitleMessage(message));
    	dropMessage(6, message);
    	TimerManager.getInstance().schedule(new Runnable() {
            public void run() {
            	 client.getPlayer().changeMap(client.getChannelServer().getMapFactory().getMap(endMap));
            }
            }, clockTime);
    }
 
Last edited:
Re: GMS Like 'The Ticket Reader'.

I edited the method so you don't need to make 1 for each ride. Oh and my source didn't have earnTitleMessage so I commented it out. Uncomment if you do.
PHP:
    public void timedRide(int startMap, final int endMap, String message, int clockTime) {
        client.getPlayer().changeMap(client.getChannelServer().getMapFactory().getMap(startMap));
    	getMap().broadcastMessage(MaplePacketCreator.getClock(clockTime));
    	//getMap().broadcastMessage(MaplePacketCreator.earnTitleMessage(message));
    	dropMessage(6, message);
    	TimerManager.getInstance().schedule(new Runnable() {
            public void run() {
            	 client.getPlayer().changeMap(client.getChannelServer().getMapFactory().getMap(endMap));
            }
            }, clockTime);
    }

Oh nice, will add that, good job :).
 
Re: GMS Like 'The Ticket Reader'.

Only problem:

Runnables are defaulted in milliseconds, and timers are in seconds, so your clock-actual time warping is off. :(
 
Re: GMS Like 'The Ticket Reader'.

lrn2use math and client commands.

Those arrays are completely unnecessary.

I have to agree with this one,

Example:
PHP:
var maps = Array(103000900, 103000903, 103000906);
cm.warp(maps[selection]);

Could be:

PHP:
cm.warp(103000900 + selection * 3 );

You also forgot to add the last bracket.

PHP:
/* @Author Gilbert.
        Name: Kerning subway portal.
        Map(s): Kerning City Subway (103000100).
        Info: Portal to enter subway.
*/

 
 
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.dispose(); 
            return;     
        } 
        if (mode == 1) { 
            status++; 
        } 
        else { 
            status--; 
        } 
        if (status == 0) {
            cm.sendSimple("Please select your desired destination.\r\n#b#L0##eSubway Line 1 Area 1 #r(caution: Striges, Wraiths etc.)#n#b#l\r\n#L1#Kerning Square Shopping Center (ride subway)#l\r\n\r\n#L2#Construction Site#l\r\n#L3#New Leaf City#l#k");
        } else if (status == 1) {
            if (selection == 0) {    
                cm.warp(103000101);
                cm.dispose();
            } else if (selection == 1) {
                cm.getPlayer().timedRide(103000300, 103000310, "The next stop is at Kerning Square Station. The exit is on your left.", 10000);
                cm.dispose();
            } else if (selection == 2) {
                if (!cm.haveItem(4031711) && !cm.haveItem(4031036) && !cm.haveItem(4031037)) {
                    cm.sendOk("Here's the ticket reader. You are not allowed in without the ticket.");
                    cm.dispose();
                } else {
                    menu = "Here's the ticket reader. You will be brought in immediately. Which ticket would you like to use?";
                    for (i = 1; i <= 3; i++) {
                        if (cm.haveItem(4031035 + i )) {
                            menu += "\r\n#b#L" + i +"##bConstruction Site B" +i + "#k#l\r\n";
                        }
                    }
                    cm.sendSimple(menu);
                }
            } else if (selection == 3) {
                cm.sendOk("RING THE BELLZ");
                cm.dispose();
            } else if (status == 2) {
                if (selection <= 3) {
                    cm.gainItem(4031035 + selection, -1);
                    cm.warp(103000900 + selection*3);
                    cm.dispose();
                }
            }
        }
    }
}
 
Last edited:
Re: GMS Like 'The Ticket Reader'.

I have to agree with this one,

Example:
PHP:
var maps = Array(103000900, 103000903, 103000906);
cm.warp(maps[selection]);

Could be:

PHP:
cm.warp(103000900 + selection * 3 );

You also forgot to add the last bracket.


PHP:
cm.warp(103000900 + selection * 3);

^ Makes no sense ._. . Selection of what? Just selection?

And multiplying it by 3 does what o.O?
 
Re: GMS Like 'The Ticket Reader'.

PHP:
cm.warp(103000900 + selection * 3);

^ Makes no sense ._. . Selection of what? Just selection?

And multiplying it by 3 does what o.O?

Oh Soul.

The first selection is 0. 0x3 = 0, thus it stays the same.
The second selection is 1. 1x3 = 3, thus you add 3 to the original Map ID.
The third selection is 2. 2x3 = 6, thus you add 6 to the original Map ID.
 
Re: GMS Like 'The Ticket Reader'.

I have to agree with this one,

Example:
PHP:
var maps = Array(103000900, 103000903, 103000906);
cm.warp(maps[selection]);

Could be:

PHP:
cm.warp(103000900 + selection * 3 );

You also forgot to add the last bracket.

PHP:
/* @Author Gilbert.
        Name: Kerning subway portal.
        Map(s): Kerning City Subway (103000100).
        Info: Portal to enter subway.
*/

 
 
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.dispose(); 
            return;     
        } 
        if (mode == 1) { 
            status++; 
        } 
        else { 
            status--; 
        } 
        if (status == 0) {
            cm.sendSimple("Please select your desired destination.\r\n#b#L0##eSubway Line 1 Area 1 #r(caution: Striges, Wraiths etc.)#n#b#l\r\n#L1#Kerning Square Shopping Center (ride subway)#l\r\n\r\n#L2#Construction Site#l\r\n#L3#New Leaf City#l#k");
        } else if (status == 1) {
            if (selection == 0) {    
                cm.warp(103000101);
                cm.dispose();
            } else if (selection == 1) {
                cm.getPlayer().timedRide(103000300, 103000310, "The next stop is at Kerning Square Station. The exit is on your left.", 10000);
                cm.dispose();
            } else if (selection == 2) {
                if (!cm.haveItem(4031711) && !cm.haveItem(4031036) && !cm.haveItem(4031037)) {
                    cm.sendOk("Here's the ticket reader. You are not allowed in without the ticket.");
                    cm.dispose();
                } else {
                    menu = "Here's the ticket reader. You will be brought in immediately. Which ticket would you like to use?";
                    for (i = 1; i <= 3; i++) {
                        if (cm.haveItem(4031035 + i )) {
                            menu += "\r\n#b#L" + i +"##bConstruction Site B" +i + "#k#l\r\n";
                        }
                    }
                    cm.sendSimple(menu);
                }
            } else if (selection == 3) {
                cm.sendOk("RING THE BELLZ");
                cm.dispose();
            } else if (status == 2) {
                if (selection <= 3) {
                    cm.gainItem(4031035 + selection, -1);
                    cm.warp(103000900 + selection*3);
                    cm.dispose();
                }
            }
        }
    }
}

I used an old ticket reader script and modified it a bit with text fixes, no more than that. I might rcode one by myself and add it.
 
Back