//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 + "\"}}";
notificationPacke*****lor = 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;
effectPacke*****lor = 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);
conditionPacke*****nditionEffect = condition;
//conditionPacke*****nditionDuration = 10;
event.sendToClient(conditionPacket);
displayNotification(event, player_id, 0x11FF11, "Sent condition "+effect);
event.cancel();
}
}
}