Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-27-2007, 06:14 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
Update: no longer tokenize account names that has any spaces in it.


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);
    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 

(wee I even fixed something I misspelled in my old post!)
__________________
Follow my work on social media post-Graal:Updated august 2025.

Last edited by xXziroXx; 04-27-2007 at 06:46 AM..
Reply With Quote
  #2  
Old 05-03-2007, 07:05 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
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!
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 06:59 PM.


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