HelpRealm Relay Command Script

Posts 1–3 of 3 · Page 1 of 1
Realm Relay Command Script
Hello everyone,
Recently I discovered and started DeVoid's RealmRelay, and have loved it ever since. I have been making my own scripts, including a modified version of the "Harlem Shake" one. Unfortunately, I seem to have run into a problem:
Whenever I try to use /condit 1 (A command I am adding) it simply says in the console; "Server: it 1 not found" when the substring should cut off all but the number.
If anyone could help me with this, I'd greatly appreciate it.


Code:
Code:
//commands.js

var ID_CREATE_SUCCESS = $.findPacketId("CREATE_SUCCESS");
var ID_PLAYERTEXT;
var player_id = -1;
var ID_NOTIFICATION = $.findPacketId("NOTIFICATION");

function displayNotification(event, playerObjectId, color, text) {
	var notificationPacket = event.createPacket(ID_NOTIFICATION);
	notificationPacket.objectId = playerObjectId;
	notificationPacket.message = "{\"key\":\"blank\",\"tokens\":{\"data\":\"" + text + "\"}}";
	notificationPacket.color = color;
	event.sendToClient(notificationPacket);
}

function onEnable(event) {
	ID_PLAYERTEXT = event.findPacketId("PLAYERTEXT");	
}

function onServerPacket(event) {
	var packet = event.getPacket();
	switch (packet.id()) {
		case ID_CREATE_SUCCESS: {
			player_id = packet.objectId;
			break;
		}
	}
}

function onClientPacket(event) {
	var packet = event.getPacket();
	
	if (packet.id() == ID_PLAYERTEXT) {	 
			var input = packet.text.toLowerCase();	
			if (input == "/harlemshake"){
				event.echo("Do the Harlem Shake!");
				harlemPacket = event.createPacket(37);
				harlemPacket.effectType = 14;				
				event.sendToClient(harlemPacket);
                event.cancel();
			} else if (input == "/ping") {
				displayNotification(event, player_id, 0x11FF11, "Pong!");
				event.cancel();
			} else if (input.length() >= 9 && input.substring(0,7) == "/effect") {
				var effect = input.substring(8,input.length());
				effectPacket = event.createPacket(37);
				effectPacket.effectType = effect;				
				effectPacket.color = 0x11FF11;
				//effectPacket.pos1 = 
				event.sendToClient(effectPacket);
				displayNotification(event, player_id, 0x11FF11, "Sent effect "+effect);
                event.cancel();
			} else if (input.length() >= 9 && input.substring(0,7) == "/condit") {
				var condition = input.substring(8,input.length());
				conditionPacket = event.createPacket(23);
				conditionPacket.conditionEffect = condition;	
				//conditionPacket.conditionDuration = 10;			
				event.sendToClient(conditionPacket);
				displayNotification(event, player_id, 0x11FF11, "Sent condition "+effect);
                event.cancel();
			}
    }
}
SETCONDITION packets should be sent to the server, not the client.
Oh - I thought they were to give conditions like slowed or blind, I wanted to compile a list of effects for something that blocks certain effects. Would that be the "SHOW_EFFECT" packet then? (Sorry if I sound a bit noobish, first time writing ROTMG hacks myself)

Also, figured out that the "it 1" part was because of connect.js - will change that a bit, as it was being run first, then canceling the packet.
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us