ULX

Author Topic: My Groups coding - Help  (Read 5906 times)

0 Members and 2 Guests are viewing this topic.

Offline saintmark

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
My Groups coding - Help
« on: May 26, 2008, 06:08:13 AM »
I started out by wanting someone to do my ulib coding for me due to my lack of time, but I have found that with the drive, cigarettes, 2quarts of tea and a headache from reading so much I have been able to come up with my own coding.  ;D
I would like to tell everyone that is starting out to stay focused and to keep at it. It is hard learning something new, but at least you have a great community here. Keep working at it and most importantly read all that you can and take notes. Planning is something that is a must!
1st plan out what groups you would like to have and what rights/powers each of them will have.
2nd place them in order from highest to lowest.
3rd find the format.txt and copy the section that relates to the "groups".
4th make a new text document (located on your desktop) and call it groups.txt
5th open your new groups.txt and paste the outline
6th fill in all the information.
This will get you going. This is what I did and as you will see below it turned out nice (or at least I am proud of it!)
I still need some of you coding Gods to look it over. I also need to make further tweaks to it, but that will be in another post.

Code: [Select]
"superadmin"
{
"allow"
{
"ulx hiddenecho"
"ulx rcon"
"ulx luarun"
"ulx cexec"
"ulx ent"
"ulx adduser"
"ulx removeuser"
"ulx userallow"
"ulx userdeny"
"ulx addgroup"
"ulx removegroup"
"ulx groupallow"
"ulx groupdeny"
"overcomeimmunity"
"ulx tooldeny"
"ulx toolallow"
"ulx tooldenyuser"
"ulx toolallowuser"

}
"deny"
{

}
"inherit_from"
{
"admin"
}
}
"admin"
{
"allow"
{
"ulib_passtime"
"ulib_passtimeout"
"ulx spawnecho"
"ulx tsay"
"ulx csay"
"ulx gimp"
"ulx mute"
"ulx ungimp"
"ulx unmute"
"ulx gag"
"ulx ungag"
"ulx chattime"
"ulx welcomemessage"
"ulx slap"
"ulx whip"
"ulx slay"
"ulx sslay"
"ulx ignite"
"ulx unignite"
"ulx playsound"
"ulx freeze"
"ulx unfreeze"
"ulx god"
"ulx ungod"
"ulx noclip"
"ulx hp"
"ulx armor"
"ulx cloak"
"ulx uncloak"
"ulx blind"
"ulx unblind"
"ulx jail"
"ulx unjail"
"ulx ghost"
"ulx unghost"
"ulx ragdoll"
"ulx unragdoll"
"ulx maul"
"ulx strip"
"ulx adminmenu"
"ulx clientmenu"
"ulx mapsmenu"
"ulx showmotd"
"ulx banmenu"
"ulx exec"
"ulx rslotsmode"
"ulx rslots"
"ulx rslotsvisible"
"ulx reservedslots"
"ulx bring"
"ulx goto"
"ulx send"
"ulx teleport"
"ulx tooldenyoverride"
"ulx map"
"ulx kick"
"ulx ban"
"ulx banid"
"ulx unban"
"ulx spectate"
"ulx mingekick"
"ulx physgunplayer"
"ulx vote"
"ulx votemap2"
"ulx votekick"
"ulx voteban"
"ulx veto"
"ulx_cvar"
}
"deny"
{

}
"inherit_from"
{
"moderator"
}
}
"moderator"
{
"allow"
{
"ulx mingekick"
"ulx banid"
"ulx kick"
"ulx ban"
"ulx bring"
"ulx goto"
}
"deny"
{

}
"inherit_from"
{
"vip"
}
}
"vip"
{
"allow"
{
"ulx teleport"
"ulx bring
"ulx kick"
"ulx votekick"
"ulx voteban"
}
"deny"
{

}
"inherit_from"
{
"respected"
}
}
"respected"
{
"allow"
{

}
"deny"
{

}
"inherit_from"
{
"regulars"
}
}
"regulars"
{
"allow"
{
"noclip"
}
"deny"
{

}
"inherit_from"
{
"user"
}
}
"user"
{
"allow"
{
"ulx"
"ulx help"
"ulx psay"
"ulx asay"
"ulx thetime"
"ulx menu"
"ulx_valueupdate"
"ulx_getgamemodes"
"ulx motd"
"ulx_getbans"
"ulx usermanagementhelp"
"ulx who"
}
"deny"
{
"noclip"
}
"inherit_from"
{

}
}
« Last Edit: May 26, 2008, 07:52:11 AM by JamminR »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: My Groups coding - Help
« Reply #1 on: May 26, 2008, 07:51:33 AM »
7th) Copy your newly created groups.txt to <root gmod>/data/Ulib/ - Not back to <root gmod>/addons/Ulib/data - Any updates to ULib would overwrite the addons folder changes  you made if you do.

