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 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
  #2  
Old 02-02-2007, 02:04 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Useful, indeed.


Nice work.
Reply With Quote
  #3  
Old 02-02-2007, 02:17 AM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
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);
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #4  
Old 02-02-2007, 02:18 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
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 
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #5  
Old 02-02-2007, 02:18 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by JkWhoSaysNi View Post
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.
Reply With Quote
  #6  
Old 02-02-2007, 02:18 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
Quote:
Originally Posted by JkWhoSaysNi View Post
Doesn't work.

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

Quote:
Originally Posted by Gambet View Post
Though it's supposed to start clientrc once you use it, at least from the looks of it.
It should, and it does.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #7  
Old 02-02-2007, 02:24 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
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.
Reply With Quote
  #8  
Old 02-02-2007, 03:52 AM
Matt Matt is offline
iZone Administrator
Matt's Avatar
Join Date: Apr 2005
Location: United States
Posts: 2,690
Matt is a jewel in the roughMatt is a jewel in the rough
Nice work.
__________________
Need Playerworld or Account support?
GraalOnline/Toonslab Support Center
Reply With Quote
  #9  
Old 02-02-2007, 05:12 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Useful =] rep++
Reply With Quote
  #10  
Old 04-27-2007, 06:14 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
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!)
__________________

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

Last edited by xXziroXx; 04-27-2007 at 06:46 AM..
Reply With Quote
  #11  
Old 04-27-2007, 06:26 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
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
__________________
Do it with a DON!
Reply With Quote
  #12  
Old 05-03-2007, 07:05 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
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
Reply With Quote
  #13  
Old 05-11-2007, 07:21 PM
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
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.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #14  
Old 05-11-2007, 07:24 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
lolol
What an arrogant person to not even read the entire thread...
Reply With Quote
  #15  
Old 05-12-2007, 02:39 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by xXziroXx View Post
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)

PS:
postcount++;
__________________
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 09:25 AM.


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