Author Topic: Reading Ulib Files  (Read 128 times)

0 Members and 1 Guest are viewing this topic.

Offline captain1342

  • Jr. Member
  • **
  • Posts: 51
  • Karma: 2
    • View Profile
    • Aperture-Hosting
Reading Ulib Files
« on: December 30, 2016, 07:26:54 PM »
Hey,

Well I am trying to Read the groups.txt file to get a table with the groups and its Permissions but .. well when i do this:

      MSync.ULX.Group = util.JSONToTable( file.Read( "ulib/groups.txt", "DATA" ))
      MSync.ULX.Group1 = file.Read( "ulib/groups.txt", "DATA" )
      file.Write( "msync/ulxoutput.txt", util.TableToJSON( MSync.ULX, true ))

Then ulxoutput.txt returns:

{
   "Group1": "\"owner\"\t\n{\n\t\"allow\"\t\n\t{\n\t}\n\t\"inherit_from\"\t\"superadmin\"\n}\n\"user\"\t\n{\n\t\"allow\"\t\n\t{\n\t\t\"ulx asay\"\n\t\t\"ulx help\"\n\t\t\"ulx motd\"\n\t\t\"ulx psay\"\n\t\t\"ulx thetime\"\n\t\t\"ulx urs_echo_commands\"\n\t\t\"ulx urs_echo_spawns\"\n\t\t\"ulx urs_overwrite_sbox\"\n\t\t\"ulx urs_weaponpickups\"\n\t\t\"ulx usermanagementhelp\"\n\t\t\"ulx version\"\n\t\t\"ulx votemap\"\n\t\t\"ulx who\"\n\t}\n}\n\"admin\"\t\n{\n\t\"can_target\"\t\"!%superadmin\"\n\t\"allow\"\t\n\t{\n\t\t\"darkrp_admincommands\"\n\t\t\"darkrp_getadminweapons\"\n\t\t\"darkrp_getjob_cp\"\n\t\t\"darkrp_getjob_mayor\"\n\t\t\"darkrp_seeevents\"\n\t\t\"darkrp_setdoorowner\"\n\t\t\"fpp_cleanup\"\n\t\t\"fpp_touchotherplayersprops\"\n\t\t\"fspectate\"\n\t\t\"fspectateteleport\"\n\t\t\"ulx armor\"\n\t\t\"ulx ban\"\n\t\t\"ulx blind\"\n\t\t\"ulx bring\"\n\t\t\"ulx chattime\"\n\t\t\"ulx cloak\"\n\t\t\"ulx csay\"\n\t\t\"ulx freeze\"\n\t\t\"ulx gag\"\n\t\t\"ulx gimp\"\n\t\t\"ulx god\"\n\t\t\"ulx goto\"\n\t\t\"ulx hp\"\n\t\t\"ulx ignite\"\n\t\t\"ulx jail\"\n\t\t\"ulx jailtp\"\n\t\t\"ulx kick\"\n\t\t\"ulx kickafternamechanges\"\n\t\t\"ulx kickafternamechangescooldown\"\n\t\t\"ulx kickafternamechangeswarning\"\n\t\t\"ulx map\"\n\t\t\"ulx mechatenabled\"\n\t\t\"ulx motdfile\"\n\t\t\"ulx motdurl\"\n\t\t\"ulx mute\"\n\t\t\"ulx noclip\"\n\t\t\"ulx physgunplayer\"\n\t\t\"ulx playsound\"\n\t\t\"ulx ragdoll\"\n\t\t\"ulx reservedslots\"\n\t\t\"ulx return\"\n\t\t\"ulx rslots\"\n\t\t\"ulx rslotsmode\"\n\t\t\"ulx rslotsvisible\"\n\t\t\"ulx seeanonymousechoes\"\n\t\t\"ulx send\"\n\t\t\"ulx showmotd\"\n\t\t\"ulx slap\"\n\t\t\"ulx slay\"\n\t\t\"ulx spawnecho\"\n\t\t\"ulx spectate\"\n\t\t\"ulx sslay\"\n\t\t\"ulx strip\"\n\t\t\"ulx teleport\"\n\t\t\"ulx tsay\"\n\t\t\"ulx unban\"\n\t\t\"ulx unblind\"\n\t\t\"ulx uncloak\"\n\t\t\"ulx unfreeze\"\n\t\t\"ulx ungag\"\n\t\t\"ulx ungimp\"\n\t\t\"ulx ungod\"\n\t\t\"ulx unignite\"\n\t\t\"ulx unigniteall\"\n\t\t\"ulx unjail\"\n\t\t\"ulx unmute\"\n\t\t\"ulx unragdoll\"\n\t\t\"ulx veto\"\n\t\t\"ulx vote\"\n\t\t\"ulx voteban\"\n\t\t\"ulx votebanminvotes\"\n\t\t\"ulx votebansuccessratio\"\n\t\t\"ulx votekick\"\n\t\t\"ulx votekickminvotes\"\n\t\t\"ulx votekicksuccessratio\"\n\t\t\"ulx votemap2\"\n\t\t\"ulx votemap2minvotes\"\n\t\t\"ulx votemap2successratio\"\n\t\t\"ulx votemapenabled\"\n\t\t\"ulx votemapmapmode\"\n\t\t\"ulx votemapmintime\"\n\t\t\"ulx votemapminvotes\"\n\t\t\"ulx votemapsuccessratio\"\n\t\t\"ulx votemapvetotime\"\n\t\t\"ulx votemapwaittime\"\n\t\t\"ulx welcomemessage\"\n\t\t\"ulx whip\"\n\t}\n\t\"inherit_from\"\t\"operator\"\n}\n\"superadmin\"\t\n{\n\t\"allow\"\t\n\t{\n\t\t\"darkrp_changedoorsettings\"\n\t\t\"darkrp_setlicense\"\n\t\t\"darkrp_setmoney\"\n\t\t\"fpp_settings\"\n\t\t\"ulx addgroup\"\n\t\t\"ulx adduser\"\n\t\t\"ulx adduserid\"\n\t\t\"ulx banid\"\n\t\t\"ulx cexec\"\n\t\t\"ulx ent\"\n\t\t\"ulx exec\"\n\t\t\"ulx groupallow\"\n\t\t\"ulx groupdeny\"\n\t\t\"ulx hiddenecho\"\n\t\t\"ulx loadoutadd\"\n\t\t\"ulx loadoutremove\"\n\t\t\"ulx logchat\"\n\t\t\"ulx logdir\"\n\t\t\"ulx logecho\"\n\t\t\"ulx logechocolorconsole\"\n\t\t\"ulx logechocolordefault\"\n\t\t\"ulx logechocoloreveryone\"\n\t\t\"ulx logechocolormisc\"\n\t\t\"ulx logechocolorplayer\"\n\t\t\"ulx logechocolorplayerasgroup\"\n\t\t\"ulx logechocolors\"\n\t\t\"ulx logechocolorself\"\n\t\t\"ulx logevents\"\n\t\t\"ulx logfile\"\n\t\t\"ulx logjoinleaveecho\"\n\t\t\"ulx logspawns\"\n\t\t\"ulx logspawnsecho\"\n\t\t\"ulx luarun\"\n\t\t\"ulx maul\"\n\t\t\"ulx rcon\"\n\t\t\"ulx removegroup\"\n\t\t\"ulx removeuser\"\n\t\t\"ulx removeuserid\"\n\t\t\"ulx renamegroup\"\n\t\t\"ulx restrict\"\n\t\t\"ulx setgroupcantarget\"\n\t\t\"ulx setlimit\"\n\t\t\"ulx stopvote\"\n\t\t\"ulx unrestrict\"\n\t\t\"ulx userallow\"\n\t\t\"ulx userallowid\"\n\t\t\"ulx userdeny\"\n\t\t\"ulx userdenyid\"\n\t\t\"ulx voteecho\"\n\t\t\"xgui_gmsettings\"\n\t\t\"xgui_managebans\"\n\t\t\"xgui_managegroups\"\n\t\t\"xgui_mrsync\"\n\t\t\"xgui_msync\"\n\t\t\"xgui_svsettings\"\n\t\t\"xgui_urs\"\n\t}\n\t\"inherit_from\"\t\"admin\"\n}\n\"operator\"\t\n{\n\t\"can_target\"\t\"!%admin\"\n\t\"allow\"\t\n\t{\n\t\t\"ulx seeasay\"\n\t}\n\t\"inherit_from\"\t\"user\"\n}\n\"noaccess\"\t\n{\n\t\"allow\"\t\n\t{\n\t}\n\t\"inherit_from\"\t\"user\"\n}\n"
}

