ID:926258
 
(See the best response by DarkCampainger.)
Code:
client
var
adminlvl = 0

proc
give_admin(var/client/m, lvl)
lvl = max(0, min(adminLevels.len, lvl))
for(var/x = 1, x <= lvl, x++)
m.verbs += typesof(adminLevels[x])
m << "You have been given level [lvl] admin abilities."
if(!admins.Find(src))
admins += src
adminlvl = lvl
save_admins(m, lvl)

null_power(var/client/target)
world << adminlvl
world << target.adminlvl
if(target.adminlvl >= adminlvl)

src << "[target.key] is too high level of an admin to perform this action."
return FALSE
return TRUE

client/Level4
var/Admin = 4
verb

Make_Admin(client/target in world, var/lv as num)
set category = "Admin"
if(null_power(target))
give_admin(target, lv)


Problem description:

I'm having problems with my admin system once again.. I just cannot figure out what is going wrong here. I'm getting a runtime error when I use the Make_Admin verb, saying 'adminlvl' for the target is undefined. It says...

runtime error: undefined variable /mob/var/adminlvl
proc name: null power (/client/proc/null_power)
source file: Admin.dm,45
usr: Kits (/mob)
src: Kitsueki (/client)
call stack:
Kitsueki (/client): null power(keynamehere (/mob))
Kitsueki (/client): Make Admin(keynamehere (/mob), 4)


Now, as you can see the variable -is- defined, but I'm being told otherwise. Anyone have any clue what the problem is?

runtime error: undefined variable /mob/var/adminlvl


It's trying to connect to it as if it was defined for a mob and not the client.

if(!admins.Find(src))
admins += src


Shouldn't src be m?
Yeah, it should be m, thanks for pointing that out, lol.
That, however.. didn't fix the issue. I'm still being told adminlvl is undefined. Nowhere do I specify a mob, so idk why it's assuming it's a mob.
Outputting the variables was my attempt at seeing what they were set as. I, being coded in at level 5, see "5" outputted, but nothing past that.

The check is seeing if the src of the proc, in this case myself, has an adminlvl less than or equal to the target's adminlvl.

I'm not really sure what you're asking beyond that.
Best response
Read the call stack:
Kitsueki (/client): null power(keynamehere (/mob))
Kitsueki (/client): Make Admin(keynamehere (/mob), 4)


You're passing it a mob. It looks like verb arguments don't know how to handle clients. You'll probably have to build your own list to choose from, or use mobs but do mob.client.

Also, clients aren't considered "in world", as they don't have a location.
Ah.. that makes sense, darn verb arguments! I continued seeing that, saying mob, and it was frustrating me. Since I'm at an intermediate level, I don't want to automatically try blaming the language before I get feedback or try other things to be certain, so thanks for pointing that out.

The latter choice seems simpler, I'll give that a shot first.

Edit: Worked perfectly, thanks for the help DarkCampainger, and you too Kozuma3.

That's a good tip, where did you find that out if I may ask?