PDA

View Full Version : Get all staff from serveroptions


xXziroXx
02-02-2007, 01:58 AM
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:


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 != "Temp") 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);
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..


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:

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:


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


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:

Server Relation:=clientr.staffrank

Gambet
02-02-2007, 02:18 AM
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
Doesn't work.

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

Yes.

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, 07:14 AM
Update: no longer tokenize account names that has any spaces in it.


wNPC:


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 != "Temp") 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, contains a function that checks if the player is staff or not (player.IsStaff()). Works both clientsided and serversided..


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:

Server Relation:=clientr.staffrank


(wee I even fixed something I misspelled in my old post!)

zokemon
04-27-2007, 07: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, 08:05 AM
Update: no longer makes client RC not work


wNPC:


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 != "Temp") 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);
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..


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:

Server Relation:=clientr.staffrank


W00t!

xXziroXx
05-11-2007, 08: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 (http://forums.graalonline.com/forums/showthread.php?t=73794) should be done.

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

Chandler
05-11-2007, 08:24 PM
lolol
What an arrogant person to not even read the entire thread...

cbk1994
05-12-2007, 03:39 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 (http://forums.graalonline.com/forums/showthread.php?t=73794) should be done.

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

Rep ++ (on first post) :D

PS:
postcount++;

Rapidwolve
05-12-2007, 10:31 PM
Isn't there a serveroptions.txt file? That way you don't need the clientrc part.

Skyld
05-12-2007, 10:39 PM
Isn't there a serveroptions.txt file? That way you don't need the clientrc part.
I might be mistaken, but it needs to be symlinked up by Stefan for it to be accessible, and I can imagine that being quite insecure if someone inadvertedly gives scripts write access to it.