ULX

Author Topic: Auto-Codes  (Read 2315 times)

0 Members and 1 Guest are viewing this topic.

Offline ngc0202

  • Newbie
  • *
  • Posts: 31
  • Karma: 0
Auto-Codes
« 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.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Auto-Codes
« Reply #1 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
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline ngc0202

  • Newbie
  • *
  • Posts: 31
  • Karma: 0
Re: Auto-Codes
« Reply #2 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?
« Last Edit: April 28, 2010, 01:27:37 PM by ngc0202 »

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Auto-Codes
« Reply #3 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 - If you're using svn ULib, this should help you out.
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline ngc0202

  • Newbie
  • *
  • Posts: 31
  • Karma: 0
Re: Auto-Codes
« Reply #4 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.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Auto-Codes
« Reply #5 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.
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline ngc0202

  • Newbie
  • *
  • Posts: 31
  • Karma: 0
Re: Auto-Codes
« Reply #6 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?
« Last Edit: April 29, 2010, 01:56:03 PM by ngc0202 »

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Auto-Codes
« Reply #7 on: April 29, 2010, 12:58:56 PM »
No Problem and good luck! :D
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly