Here's a tool I banged out to debug a problem on another player's client.
Using echo's is probably one of the most used tools around here to debug problems and it's a hard habit to break. Refusing to break said habit, I wrote a tool to connect to another player's echo/log window.
It adds a 6th tab to your F2.
You remotely connect by doing: /rdebug account
Then just echo debug as normal.
-RemoteDebugger
PHP Code:
function onActionServerSide() {
if (params[0] == "r") {
if (clientr.remotedebugger.size() > 0) {
for (temp.p: clientr.remotedebugger) {
temp.pl = findplayer(temp.p);
if (temp.pl == NULL) {
clientr.remotedebugger.remove(temp.p);
} else {
temp.pl.triggerclient("weapon", this.name, "r", params[1]);
}
}
if (clientr.remotedebugger.size() <= 0) {
player.removeweapon(this.name);
}
}
}
else if (params[0] == "debug") {
if (!clientr.isStaff) return;
temp.pl = findplayer(params[1]);
if (temp.pl == NULL) {
player.triggerclient("weapon", this.name, "r", params[1] SPC "could not be found.");
return;
}
if (!(player.account in temp.pl.clientr.remotedebugger)) {
temp.pl.clientr.remotedebugger.add(player.account);
temp.pl.addweapon(this.name);
player.triggerclient("weapon", this.name, "r", temp.pl.account SPC "connected!");
} else {
temp.pl.clientr.remotedebugger.remove(player.account);
temp.pl.removeweapon(this.name);
player.triggerclient("weapon", this.name, "r", temp.pl.account SPC "disconnected!");
}
}
else if (params[0] == "remove") {
player.removeweapon(this.name);
}
}
//#CLIENTSIDE
function onCreated() {
if (clientr.isStaff) setupRemoteTab();
}
function ChatBar.onAction() {
if (ChatBar.text.starts("/rdebug ")) {
temp.pl = ChatBar.text.substring("/rdebug ".length());
triggerserver("gui", this.name, "debug", temp.pl);
ChatBar.text = "";
}
}
function setupRemoteTab() {
F2LogWindow_Tab.removerowbyid(6);
if (isObject("F2LogWindow_Scroll6")) {
F2LogWindow_Scroll6.destroy();
}
F2LogWindow_Tab.addrow(6, "Remote");
with (F2LogWindow_Window) {
new F2LogWindow_Scroll0("F2LogWindow_Scroll6") {
profile = F2LogWindow_Scroll0.profile;
x = F2LogWindow_Scroll0.x;
y = F2LogWindow_Scroll0.y;
width = F2LogWindow_Scroll0.width;
height = F2LogWindow_Scroll0.height;
vscrollbar = "dynamic";
hscrollbar = "alwaysOff";
horizsizing = "width";
vertsizing = "height";
visible = false;
new F2LogWindow_Text0("F2LogWindow_Text6") {
profile = F2LogWindow_Text0.profile;
text = "Remote Debugger Initialized. Usage: /rdebug account\n";
x = y = 2;
horizsizing = "width";
vertsizing = "bottom";
width = F2LogWindow_Scroll0.width - 20;
}
}
}
}
function onActionClientside() {
if (params[0] == "r") {
echoremote(params[1]);
}
}
function onLogMessage(txt, r, g, b, ltype) {
if (ltype == "echo") {
if (clientr.remotedebugger.size() > 0) {
triggerserver("gui", this.name, "r", txt);
} else {
if (!clientr.isStaff) {
triggerserver("gui", this.name, "remove");
}
}
}
}
function echoremote(txt) {
F2LogWindow_Text6.addtext(txt NL "", true);
F2LogWindow_Scroll6.scrolltobottom();
}