SaintMark, in your group "regulars", you have "noclip". Not sure what that is.. perhaps you meant "ulx noclip", which would allow your group to use "ulx noclip" and allow them to noclip through peoples props if you use "UClip", a fine release here on our forums.

All,
Though manually editing of the groups.txt is absolutely fine, if you aren't going to be adding many groups, or many functions to the groups, you can also use ULX from your server console or with rcon access. See "ulx usermanagementhelp" from console for the explanation of the following
ulx addgroup <goupname> <group to inherit>
Then to allow that group something, if the group inherited doesn't already have it.
ulx groupallow <groupname> "ulx <command>"
Even better, if you inherited a group that has access to something that the group you just created shouldn't, you can use
ulx groupdeny <groupname> "ulx <command>"
This would be handy so you don't have to retype all the allow commands but one or two just to make two groups similiar.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline saintmark

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
Re: My Groups coding - Help
« Reply #2 on: May 26, 2008, 08:21:14 AM »
Thanks JamminR!

I am using the following addons:
Uclip
Uteam
Utime
AntiAfk
sui_scoreboard

what I was trying to do is to have it so that the group "user" could not use Uclip/Noclip. I want Superadmins and Admins to have NoClip and the others to have Uclip.
I tried with no luck~I fail, but I have been up way too long...
After i get some sleep I with a clear head i will start to try and fix it. Any suggestions would be great!

Thanks,
Saint Mark

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: My Groups coding - Help
« Reply #3 on: May 26, 2008, 10:19:31 AM »
Uclip is written so that if server noclip is on, 'regular players' (users, in ULib terms) can 'fly', but not through others props or the world ground/walls.
There is no way to turn off user noclip, but still allow non-user noclip using UClip.
However, if you give your other groups "ulx noclip" access, they can use noclip even if server doesn't have sbox_noclip on or UClip installed.

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline saintmark

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
Re: My Groups coding - Help
« Reply #4 on: May 26, 2008, 04:14:47 PM »
ahhhhh... no wonder i could not get it to work... thanks

After I got some sleep and with assistance from JamminR I got my Uteam working!!!!

Offline saintmark

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
Re: My Groups coding - Help
« Reply #5 on: May 28, 2008, 10:55:47 AM »
I took some code from http://forums.ulyssesmod.net/index.php/topic,3392.0.html  and tried to make it work for me, but I failed. Respected, vip and moderator do not spawn with all weapons. Where did I go wrong?

weapon_control.lua

Code: [Select]
function Loadout( ply )
if !ply:IsAdmin() and !ply:IsUserGroup("moderator") and !ply:IsUserGroup("vip") and !ply:query("respected") then
              ply:Give("weapon_physcannon")
      ply:Give("weapon_physgun")
      ply:Give("gmod_tool")
      ply:Give("gmod_camera")
      ply:Give("weapon_pistol")
      ply:SelectWeapon("weapon_physcannon")
      return true
        end
return false
end
hook.Add( "PlayerLoadout", "gravAndShot", Loadout)


Would this work for Stool control?

stool_control.lua

Code: [Select]
function MPUseTool( ply, tr, toolmode )
local denies = {"rt_antinoclip", "light", "lamp", "ignite", "rtcamera", "trails", "wire_light", "wire_lamp", "wire_trails"}
for _, v in pairs(denies) do
if v == toolmode then
if !ply:IsAdmin() then
ply:PrintMessage( HUD_PRINTTALK, "This tool is restricted to Admins" )
return false
end
end
end
end
hook.Add( "CanTool", "MPUseTool", MPUseTool );

function MPUseTool( ply, tr, toolmode )
local denies = {"balloon", "smartwelder", "wire_igniter", "emitter"}
for _, v in pairs(denies) do
if v == toolmode then
if !ply:IsAdmin() and !ply:IsUserGroup("moderator") and !ply:IsUserGroup("vip") then
ply:PrintMessage( HUD_PRINTTALK, "This tool is restricted to Admins,Moderators,and VIP members" )
return false
end
end
end
end
hook.Add( "CanTool", "MPUseTool", MPUseTool );

