ID:157590
 
I'm trying to develop an admin code, but have one problem before I even start.

How can I set it so that I can give MY mob a set of verbs that no one else can access, and then how can I make a verb that will give permanent or temporary access to another mob?
#define MASTER_KEY "Blafblabla" //GM now

mob/GM
key = MASTER_KEY

mob/GM/verb
admin_check()
usr << "you are a GM" // only available to the GM, so he must be the GM.
In response to Blafblabla
Blafblabla wrote:
> 
> #define MASTER_KEY "Blafblabla" //GM now
>
> mob/GM
> key = MASTER_KEY
>
> mob/GM/verb
> admin_check()
> usr << "you are a GM" // only available to the GM, so he must be the GM.
>


That admin_check() verb is completely useless. The user shouldn't receive these verbs at all if they're not administration. It's essentially going client/verb/Hey_You() { src << "You're logged into the game! ^.^" }

Also, you're far better off using a list to define staff members, as a game will at some stage, require more than one.
SRI wrote:
How can I set it so that I can give MY mob a set of verbs that no one else can access

To do something like this, you're best off using a list for staff member ckeys, and a datum to store the verbs to add to the user client on New().

As a basic example of what to do, you can do this:
/*
First you need to define a list that contains the ckey() of all your staff members.
If you want to use different staff ranks, there are a majority of ways to do this,
including separate lists or associtive lists with bitflags.

But for the sake of simplicity, we'll just use this for the moment.
*/

var/list/admins = list("tiberath", "mobiusevalon", "nadrew", "lummoxjr")

/*
Now we need a datum to contain all the administrative verbs we want. Boot/ban etc.
Remember, in this datum, 'src' would be /admin. So we must use 'usr' in place.
'usr' is safe to use in verbs, so we don't have to worry about usr abuse.
*/

admin
verb
SomeVerb()
usr << "You have used SomeVerb()!"

SomeOtherVerb()
usr << "You have used SomeOtherVerb()!"

/*
Rather than supplying the verbs to mobs, it's a better idea to supply them to clients,
especially if your plan is to swap mobs at any stage, as per your second request.
This way, the verbs stay with the user regardless of what mob they're using, and we don't
have to reassign them every time a mob-swap occurrs.
*/


client
New()
. = ..()
if(src.ckey in admins) // Check the admins list to see if the users ckey is inside the list.
src.verbs += typesof(/admin/verb) // If the admin check works, give the client the verbs of the admin datum.


Just replace the ckeys in the admin list with the ckeys of the administration team you have.

Things you'll need to know:
client/New()
client.ckey
Lists
in operator
+= operator
typesof()
client.verbs
datum.

All of that should explain what my snippet does and help you to expand it. It might look like a lot of reading, but it's not really, and all sums up to fairly basic stuff you'll need to successfully develop a game. Best to learn this stuff now rather than later.
In response to Tiberath
Great, this helped a lot.

Thanks :)