Quote:
Originally Posted by Sivamet
EDIT: Appearantly the forum software doesn't like tabs, so my code looks crappy.
|
Maybe you should have used the CODE function
Code:
var kos_list = new Array();
var kos_att = "kill";
function kos_input( event ) {
switch( event ) {
default:
split = event.split( " " );
switch (split[ 0 ]) {
case "/kosadd":
kos_list.push( split[ 1 ] );
jmc.output( split[ 1 ] + " has been added to your KOS list." );
return 1;
break;
case "/kosrem":
var found = false;
for (var x = 0; x < kos_list.length;x++ ) {
if (kos_list[ x ] == split[ 1 ]) {
kos_list[ x ] = null;
found = true;
}
}
if (found) {
jmc.output( split[ 1 ] + " has been removed from your KOS list." );
kos_optimize();
} else {
jmc.output( split[ 1 ] + " was not found on your KOS list." );
}
return 1;
break;
case "/kosatt":
kos_att = '';
for (var x = 1;x < split.length; x++) {
kos_att = kos_att + split[ x ] + " ";
}
jmc.output("Your attack has been set to " + kos_att);
return 1;
break;
case "/kosres":
kos_list = new Array();
jmc.output( "You KOS list has been reset." );
return 1;
break;
case "/kos":
var msg = "[KOS List: (Action: " + kos_att + ")(Members: ";
var comma = 0;
for (var x = 0; x < kos_list.length;x++ ) {
if (kos_list[ x ] != null) {
if (comma) {
msg = msg + ", " + kos_list[ x ];
} else {
msg = msg + kos_list[ x ];
comma = 1;
}
}
}
msg = msg + ")]";
jmc.parse( split[ 1 ] + " " + msg );
return 1;
break;
case "/?":
jmc.showme( "" );
jmc.showme( "KOS help" );
jmc.showme( "---------------------------------------");
jmc.showme( "/kos <channel> - displays your list of kos in channel");
jmc.showme( "/kosadd <player name> - adds a player to your KOS list");
jmc.showme( "/kosrem <player name> - removes a player to your KOS list");
jmc.showme( "/kosres - removes all players from your KOS list");
jmc.showme( "/kosatt <skill/spell> - changes your default attack");
jmc.showme( "---------------------------------------");
jmc.showme( "END OF KOS HELP" );
return 1;
break;
}
return 0;
break;
}
}
function kos_optimize() {
var temp = kos_list;
y = 0;
kos_list = new Array();
for (var x = 0; x < temp.length; x++) {
if (temp[ x ] != null) {
kos_list[ y ] = temp[ x ];
y++;
}
}
}
function kos_incoming( event ) {
var line = remascii( event );
var player = null;
var regex = new RegExp( /(.*) (is standing here.|is resting here.|has arrived.|appears with a flashing light.)/ );
for (var x = 0; x < kos_list.length; x++ ) {
if ((player = regex.exec( line )) != null) {
if (player[ 1 ].search( kos_list[ x ] ) != -1)
jmc.parse( kos_att + " " + kos_list[ x ]);
}
}
return event;
}
register_handler( "Incoming", kos_incoming );
register_handler( "Input", kos_input );