Адрес сервера: 178.19.245.169 2700 или game2.mudlast.ru 2700 , группа Вконтакте

Форум игры Мир Ведьмака

Информация о пользователе

Привет, Гость! Войдите или зарегистрируйтесь.


Вы здесь » Форум игры Мир Ведьмака » Полезная информация » Настройка клиента jmc


Настройка клиента jmc

Сообщений 1 страница 6 из 6

1

И так для начала сам клиент обладает хорошими встроеyными функциями.
Их название и описание можно найти в справке, которая должна прилагаться к клиенту!

Но клиент jmc позволяет вам использовать еще и некоторые языка программирования
для написания скриптов и сценариев.

Данный клиент поддерживает следующие языки:
1)VBscript
2)XML
3)JScript
4)perl

0

2

Mortis написал(а):

Их название и описание можно найти в справке, которая должна прилагаться к клиенту!

Должна но не обязательно  :)
Справку по jmc можно найти в инете, например

http://www.mudconnector.su/JmcTutorial

0

3

Код:
function lootGold ( event )
	{
var line = jmc.event;
var n = new RegExp ( /^Там было ? (\d+) монет/. );
if(n.test(line))
	{
var b = new Array(n.exec(line));
var amount = b.$1;
 
jmc.parse("#woutput {3} {yellow} {<|[system] :: [loot] :: Gold " + amount + "  |>}");
	}
else
	{
b = "";
amount = 0;
return (line);
	}
return (event)
     }

А про это там много написанно?

Отредактировано Mortis (22.10.13 15:46:30)

0

4

Что "это" справку, скрипты?

0

5

Нет работаю чтоб все сразу комплектом выложить.

0

6

Так вот начнем с того что, если вы человек далекий от программирования то скорей всего знакомство со скриптами жабы в начале вам не доставит особого удовольствия.
Начнем с того что я лично для себя выбрал язык JScript.

JScript - это java, но не откомании Sun,  а от Microsoft.
Это обо языка произлшдл от групы ECOM262  - если мне не изменяет память.
По это они различаються между собой синтаксисам и так далее, но различия не большие.

Начнем с того как устаовить скриптовой движок и как его настроить.

И так идем в директорию где у вас лежит жаба. (Желательно установить с нуля с помощью инсталятора или рег файла жилательно в директорию C:\)

У нас в папке с жабой есть папка settings в ней необходимо создать файл commonlib.scr
Это собственно где храниться ваши скрипты для всех профилей жабы!

Чтоб Жаба начала без проблем понимать файлы без расширения .scr в этот самый commonlib.scr нужно вставить следущий не хитрый код

Код:
/*
*  Multi-Script Loader
*  Written by Nemesis
*  Modify by Mortis
*	v.1.3
*
*  Description:
*  Allows you to set multiple handlers in JMC for loading
*  more than one script.
*
*	Usage:
*  type = "Input" - Information from the command line
*         "Incoming" - Information from the server
*         "Timer"
*         "PreTimer"
*	"Connect"
*	"Disconnect"
*	register_handler( type, function );
*	remove_handler( type, function );
*	replace_handler( type, oldfunction, newfunction );
*
*  Ex.
*  function test( event ) {
*  	blah blah blah...
*  }
*  function test2( event ) {
*  	blah blah blah...
*  }
*  register_handler( "Input", test );
*	 replace_handler( "Input", test, test2 );
*  remove_handler( "Input", test2 );
*
*  To read another JScript file, type:
*  _include( filename );
*
*  Ex.
*  _include( "settings/script.scr" );
*
*  When including, script does not need to have extention
*  .scr  You may make up your own if you please.
*
*  The Incoming handler must return the event else
*  the line will not be displayed on the screen.
*
*  If you want an event to drop after reading input,
*  return 1 else return 0
*/

var debug = false; // Used to display what Script Loader does. (false by default)

var FileSystem = new ActiveXObject("Scripting.FileSystemObject");
var ForReading = 1;
var ForWriting = 2;
var ForAppending = 8;

_scripts = new Array();
_input = new Array();
_incoming = new Array();
_timer = new Array();
_pretimer = new Array();
_connect = new Array();
_disconnect = new Array();

