Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-13-2009, 05:33 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Client-RC Addon System

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!
Attached Thumbnails
Click image for larger version

Name:	rcaddons.png
Views:	564
Size:	72.7 KB
ID:	49177  
__________________
Quote:
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:06 PM.


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