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 02-02-2007, 01:58 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Get all staff from serveroptions

Just add this as a wNPC and say /getstaffs, voilá check RC!

Update by Skyld: pasted latest script post
Update: no longer makes client RC not work


wNPC:

PHP Code:
function onActionServerSide()
{
  switch (
params[0]) {
    
// Automaticly scans the serveroptions for staffs and add them
    // to serverr.staff.
    
case "updatestaffs":
      for (
iparams[1]) {
        if (
i.starts("staff=")) temp.staff i;
      }
      
serverr.staff NULL;
      for (
itemp.staff.tokenize(",")) {
        if (
i.starts("staff=") || i.starts("(") && i.ends(")")) {
          if (
i.starts("staff=")) temp.rank i.substring(7i.length() - 8);
          else 
temp.rank i.substring(1i.length() - 2);
        }
        else if (
temp.rank != "Temp"serverr.staff.add({itemp.rank});
      }
    break;
  }
}

//#CLIENTSIDE
function onCreated()
{
  if (
clientr.staffrank != NULLrequestText("clientrc"1);
}

function 
onReceiveText(texttypetextoptiontextlines) {
  switch (
texttype) {
    case 
"clientrc":
      
requestText("options""");
    break;
    
    case 
"options":
      
triggerServer("gui"name"updatestaffs"textlines.tokenize(), servername);
      
requestText("clientrc"0);
    break;
  }

"isstaff" class that should be joined when the player logs in, contains a function that checks if the player is staff or not (player.IsStaff()). Works both clientsided and serversided..

PHP Code:
public function IsStaff()
{
  
clientr.isstaff false;
  
clientr.staffrank NULL;
  
temp.data isInString(this.account);
  if (
temp.data[0] == true) {
    
clientr.isstaff = { temp.data[0], temp.data[1] };
    
clientr.staffrank temp.data[1];
  } else 
clientr.staffrank "Player";
  return 
clientr.isstaff[0];
}

function 
isInString(acc)
{
  for (
0serverr.staff.size(); ++) {
    if (
serverr.staff[i][0] == acc) {
      
temp.info = { trueserverr.staff[i][1] };
      return 
temp.info;
    }
  }
  return 
false;
}

//#CLIENTSIDE
public function IsStaff()
{
  return 
isInString(this.account)[0];
}

function 
isInString(acc)
{
  for (
0serverr.staff.size(); ++) {
    if (
serverr.staff[i][0] == acc) {
      
temp.data = { trueserverr.staff[i][1] };
      return 
temp.data;
    }
  }
  return 
false;

And finally, just add this to profilevars in serveroptions:

PHP Code:
Server Relation:=clientr.staffrank 

W00t!
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto

Last edited by Skyld; 05-14-2007 at 09:51 PM..
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:27 AM.


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