Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Get all staff from serveroptions (https://forums.graalonline.com/forums/showthread.php?t=71878)

xXziroXx 02-02-2007 01:58 AM

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!

Gambet 02-02-2007 02:04 AM

Useful, indeed.


Nice work.

JkWhoSaysNi 02-02-2007 02:17 AM

Doesn't work.

Does client RC need to be in use for this to work?


Edit: i found the problem:

replace
for (staff: temp.staffs) echo(staff);

with

echo(temp.staffs);

xXziroXx 02-02-2007 02:18 AM

Here's another version of it, thats currently in use on Mythic.. it checks what staff position you are, and sets a clientr. string as it. Could be useful for showing it in your profile etc.


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 != "Access"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, cotains a function that checks if the player is staff or not (player.IsStaff()). Works both clientsided and serversided (atleast I think it does.. pretty sure it does on ML).

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 


Gambet 02-02-2007 02:18 AM

Quote:

Originally Posted by JkWhoSaysNi (Post 1272270)
Doesn't work.

Does client RC need to be in use for this to work?



Yes, of course.


Though it's supposed to start clientrc once you use it, at least from the looks of it.

xXziroXx 02-02-2007 02:18 AM

Quote:

Originally Posted by JkWhoSaysNi (Post 1272270)
Doesn't work.

Does client RC need to be in use for this to work?

Yes.

Quote:

Originally Posted by Gambet (Post 1272273)
Though it's supposed to start clientrc once you use it, at least from the looks of it.

It should, and it does.

Gambet 02-02-2007 02:24 AM

Second version looks better, though of course I can't think of many uses for it besides setting a profile var.

I guess the simpler way would be best unless you'd like to set up such profile vars.

Matt 02-02-2007 03:52 AM

Nice work. :)

Rapidwolve 02-02-2007 05:12 AM

Useful =] rep++

xXziroXx 04-27-2007 06:14 AM

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

zokemon 04-27-2007 06:26 AM

Neat, but I don't like the idea of having to use clientrc to get such. Also a loadvarsfromarray() would probably be much more effecient then using a for loop through the whole serverops text :(

xXziroXx 05-03-2007 07:05 AM

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!

xXziroXx 05-11-2007 07:21 PM

Wow, thanks a lot whomever gave me bad rep for "u cant script" - the script in the first post no longer works. Ever heard of reading through the entire thread for possible updates?

This is exactly why THIS should be done.

Skyld, or anyone, mind editing my first post with the latest script? Cheers.

Chandler 05-11-2007 07:24 PM

lolol
What an arrogant person to not even read the entire thread...

cbk1994 05-12-2007 02:39 PM

Quote:

Originally Posted by xXziroXx (Post 1307068)
Wow, thanks a lot whomever gave me bad rep for "u cant script" - the script in the first post no longer works. Ever heard of reading through the entire thread for possible updates?

This is exactly why THIS should be done.

Skyld, or anyone, mind editing my first post with the latest script? Cheers.

Rep ++ (on first post) :D

PS:
postcount++;


All times are GMT +2. The time now is 02:44 PM.

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