function MPSentSpawn( ply, cls )
local denies = {"stacker", "turret", "dynamite", "wire_turret", "wire_explosive"}
for _, v in pairs(denies) do
if v == cls then
if !ply:IsAdmin() and !ply:IsUserGroup("moderator") and !ply:IsUserGroup("vip") and !ply:query("respected") then
ply:PrintMessage( HUD_PRINTTALK, "This entity is restricted to Admins and Platinum Members" )
return false
end
end
end
end
hook.Add( "PlayerSpawnSENT", "MPSentSpawn", MPSentSpawn );



This is my 1st attempt at lua coding so please be gentle.
Thanks,
Saint Mark

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: My Groups coding - Help
« Reply #6 on: May 28, 2008, 11:48:19 AM »
specifically what about it doesnt work? A quick glance at it, it looks right.

Offline saintmark

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
Re: My Groups coding - Help
« Reply #7 on: May 28, 2008, 03:17:58 PM »
the weapon_control.lua takes away the weapons correctly on the guest but gives no weapons to the rest. It only gives limited ammo on the pistol as well.

Nothing about stool_control.lua works :(

I placed both luas in the garrysmod/lua/autorun/server/  folder


Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: My Groups coding - Help
« Reply #8 on: May 28, 2008, 04:31:11 PM »
A few pointers ...
RE: your weapons code


"query" doesn't equal query group.
http://www.ulyssesmod.net/docs/files/lua/ULib/shared/sh_ucl-lua.html#ULib.ucl.query
query is an alias for ULib.ucl.query, which, verifies player has (true or false) access to a command. That is, it could test for all those 'ulx <command>' in a groups allow list (or deny)

I recommend changing the "respected" query to IsUserGroup

If the above fix doesn't work, try moving the code from /lua/autorun/server to gmod/lua/Ulib/modules
It's possible the code could run before the ULib groups are started.
(One day, I'll teach you how to make it an addon, so you don't have to worry about backing up tons of files from the lua and other misc folders.)

Just in case you didn't know,
A) "!" equals not in Lua. (At least in Gmod lua, I don't know if it's 100% true Lua or not - Garry added some C construct to make it 'easier' for him.)
B) All statements of an "if" statement that uses "AND" must be true, or the statement is false.
C) Returning anything but nil causes Gmod game hooks to do nothing, and doesn't allow for any other scripts using same hook to continue.
So, returning true kills the continue, which, if you're preventing loadout, is fine.

However, returning false prevents anything from happening too

I recommend changing the 'return false' to 'return' (which should allow full loadout)

Your weapons code, with the corrected "respected" group check, and changed 'return' would be like this in more english like flow
If player is NOT admin AND is NOT moderator AND is NOT vip AND is NOT respected then
give the few limited weapon
Return "true" to normal, no more loadout scripting by anything.
(but if not)
return to normal, give normal weapons, allow any other scripts that use loadout to continue.

[edit] - That was kind of a stream of various code thoughts, done in bad order. I've bold'ed the two glaring things that will definitely break things... the rest are just helpful
« Last Edit: May 28, 2008, 04:34:20 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline saintmark

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
Re: My Groups coding - Help
« Reply #9 on: May 28, 2008, 05:26:39 PM »
Lets see if I got what you said.
made the changes to weapon_control.lua below

If the above fix doesn't work, try moving the code from /lua/autorun/server to gmod/lua/Ulib/modules
It's possible the code could run before the ULib groups are started.
(One day, I'll teach you how to make it an addon, so you don't have to worry about backing up tons of files from the lua and other misc folders.)

I dont have a gmod/lua/Ulib/modules folder should i make one and put it there? ( there is no Ulib file in my gmod/lua folder)

Code: [Select]
function Loadout( ply )
if !ply:IsAdmin() and !ply:IsUserGroup("moderator") and !ply:IsUserGroup("vip") and !ply:IsUserGroup("respected") then
              ply:Give("weapon_physcannon")
      ply:Give("weapon_physgun")
      ply:Give("gmod_tool")
      ply:Give("gmod_camera")
      ply:Give("weapon_pistol")
      ply:SelectWeapon("weapon_physcannon")
      return true
        end
return
end
hook.Add( "PlayerLoadout", "gravAndShot", Loadout)
« Last Edit: May 28, 2008, 05:29:11 PM by saintmark »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: My Groups coding - Help
« Reply #10 on: May 28, 2008, 07:15:57 PM »

I dont have a gmod/lua/Ulib/modules folder should i make one and put it there? ( there is no Ulib file in my gmod/lua folder)


Yes.
And from my first look-over, the code looks good. (The part you have as 'return true' could have been left 'return false', BUT both will have same effect. You're not returning nil, so rest of loadout (and other scripts) will stop)
« Last Edit: May 28, 2008, 07:23:02 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming