Realm relay script to K relay?

Posts 1–2 of 2 · Page 1 of 1
Realm relay script to K relay?
var ID_NOTIFICATION = $.findPacketId("NOTIFICATION");
var ID_CREATE_SUCCESS = $.findPacketId("CREATE_SUCCESS");
var ID_PLAYER_TEXT = $.findPacketId("PLAYERTEXT");
var ID_UPDATE = $.findPacketId("UPDATE");
var ID_TELEPORT = $.findPacketId("TELEPORT");
var ID_NEW_TICK = $.findPacketId("NEW_TICK");
var ID_MOVE = $.findPacketId("MOVE");

var player_id = -1;
var follow_id = -1;
var follow_pos = -1;
var following = false;
var playerLocs = {};
var players = {};
var playerLoc = null;
var myLoc = null;
var who = null;

function onClientPacket(event) {
var packet = event.getPacket();
switch (packet.id()) {
case ID_PLAYER_TEXT: {
var text = packet.text.toLowerCase();
if(text.contains("/follow ")){
event.cancel();
who = text.substring('/follow '.length)
$.echo("follow " + who);
if(who == "off"){
following = false;
this.displayNotification(event, player_id, 0xFF0000, "follow " + who);
}
else{
following = true;
this.displayNotification(event, player_id, 0x00FF00, "follow " + who);
findplayers(event,who);
}
}
break;
}
case ID_MOVE: {
break;
}
}
}
function findplayers(event,who){
if(following){
for(var player in players){
var name = players[player].toLowerCase();
if (who == name){
follow_id = player;
autotp(event,follow_id);
break;
}
}
}
}
function autotp(event,playerObjectId){
if(following){
var tp_packet = event.createPacket(ID_TELEPORT);
tp_packet.objectId = playerObjectId;
event.sendToServer(tp_packet);
event.scheduleEvent(10, "findplayers",who);
}
}
function onServerPacket(event) {
var packet = event.getPacket();
switch (packet.id()) {
case ID_CREATE_SUCCESS: {
player_id = packet.objectId;
break;
}
case ID_UPDATE: {
// New objects
for (var i = 0; i < packet.newObjs.length; i++) {
var objectData = packet.newObjs[i];
var type = objectData.objectType;
if(objectData.status.objectId == follow_id){
playerLoc = objectData.status.pos;
log("playerLoc",follow_id ,playerLoc);
}
if(objectData.status.objectId == player_id){
myLoc = objectData.status.pos;
log("myLoc",player_id ,myLoc);
}
if(type == 768 || type == 775 || type == 782 || type == 784 || (type >= 797 && type <= 806)){ // player classes
playerLocs[objectData.status.objectId] = objectData.status.pos;
for (var j = 0; j < objectData.status.data.length; j++) {
var statData = objectData.status.data[j];
if(statData != null && statData.obf0 == 31){
players[objectData.status.objectId] = statData.obf2;
break;
}
}
}
}
// Removed objects
for (var i = 0; i < packet.drops.length; i++) {
var droppedObjectId = packet.drops[i];
if(playerLocs[droppedObjectId] != null){
delete playerLocs[droppedObjectId];
}
else if(droppedObjectId == follow_id){
follow_id = -1;
playerLoc = null;
}
else if(droppedObjectId == player_id){
player_id = -1;
myLoc = null;
}
}
break;
}
}
}
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 log(title,id,data){
$.echo(title);
$.echo(id);
$.echo(data);
}


This script was originally from Realm-Relay, but i'm wondering if it can be used for K-relay as it has a lot better mods and works better for me. tyvm
here's the link to the original
http://rotmgtool.com/realm-relay-rot...low-t4579.html
aha! You finally found the link
Like I already mentioned - I tried making a script like this in K Relay.
But I simply did not have enough time to finish it!
I've got very important exams that I need to take care of.
In the meantime, I'll just post my code how far I got here.
If you - or anyone else wants to work upon my code, feel free. Just remember to Attribute.
Code is licensed under CC-BY. Feel free to distribute it and whatnot:

The code is almost done, but like I said - I didn't have enough time to properly test it or finish it:

Code:
using Lib_K_Relay;
using Lib_K_Relay.Interface;
using Lib_K_Relay.Networking;
using Lib_K_Relay.Networking.Packets;
using Lib_K_Relay.Networking.Packets.Client;
using Lib_K_Relay.Networking.Packets.DataObjects;
using Lib_K_Relay.Networking.Packets.Server;
using Lib_K_Relay.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PixelZerg
{
    public class PixelBoxer// : IPlugin
    {
        private bool _enabled = true;
        //private bool tradeS = false

        public string GetAuthor() 
        { return "PixelZerg"; }

        public string GetName() 
        { return "PixelBoxer"; }

        public string GetDescription() 
        { return "Trying to replace all those multiboxing software - this one only needs one client. Essentially - what it does is it keeps teleporting you to someone."; }

        public string[] GetCommands()
        { return new string[] { "/pbtoggle on:off and /pb [name]"}; }

        //DEFINING DONE

        public void Initialize(Proxy proxy)
        {
           // moo:
            proxy.HookCommand("pbtoggle", PluginToggle);
            proxy.HookCommand("pb", PlayerDefine);
           // proxy.HookPacket(PacketType.PLAYERTEXT, OnPlayerText);
        }

        //VARS ))))))))))))))))))))))))))))))))((((((((((((((((((((((((((OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
        private Dictionary<int, string> _playerNames;
        private Dictionary<int, Location> _playerLocations;
        private short[] _classes;
        private int _questId;
        private Location _questLocation;


        //VAES OOOOOOEEEEEEEEEEEEEEEEEEEEEMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

        private void OnUpdate(Client client, Packet packet)
        {
            UpdatePacket packet2 = (UpdatePacket)packet;
            foreach (Entity entity in packet2.NewObjs)
            {
                if (this._classes.Contains<short>(entity.ObjectType))
                {
                    this._playerLocations.Add(entity.Status.ObjectId, entity.Status.Position);
                    foreach (StatData data in entity.Status.Data)
                    {
                        if (data.Id == 0x1f)
                        {
                            this._playerNames.Add(entity.Status.ObjectId, data.StringValue);
                        }
                    }
                }
                else if (entity.Status.ObjectId == this._questId)
                {
                    this._questLocation = entity.Status.Position;
                }
            }
            foreach (int num in packet2.Drops)
            {
                if (this._playerLocations.ContainsKey(num))
                {
                    this._playerLocations.Remove(num);
                    this._playerNames.Remove(num);
                }
            }
        }



        private void PluginToggle(Client client, string command, string[] args)
        {
         // moo:

            if (args.Length == 0) return;

            if (args[0] == "on")
            {
                _enabled = true;
                client.SendToClient(PluginUtils.CreateOryxNotification(
                   "PixelBox", "Enabled"));
            }
            if (args[0] == "off")
            {
                _enabled = false;
                client.SendToClient(PluginUtils.CreateOryxNotification(
                   "PixelBox", "Disabled"));
            }
        }

        private void PlayerDefine(Client client, string command, string[] args)
        {
            if (args.Length == 0)
            {
                return;
            }
            else
            {
                string who = args[0];
              //  int count = 0;
           moo:
                if (_enabled == true)
                {
                    PlayerTextPacket packet = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
                    packet.Text = "/teleport " + who;
                    packet.Send = true;
                    client.SendToServer(packet);
                    client.SendToClient(PluginUtils.CreateNotification(client.ObjectId, "Teleported to " + who));

                    goto moo;
                }
                else
                {
                    Console.WriteLine("moOoO000OOooo00OOOOooO!");
                    //Initialize(proxy);

                }

                    
                    //client.SendToClient(PluginUtils.CreateNotification(client.ObjectId, "Player with \"" + args[0] + "\" in their name was not found!"));
                }

//ARGS LENGTH DONE BREAK MOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO-----------------------------------------------


            }


           
        }


         

    }
Hope this helps!
Posts 1–2 of 2 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us