PDA

View Full Version : Staff Only check


xXziroXx
08-04-2006, 06:42 PM
This function checks if your account is listed in the "staff=" section of the server options, if so it returns "true" and if you're not it returns "false".

Example:

The NPC containing the function(s) is named "System/Functions", and the current NPC want to make a IsStaff() check.


if (("System/Functions").IsStaff() == true) {
// Proceed with script
}



The code can be found here: http://www.graal.net/snippet/detail.php?type=snippet&id=116


Hopefully you find it usefull, enjoy.

DrakilorP2P
08-04-2006, 08:01 PM
A smooth way to check for access. Though what about something like: HasAccess("Staff/Boots")

xXziroXx
08-05-2006, 04:56 PM
A smooth way to check for access. Though what about something like: HasAccess("Staff/Boots")

HasAccess()? Dont you mean hasRight(str, str)?

contiga
08-06-2006, 01:53 PM
Nice Ziro! Like this players still have access to the server, but you can limit their actions, without having another flag (in Control-NPC for example) to update each time you hire / fire a person.

xXziroXx
08-06-2006, 04:42 PM
Nice Ziro! Like this players still have access to the server, but you can limit their actions, without having another flag (in Control-NPC for example) to update each time you hire / fire a person.

Yeah, I thought something like this would be usefull.

DrakilorP2P
08-06-2006, 06:38 PM
HasAccess()? Dont you mean hasRight(str, str)?
I was talking in terms of a manually declared function.

xXziroXx
09-10-2006, 12:31 AM
Mods: Mind moving this to the Code Gallery?

projectigi
09-13-2006, 02:53 PM
link doesnt work for me =(

xXziroXx
09-13-2006, 05:29 PM
link doesnt work for me =(

It should do. Graal.NET was down a few days though, so try again.

projectigi
09-14-2006, 12:33 AM
yeah works now

Twinny
09-14-2006, 09:21 AM
I hate using serverr flags for anything. I'd use a DBNPC called StaffRights and use functions like this:


public function checkrights(ply,right)
{
temp.check = this.([email protected]"_rights").index(right);
if (temp.check >= 0) return true;
else return false;
}

public function addrights(ply,right)
{
if (this.([email protected]"_rights").index(right) < 0)
{
this.([email protected]"_rights").add(right);
return true;
}
else return false;
}

public function removerights(ply,right)
{
if (this.([email protected]"_rights").index(right) >= 0)
{
this.([email protected]"_rights").remove(right);
return true;
}
else return false;
}


This could be used in many other things as well. Thus i'd use StaffRights.addrights("Twinny","MonkeyPowers!");

xXziroXx
09-14-2006, 03:43 PM
I hate using serverr flags for anything. I'd use a DBNPC called StaffRights and use functions like this:


public function checkrights(ply,right)
{
temp.check = this.([email protected]"_rights").index(right);
if (temp.check >= 0) return true;
else return false;
}

public function addrights(ply,right)
{
if (this.([email protected]"_rights").index(right) < 0)
{
this.([email protected]"_rights").add(right);
return true;
}
else return false;
}

public function removerights(ply,right)
{
if (this.([email protected]"_rights").index(right) >= 0)
{
this.([email protected]"_rights").remove(right);
return true;
}
else return false;
}


This could be used in many other things as well. Thus i'd use StaffRights.addrights("Twinny","MonkeyPowers!");

Server strings are used when theres too little data to having to 'waste' a DB for it. I mean, come on - an entire database for one string?

Twinny
09-15-2006, 08:48 AM
I use serverr strings if everbody will be checking them alot. Otherwise i use other methods. Also - that script i wrote for a DB can easily be converted into other similar things.

KuJi
09-15-2006, 02:23 PM
Server strings are used when theres too little data to having to 'waste' a DB for it. I mean, come on - an entire database for one string?

I think you forgot its limited only 255 characters and probally wouldnt fit much.