var _handler = 1;

function _include(sFileName)
{
	if (FileSystem.FileExists(sFileName)) {
_scripts.push( sFileName );
var Stream = FileSystem.OpenTextFile(sFileName, ForReading);
jmc.Eval(Stream.ReadAll());
Stream.Close();
jmc.output(color(1,"blue") + sFileName + color(1,"green") + " Loaded.");
	} else {
jmc.showme( color(1,"red") + "Failed to load: " + sFileName );
jmc.showme( color(1,"red") + "File not found." );
	}
}

function register_handler(type, call)
{
	var found = false;
	if (type == "Input") {
for (var x = 0; x < _input.length; x++) {
	if (debug) {
jmc.output("Check Call.");
	}
	if (_input[ x ] == call) {
found = true;
if (debug) {
	jmc.output("Found Call.");
}
	}
}
if (!found) {
	_input.push( call );
}
if (debug) {
	if (found) {
jmc.output( "Handler Input already Registered.");
} else {
jmc.output( "Handler Input Registered.");
	}
}
} else if (type == "Incoming") {
for (var x = 0; x < _incoming.length; x++) {
	if (debug) {
jmc.output("Check Call.");
	}
	if (_incoming[ x ] == call) {
found = true;
if (debug) {
	jmc.output("Found Call.");
}
	}
}
if (!found) {
	_incoming.push( call );
}
if (debug) {
	if (found) {
jmc.output( "Handler Incoming already Registered.");
} else {
jmc.output( "Handler Incoming Registered.");
	}
}
} else if (type == "Timer") {
for (var x = 0; x < _timer.length; x++) {
	if (debug) {
jmc.output("Check Call.");
	}
	if (_timer[ x ] == call) {
found = true;
if (debug) {
	jmc.output("Found Call.");
}
	}
}
if (!found) {
	_timer.push( call );
}
if (debug) {
	if (found) {
jmc.output( "Handler Timer already Registered.");
} else {
jmc.output( "Handler Timer Registered.");
	}
}
} else if (type == "PreTimer") {
for (var x = 0; x < _pretimer.length; x++) {
	if (debug) {
jmc.output("Check Call.");
	}
	if (_pretimer[ x ] == call) {
found = true;
if (debug) {
	jmc.output("Found Call.");
}
	}
}
if (!found) {
	_pretimer.push( call );
}
if (debug) {
	if (found) {
jmc.output( "Handler PreTimer already Registered.");
} else {
jmc.output( "Handler PreTimer Registered.");
	}
}
} else if (type == "Connect") {
for (var x = 0; x < _connect.length; x++) {
	if (debug) {
jmc.output("Check Call.");
	}
	if (_connect[ x ] == call) {
found = true;
if (debug) {
	jmc.output("Found Call.");
}
	}
}
if (!found) {
	_connect.push( call );
}
if (debug) {
	if (found) {
jmc.output( "Handler Connect already Registered.");
} else {
jmc.output( "Handler Connect Registered.");
	}
}
} else if (type == "Disconnect") {
for (var x = 0; x < _disconnect.length; x++) {
	if (debug) {
jmc.output("Check Call.");
	}
	if (_disconnect[ x ] == call) {
found = true;
if (debug) {
	jmc.output("Found Call.");
}
	}
}
if (!found) {
	_disconnect.push( call );
}
if (debug) {
	if (found) {
jmc.output( "Handler Disconnect already Registered.");
} else {
jmc.output( "Handler Disconnect Registered.");
	}
}
} else {
jmc.output( "Unknown Handler Call." );
	}
}

