Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Client-RC Addon System (https://forums.graalonline.com/forums/showthread.php?t=87384)

fowlplay4 08-13-2009 05:33 AM

Client-RC Addon System
 
1 Attachment(s)
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.rcaddontemp.rcaddons) {
    
onClientRCAddon(temp.rcaddon[0], temp.rcaddon[1], temp.rcaddon[2]);
  }
}

function 
clearAddons() {
  
with (ScriptedRCWindow) {
    for (
temp.objthis.addonstemp.obj.destroy();
    
this.addons "";
  }
}

function 
onClientRCAddon(temp.addontemp.rcimagetemp.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
      
temp.obj.width 1;
      
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.0temp.this.addons.size(); temp.i++) {
      
temp.linkobj = (temp.== 0) ? ScriptedRCButton_classlist this.addons[temp.i-1];
      
with (this.addons[temp.i]) {
        
temp.linkobj.width 1;
        
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!

Seich 08-13-2009 06:40 AM

Nice script and good idea. ^^

Gambet 08-13-2009 08:29 AM

Can definitely prove useful to some, nice work. :)

cbk1994 08-13-2009 10:02 AM

Cool, though I can't really see any practical uses for it right now. Could be interesting for some stuff, though.

Chompy 08-13-2009 12:03 PM

Quote:

Originally Posted by cbk1994 (Post 1514454)
Cool, though I can't really see any practical uses for it right now. Could be interesting for some stuff, though.

The possibilites are many, Zodiac could add a Nation Control Panel or something, or even something as an Archetype Manager/Creator, Mud Controls, etc.

I can think of many uses of this :)

cbk1994 08-13-2009 12:20 PM

Quote:

Originally Posted by Chompy (Post 1514459)
The possibilites are many, Zodiac could add a Nation Control Panel or something, or even something as an Archetype Manager/Creator, Mud Controls, etc.

I can think of many uses of this :)

Well, not sure about you, but I don't use client-RC, which is why I said I didn't see it being very useful. It'd probably be more beneficial to put them elsewhere, though I guess client-RC is just as good a place as any.

fowlplay4 10-23-2011 08:56 PM

3 Attachment(s)
Updated this to include profile modification which also makes the chat window look more like the default external RC theme.

Link: http://pastie.org/2746588

ff7chocoboknight 10-25-2011 12:17 AM

That's pretty neato.

MattKan 10-25-2011 02:56 AM

Quote:

Originally Posted by ff7chocoboknight (Post 1671658)
That's pretty neato.

I agree.

Matt 10-25-2011 05:21 PM

Nice job ^^

Vlad1 07-23-2012 04:49 AM

i noticed the rc u displayed wasn't a new window it was a window on graal

Crono 07-23-2012 02:07 PM

Now can you make it a stand-alone client so we don't have to have Graal open to have RC open?!


All times are GMT +2. The time now is 05:08 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.