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 (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..
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
(wee I even fixed something I misspelled in my old post!)