function remove_handler( type, call ) {
	var found = false;
	if (type == "Input") {
for (var x = 0; x < _input.length; x++) {
	if (_input[ x ] == call) {
found = true;
_input[ x ] = null;
	}
}
if (found && debug) {
	jmc.output( "Handler Input Removed.");
}
} else if (type == "Incoming") {
for (var x = 0; x < _incoming.length; x++) {
	if (_incoming[ x ] == call) {
found = true;
_incoming[ x ] = null;
	}
}
if (found && debug) {
	jmc.output( "Handler Incoming Removed.");
}
} else if (type == "Timer") {
for (var x = 0; x < _timer.length; x++) {
	if (_timer[ x ] == call) {
found = true;
_timer[ x ] = null;
	}
}
if (found && debug) {
	jmc.output( "Handler Timer Removed.");
}
} else if (type == "PreTimer") {
for (var x = 0; x < _pretimer.length; x++) {
	if (_pretimer[ x ] == call) {
found = true;
_pretimer[ x ] = null;
	}
}
if (found && debug) {
	jmc.output( "Handler PreTimer Removed.");
}
} else if (type == "Disconnect") {
for (var x = 0; x < _disconnect.length; x++) {
	if (_disconnect[ x ] == call) {
found = true;
_disconnect[ x ] = null;
	}
}
if (found && debug) {
	jmc.output( "Handler Disconnect Removed.");
}
} else if (type == "Connect") {
for (var x = 0; x < _connect.length; x++) {
	if (_connect[ x ] == call) {
found = true;
_connect[ x ] = null;
	}
}
if (found && debug) {
	jmc.output( "Handler Connect Removed.");
}
} else {
jmc.output( "Unknown Handler Call." );
	}
}

function replace_handler( type, oldcall, newcall ) {
	var found = false;
	if (type == "Input") {
for (var x = 0; x < _input.length; x++) {
	if (_input[ x ] == oldcall) {
found = true;
_input[ x ] = newcall;
	}
}
if (found && debug) {
	jmc.output( "Handler Input Replaced.");
}
} else if (type == "Incoming") {
for (var x = 0; x < _incoming.length; x++) {
	if (_incoming[ x ] == oldcall) {
found = true;
_incoming[ x ] = newcall;
	}
}
if (found && debug) {
	jmc.output( "Handler Incoming Replaced.");
}
} else if (type == "Timer") {
for (var x = 0; x < _timer.length; x++) {
	if (_timer[ x ] == oldcall) {
found = true;
_timer[ x ] = newcall;
	}
}
if (found && debug) {
	jmc.output( "Handler Timer Replaced.");
}
} else if (type == "PreTimer") {
for (var x = 0; x < _pretimer.length; x++) {
	if (_pretimer[ x ] == oldcall) {
found = true;
_pretimer[ x ] = newcall;
	}
}
if (found && debug) {
	jmc.output( "Handler PreTimer Replaced.");
}
} else if (type == "Connect") {
for (var x = 0; x < _connect.length; x++) {
	if (_connect[ x ] == oldcall) {
found = true;
_connect[ x ] = newcall;
	}
}
if (found && debug) {
	jmc.output( "Handler Connect Replaced.");
}
} else if (type == "Disconnect") {
for (var x = 0; x < _disconnect.length; x++) {
	if (_disconnect[ x ] == oldcall) {
found = true;
_disconnect[ x ] = newcall;
	}
}
if (found && debug) {
	jmc.output( "Handler Disconnect Replaced.");
}
} else {
jmc.output( "Unknown Handler Call." );
	}
}

function handler_input()
{
	split = jmc.event.split(" ");
	switch(split[ 0 ]) {
	case "/jload":
_include( split[ 1 ] );
jmc.dropevent();
break;

	case "/jclear":
_input = new Array();
_incoming = new Array();
_timer = new Array();
jmc.output("Handlers Reset");
jmc.dropevent();
break;

	case "/jshow":
jmc.showme( "" );
jmc.showme( "" );
jmc.showme( "Loaded Scripts");
jmc.showme( "*----------------------------------*" );
for (var x = 0; x < _scripts.length; x++) {
	jmc.showme( _scripts[ x ]);
}
jmc.showme( "*----------------------------------*" );
jmc.dropevent();
break;

	case "/?":
jmc.showme( "" );
jmc.showme( "SL Help" );
jmc.showme( "---------------------------------------" );
jmc.showme( "/jload <script>  - loads a javascript into memory. " );
jmc.showme( "/jshow           - shows javascripts in memory." );
jmc.showme( "/jclear          - removes all loaded javascripts." );
jmc.showme( "---------------------------------------" );
jmc.showme( "END OF SL HELP" );
break;
	}

	for (var x = 0; x < _input.length; x++) {
if (_input[ x ] != null) {
	if (_input[ x ]( jmc.event )) {
jmc.dropevent();
	}
}
	}
}

