I have a code file for GM tools, im pretty sure i got it from this site, its called magehrr-orig
i think deadron made it?
anyway im having some problems with it....
mob
Login()
seeadmin()
..()
proc/seeadmin()
var/list/admin = dd_file2list("admin.txt")
var/list/gm = dd_file2list("gm.txt")
var/list/ban = dd_file2list("banned.txt")
usr.name = dd_replacetext(usr.name, "-{Admin}", "" )
usr.name = dd_replacetext(usr.name, "-{GM}", "" )
if(usr.key in ban)
world << "You are banned!"
spawn()
Logout()
else if(usr.key in gm)
usr << "you GM"
usr.name += "-{GM}"
icon = 'GM.dmi'
density = 0
var/mob/gm/T = new()
T.loc = locate(3,1,1)
T.name = src.name
T.key = src.key
else if(usr.key in admin)
usr << "you admin"
usr.name += "-{Admin}"
icon = 'Admin.dmi'
density = 0
var/mob/admin/L = new()
L.loc = locate(3,1,1)
L.name = usr.name
L.key = src.key
now the problem is in the lines "L.key = src.key" and "T.key = src.key"
correct me if im wrong but arnt these lines trying to change your key? somthing which cant be done?
anyway when i run the game, i get the "this program has performed an illegal operation" error and it crashes back to windows.
if i comment out those lines then the game runs, it works to some degree (adds -(admin) to my name) but doesnt give me access to the gm tools:
mob/admin
verb
Zsay(msg as text)
set category = "Admin Tools"
src << [usr]: [msg]
oview(src) << "[src]: [msg]"
kck()
set category = "Admin Tools"
set name = "Kick"
argh()
boom()
set category = "Admin Tools"
set name = "Ban"
bn()
addamin()
set category = "Admin Tools"
set name = "Add-A-Admin"
addadmin()
addgm()
set category = "Admin Tools"
set name = "Add-A-GM"
addagm()
teleport(mob/M as mob in world)
set category = "Admin Tools"
set name = "Goto Player"
usr.loc = M.loc
reload()
set category = "Admin Tools"
set name = "Reboot the World"
spawn() world.Reboot()
can someone help me fix this?
ID:180645
![]() Apr 20 2001, 6:39 am (Edited on Apr 20 2001, 9:36 pm)
|
|
![]() Apr 20 2001, 9:37 pm
|
|
anyone?
|
now the problem is in the lines "L.key = src.key" and "T.key = src.key" Changing your key can be done, and in fact it is a very useful tool. When you change a mob that didn't have a key to now have a key, the player with that key will instantly be connected to that mob, going through the new mob's mob/Login() proc. So if you make a new mob and then set its key to usr.key, the usr will be connected to that new mob. It's a very useful tool, like I said. anyway when i run the game, i get the "this program has performed an illegal operation" error and it crashes back to windows. I wish I could help, but it's got me buffaloed. |
the thing is, taht Byond compiles it fine with no errors, but when i run it, i get that windows error and it crashes...
this would perhaps indicate that its not a problem in the code, but an actual bug in the byond program? |
On 4/21/01 7:31 pm Mloren wrote:
the thing is, taht Byond compiles it fine with no errors, but when i run it, i get that windows error and it crashes... BYOND isn't supposed to crash at all, so yes, that's a bug. But the primary issue here is which line is causing it to crash, which isn't known. BYOND used to crash if there was an infinite loop, too, though that was supposedly fixed. |
But the primary issue here is which line is causing it to crash, which isn't known. yes... its the lines that use the word "key" eg T.key = src.key if i comment all these out, then it doesnt crash, if i leave just one in, it crashes. |
The problem is an infinite loop inside admin.dm. We should be catching this and not crashing, but it's a tricky problem and we can't yet handle all cases. I'll try to explain and you can make the necessary corrections. If this is code from somewhere else, please inform the author as well.
you have this line: mob/Login() seeadmin() ..() and then: proc/seeadmin() ... // something like this var/mob/admin/M = new() M.key = src.key As you noticed, it's the last line causing problems. So you might want to know what it does. Basically, when you first login to the game, your "key" is assigned to a mob of type world.mob (which is /mob by default). You then actively play as that mob, inheriting all of its verbs and such. But what if you don't want to be a /mob, but something else (like a /mob/admin) instead? One way to do this is to reassign the key. You create a new mob of the type you want and then assign your key to that (you key can only be in one place at once). Now, the confusing part (and I wish we had rethought the notation here): the mob/Login() proc is called whenever a key is assigned to a mob, that is, when a user "logs into" a mob (ditto for mob/Logout()). This usually only happens when a user first connects to a game, but in your case it also happens because you are manually reassigning the key. So what's happening? When you get to that line 'M.key = src.key' you are calling the Login() proc for your new mob (/mob/admin/Login()). But since you haven't overriden that, it just calls the default version, /mob/Login(). And this calls seeadmin() again, and we have an infinite loop. So to fix this you'll want to override the Login() proc for all of the new "administration" mobs, so that they don't call the default version. Eg: mob/admin/Login() return // don't do anything or it might be better to just check for this in your "global" Login() proc: mob/Login() if(!istype(/mob/admin)) // check for all admin types here seeadmin() // okay, we haven't checked yet ..() (the reason this second option is better is that it calls the built-in Login() default (the ..()) part, which does some initial junk). I hope this makes some sense. I wrote a tutorial on this a while ago; I'll put that up eventually. |