This should come in handy when Client-RC is more mainstream in the next Graal version, and even now for quick access to any client debugging tools you may have scripted.
Installation is simple! Just put the weapon script below in a weapon npc called -RCAddons or whatever you like, and add it to staff when they log in.
Then you just adjust the rc addon's array, write the appropriate button_pressed function, and it's active and ready to use for your local staff.
However you'll probably have to adjust the createAddon function to prevent people from getting buttons they don't have rights or even need access to. But I'll leave that part up to you
You can check if they're staff and add the weapon to the them with the following script in your Control-NPC.
PHP Code:
function onActionPlayerOnline() {
temp.staffmembers = serveroptions.staff.tokenize(",");
if (player.account in temp.staffmembers) {
player.addweapon("-RCAddons");
}
}
Weapon Name: -RCAddons
PHP Code:
//#CLIENTSIDE
function onCreated() {
// Creates Addons if script is updated.
// Useful when developing add-ons
if (isObject(ScriptedRCWindow)) {
createAddons();
}
}
function ScriptedRCWindow.onWake() {
// Create Addons when Client-RC is opened.
createAddons();
}
function createAddons() {
// RC Addon Array
temp.rcaddons = {
/*
RC Addons Array Explaination
{ "addonID", "image", "hint description" }
addonID makes the button unique
image: rc_<image>_normal.png
rc_<image>_pressed.png
Default RC Images can be found on RC with the command:
/finddef rc_*
hint description is what text is displayed when
hovering over the button.
*/
{"Example", "datablocks", "Description of addon."},
{"RawrButton", "accounts", "Just a test button.."}
};
// Clear any Existing Add-ons
clearAddons();
// Create Add-ons
for (temp.rcaddon: temp.rcaddons) {
onClientRCAddon(temp.rcaddon[0], temp.rcaddon[1], temp.rcaddon[2]);
}
}
function clearAddons() {
with (ScriptedRCWindow) {
for (temp.obj: this.addons) temp.obj.destroy();
this.addons = "";
}
}
function onClientRCAddon(temp.addon, temp.rcimage, temp.hintmsg) {
with (ScriptedRCWindow) {
new GuiBitmapButtonCtrl("ScriptedRCButton_" @ temp.addon) {
// Determine which button to sit beside..
if (ScriptedRCWindow.addons.size() > 0) {
temp.obj = ScriptedRCWindow.addons[ScriptedRCWindow.addons.size()-1];
} else {
temp.obj = ScriptedRCButton_classlist;
}
// Button Images
normalbitmap = "rc_" @ temp.rcimage @ "_normal.png";
pressedbitmap = "rc_" @ temp.rcimage @ "_pressed.png";
mouseoverbitmap = "rc_" @ temp.rcimage @ "_normal.png";
// Determine Width + Height
width = getimgwidth(normalbitmap);
height = getimgheight(normalbitmap);
// Determine X + Y
x = temp.obj.x - width - 1;
y = temp.obj.y;
// Record Hint
hint = temp.hintmsg ? temp.hintmsg : temp.addon;
// Catch onAction Event
thiso.catchevent(this.name, "onAction", temp.addon @ "_Pressed");
}
this.addons.add(makevar("ScriptedRCButton_" @ temp.addon));
}
}
function ScriptedRCWindow.onResize() {
// Keeps the Addons in line
with (ScriptedRCWindow) {
for (temp.i = 0; temp.i < this.addons.size(); temp.i++) {
temp.linkobj = (temp.i == 0) ? ScriptedRCButton_classlist : this.addons[temp.i-1];
with (this.addons[temp.i]) {
x = temp.linkobj.x - width - 1;
y = temp.linkobj.y;
}
}
}
}
/*
Example Addons
You generally won't need much script here since you'll probably
just make calls to the Staff weapon, trigger, or whatever you want
to do.
*/
function Example_Pressed() {
cRCecho("Example Button Pressed!");
}
function cRCecho(msg) {
ScriptedRCRCchat.text @= "\n" @ msg;
ScriptedRCScroll.scrolltobottom();
}
function RawrButton_Pressed() {
sendtorc("Rawr");
}
The script neatly adds them to the Client-RC as well. Enjoy!