Which is the same as the Group file.. but i cant get a table from a string.. please help .. i dont understand how to "Compile" that file.
Aperture-Hosting Manager

Web: https://Aperture-Hosting.de
Mail: Webmaster@Aperture-Hosting.de
Github: https://github.com/captain1242
Discord: https://discord.gg/wxpbtYk
Teamspeak: ts3.Aperture-Hosting.de
Support: https://support.Aperture-Hosting.de
"Hosting with Vision"

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 696
  • Karma: 101
  • :)
    • View Profile
    • My Homepage
Re: Reading Ulib Files
« Reply #1 on: December 30, 2016, 07:38:03 PM »
users.txt and groups.txt are parsed using ULib.parseKeyValues following a ULib.removeCommentHeader call to the contents of each file (gathered using ULib.read (example[/url). So, you'll want to use a similar function chain in your own code to parse ULib's data into a table.
bw81@ulysses-forums ~ % whoami
Homepage

I have 10 more Keybase invites! PM me for more information or to request one!
An easy intro to PGP and public-key cryptography

Offline captain1342

  • Jr. Member
  • **
  • Posts: 51
  • Karma: 2
    • View Profile
    • Aperture-Hosting
Re: Reading Ulib Files
« Reply #2 on: December 30, 2016, 07:41:05 PM »
First: Nice Pony :D I am also a Brony

and Second thank you my problem is Solved
Aperture-Hosting Manager

Web: https://Aperture-Hosting.de
Mail: Webmaster@Aperture-Hosting.de
Github: https://github.com/captain1242
Discord: https://discord.gg/wxpbtYk
Teamspeak: ts3.Aperture-Hosting.de
Support: https://support.Aperture-Hosting.de
"Hosting with Vision"