View Single Post
  #4  
Old 02-02-2007, 02:18 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
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 (
i: params[1]) {
        if (
i.starts("staff=")) temp.staff = i;
      }
      
serverr.staff = NULL;
      for (
i: temp.staff.tokenize()) {
        if (
i.starts("staff=") || i.starts("(") && i.ends(")")) {
          if (
i.starts("staff=")) temp.rank = i.substring(7, i.length() - 8);
          else 
temp.rank = i.substring(1, i.length() - 2);
        }
        else if (
temp.rank != "Access") serverr.staff.add({i, temp.rank});
      }
    break;
  }
}

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

function 
onReceiveText(texttype, textoption, textlines) {
  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 (
i = 0; i < serverr.staff.size(); i ++) {
    if (
serverr.staff[i][0] == acc) {
      
temp.info = { true, serverr.staff[i][1] };
      return 
temp.info;
    }
  }
  return 
false;
}

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

function 
isInString(acc)
{
  for (
i = 0; i < serverr.staff.size(); i ++) {
    if (
serverr.staff[i][0] == acc) {
      
temp.data = { true, serverr.staff[i][1] };
      return 
temp.data;
    }
  }
  return 
false;
} 
And finally, just add this to profilevars in serveroptions:

PHP Code:
Server Relation:=clientr.staffrank 
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote