Ulysses

Ulysses Stuff => General Chat & Help and Support => Topic started by: ngc0202 on April 28, 2010, 12:51:43 PM

Title: Auto-Codes
Post by: ngc0202 on April 28, 2010, 12:51:43 PM
Is there anyway I can have it auto-run codes on-join for specific groups? e.g. Admin gets auto god mode.
Title: Re: Auto-Codes
Post by: jay209015 on April 28, 2010, 01:10:52 PM
With a little bit of lua you can. Good chance to learn.
EX:
Code: [Select]
if (ply:GetUserGroup() == "superadmin") then
game.consolecomand("ulx", "god", ply:Nick())
end
Title: Re: Auto-Codes
Post by: ngc0202 on April 28, 2010, 01:21:11 PM
With a little bit of lua you can. Good chance to learn.
EX:
Code: [Select]
if (ply:GetUserGroup() == "superadmin") then
game.consolecomand("ulx", "god", ply:Nick())
end
Where does that lua go?

EDIT: Another question. In the command 'ulx groupallow', it says ulx groupallow <group> <access tag>. What does access tag mean?
Title: Re: Auto-Codes
Post by: jay209015 on April 28, 2010, 01:57:56 PM
That code was just an example of somewhere to start, alone it doesn't do anything but throw out some errors.
I'm currently at work, but when I get home in about an hour, I'll make you a fully functional script if you'd like.

As far as the access tags, do some searching around. Megiddo could explain it better if he jumps on here.
Immunity: How It Works Now (http://forums.ulyssesmod.net/index.php/topic,4314.0.html) - If you're using svn ULib, this should help you out.
Title: Re: Auto-Codes
Post by: ngc0202 on April 28, 2010, 02:18:19 PM
Oh, okay. I read it over and it makes sense now.

EDIT: I would appreciate a full script, that would be good to use as a template to learn from.
Title: Re: Auto-Codes
Post by: jay209015 on April 28, 2010, 04:44:31 PM
Code: [Select]
if !autocodes then
autocodes = {}
end
--Don't touch that up there--
--Configs below--

autocodes.groups = {'superadmin', 'admin', 'operator', 'user'}
autocodes.codes = {
'superadmin' = { 'ulx god', 'ulx cloak' },
'admin' = { 'ulx god' },
}


--End of configs--

function autocodes.applyCodes( ply )
for _, group in pairs(autocodes.groups) do
if autocodes.codes[group] and ( ply:GetUserGroup == group )then
for _, code in pairs(autocodes.codes[group]) do
code = string.Explode( " ", code )
game.consolecommand( code[1], code[2], ply:Nick() )
end
end
end
end
hook.Add( "ULibPlayerReady", "Autocodes_Apply_Hook", autocodes.applyCodes )

Not tested, but pretty sure it's good.
Title: Re: Auto-Codes
Post by: ngc0202 on April 29, 2010, 12:43:22 PM
Awesome, thank you. I haven't tested it yet, but I will edit when I do. First I have to fix that it doesn't copy new lines, so I have to add them myself, its just a oneliner blob.

EDIT: I fixed the code, but how do I get it to work in the server? Where do I put it?
Title: Re: Auto-Codes
Post by: jay209015 on April 29, 2010, 12:58:56 PM
No Problem and good luck! :D