function handler_incoming()
{
	for (var x = 0; x < _incoming.length; x++) {
if (_incoming[ x ] != null) {
	jmc.event = _incoming[ x ]( jmc.event );
}
	}
}

function handler_connect()
{
	for (var x = 0; x < _connect.length; x++) {
if (_connect[ x ] != null) {
	_connect[ x ]();
}
	}
}

function handler_disconnect()
{
	for (var x = 0; x < _disconnect.length; x++) {
if (_disconnect[ x ] != null) {
	_disconnect[ x ]();
}
	}
	register_handler( "Incoming" , auto_login);
}

function handler_timer()
{
	for (var x = 0; x < _timer.length; x++) {
if (_timer[ x ] != null) {
	_timer[ x ]();
}
	}
}

function handler_pretimer()
{
	for (var x = 0; x < _pretimer.length; x++) {
if (_pretimer[ x ] != null) {
	_pretimer[ x ]();
}
	}
}

function remascii( line ) {
	if (line != null) {
line = line.replace(/\[\d+;\d+m/g,"");
line = line.replace(/\[\d+m/g,"");
return line;
	}
	return "";
}

function getElapseSeconds(from, to) {
	var update = new Date();
	var seconds = 0;
	seconds = ( from.getMinutes() - to.getMinutes() ) * 60;
	seconds += ( from.getSeconds() - to.getSeconds() );
	return Math.abs(seconds);
}

function color( contrast, type ) {
	switch( type ) {
default: return "[" + contrast + ";37m]"; break;
case "gray": return "[" + contrast + ";30m"; break;
case "red": return "[" + contrast + ";31m"; break;
case "green": return "[" + contrast + ";32m"; break;
case "yellow": return "[" + contrast + ";33m"; break;
case "blue": return "[" + contrast + ";34m"; break;
case "magenta": return "[" + contrast + ";35m"; break;
case "cyan": return "[" + contrast + ";36m"; break;
case "white": return "[" + contrast + ";37m"; break;
case "gray": return "[" + contrast + ";30m"; break;
	}
}
function auto_login( event ) {
	var line = remascii( event );

	if (autologin) {
if (line.search(login_prompt) != -1) {
	jmc.output(color(1,"green") + "Initiating Autologin");
	jmc.send(username);
	jmc.send(password);
	remove_handler("Incoming" , auto_login);
	} else if (line.search( login_skip ) != -1) {
	jmc.output( color(1,"green") +  "Already in game, skipping Autologin." );
	remove_handler("Incoming" , auto_login);
}
} else {
jmc.output( color(1,"green") + "Auto-login Disabled.");
remove_handler("Incoming" , auto_login);
	}
	return event;
}

jmc.registerhandler("Input","handler_input()");
jmc.registerhandler("Incoming","handler_incoming()");
jmc.registerhandler("Timer","handler_timer()");
jmc.registerhandler("PreTimer","handler_pretimer()");
jmc.registerhandler("Connected","handler_connect()");
jmc.registerhandler("ConnectLost","handler_disconnect()");
jmc.SetTimer(1, 20);

jmc.output( color(1,"yellow") + "Loader Installed.");
jmc.output( color(1,"yellow") + "Written by " + color(1,"white") + " Nemesis.");
jmc.output( "" );

if (FileSystem.FileExists("settings/" + jmc.profile + ".js")) {
	_include( "settings/" + jmc.profile + ".js" );
	} else {
	_include( "settings/default.js" );
}

А в папку settings так же добавть файл default.js.

Внимание все файлы должны быть сохранены с кодировкой ANSI !!! В настроках JMC выбрать во вкладе Script -> JScript.encode

Отредактировано Mortis (03.06.13 14:51:57)

0


Вы здесь » Форум игры Мир Ведьмака » Полезная информация » Настройка клиента jmc