• xPermissions - Permission Denied.
    50 replies, posted
I've been working on an addon called xPermissions, which is basicly something for Lua coders to implement into scripts. You can do stuff like. [lua] function LetUsNoClip(ply) if xPermissions and xPermissions.HasPermission(ply, "noclip") then return true else return false end end hook.Add("PlayerNoClip", "xPermissionsTest", LetUsNoClip) [/lua] It will be released soon as soon as I work out all of the bugs. You can also assign a player a '*' permission to let them access everything. Functions: xPermission.GetPermissions(PLAYER Object) -- Returns a table of all the players permissions. xPermission.GivePermission(PLAYER Object, STRING permission) -- Gives a player a permission. xPermission.HasPermission(PLAYER Object, STRING permission) -- Returns true if a player has a permission, Returns false if they do not. xPermission.RemovePermission(PLAYER Object, STRING permission) -- Removes a players permission, if they do not have permission, it returns nil. xPermission.SetPermissions(PLAYER Object, TABLE permissions) -- Sets a players permission, (WARNING: Accepts tables only.) Current Bugs: For some reason, Permissions started to durr when I put it on a dedicated server instead of a listen server. - Should be fixed. You can also use this in DarkRP to restrict weapons and jobs to certain players. Instead of true/false for the admin boolean on the AddCustomTeam function, use [lua]xPermissions.HasPermission(ply, "whateverpermission")[/lua]
How will these permissions be stored?
[QUOTE=_nonSENSE;33920954]How will these permissions be stored?[/QUOTE] SQLite, Why? I might add some more storage methods such as GLON and MySQL
[QUOTE=tazy4tazy;33921034]SQLite, Why? I might add some more storage methods such as GLON and MySQL[/QUOTE] GLON isn't a method of storing data, it's a method for compressing data. I assume you say GLON, but mean to say text file?
someone could find this useful i suppose. I suggest for the sake of actually getting publicity( Lua Libraries like this don't get a lot of attention believe me ), you make a menu for admins to give permissions and include all the basic sandbox hooks for permissions. also how many "bugs" could there be with this? I can't possibly imagine how you'd manage to get a bug with storing true/false on the player
[QUOTE=tazy4tazy;33919257] Current Bugs: For some reason, Permissions started to durr when I put it on a dedicated server instead of a listen server.[/QUOTE] your bugs are very descriptive
[QUOTE=Knallex;33922580]your bugs are very descriptive[/QUOTE] When I put it on a listen server, it returns true when a player has the permission, when its dedicated, it returns false when the player has the permission.
[QUOTE=tazy4tazy;33922672]When I put it on a listen server, it returns true when a player has the permission, when its dedicated, it returns false when the player has the permission.[/QUOTE] never ran into this. something you must be doing weird with your code.
[QUOTE=LauScript;33922759]never ran into this. something you must be doing weird with your code.[/QUOTE] [lua] if !ply or !perm then return end local plyperms = xPermissions.GetPermissions(ply) if table.HasValue(plyperms, "*") or table.HasValue(plyperms, perm) then return true else return false end [/lua] Dont see whats wrong.
[lua]function YourFunction(ply, perm) if table.HasValue(plyperms, "*") or table.HasValue(plyperms, perm) then return true end return false end[/lua] Why add the "else".
[lua]function YourFunction(ply, perm) return table.HasValue(plyperms, "*") or table.HasValue(plyperms, perm) end[/lua]
[QUOTE=tazy4tazy;33921034]SQLite, Why? I might add some more storage methods such as GLON and MySQL[/QUOTE] You don't even know how to use SQLite
god damnit, it works in singleplayer/listen servers, but it wont work on dedicated servers.
I'd rather have a general purpose addon that allows you to save any sort of data for players (except tables).
[QUOTE=Chessnut;33923416]You don't even know how to use SQLite[/QUOTE] Playerdata uses SQLite, he doesn't need to know. [QUOTE=Hentie;33924494]I'd rather have a general purpose addon that allows you to save any sort of data for players (except tables).[/QUOTE] pdata. btw a permissions library is useless, player:SetPData("CanNoclip", true ); player:GetPData("CanNoclip"); like my lib?
[lua]hook.Add("PlayerNoClip", "xPermissionsTest", function(ply) return xPermissions.HasPermission(ply, "noclip") end)[/lua] Why take up 15 lines when you could just use 3? And this is such a basic addon. Any developer that can actually do decent scripting wouldnt need this.
[QUOTE=Science;33925528]And this is such a basic addon. Any developer that can actually do decent scripting wouldnt need this.[/QUOTE] Don't hate on other peoples work when you can't do better you're self
[QUOTE=Dame Flawless;33925552]Don't hate on other peoples work when you can't do better you're self[/QUOTE]Yay. Flawless is back. I could make this system so easily and have it encorporate more than he has.
oh yeah well i can make it better than all u nerds!!! anyone wasting there time arguing over this is stupid, if this is released, [b][i]someone might[/i][/b] find it useful. leave it at that and quit being retards talking about who can store a bool on the player "better", it's pathetic.
Reminds me of things like PermissionsBukkit
[QUOTE=Science;33925704]Yay. Flawless is back. I could make this system so easily and have it encorporate more than he has.[/QUOTE] You can't code, get over yourself, no one gives a shit. For the Permissions, this would be something useful for an admin mod, I don't see it being useful for something else other than that. [highlight](User was banned for this post ("Derailing" - Grea$eMonkey))[/highlight]
-He got banned, no need to argue-
I got xPermissions released bro. [lua] xPermission = {}; function xPermission.add(client, permission) client:SetPData(permission, true); end; function xPermission.remove(client, permission) client:RemovePData(permission); end; function xPermission.has(client, permission) return client:GetPData(permission, false); end; [/lua]
That really is the entire thing lol
If you want the version using the player metatable: [lua] local playerTable = FindMetaTable("Player"); playerTable.XPerm_Give = playerTable.SetPData; playerTable.XPerm_Take = playerTable.RemovePData; playerTable.XPerm_Has = playerTable.GetPData; [/lua]
The purpose of this was for developers to implement it into scripts, for instance, you can replace [lua] function LetsDoSomeShit(ply) if ply:IsAdmin() then ...doshit... end end[/lua] With: [lua] function LetsDoSomeShit(ply) if xPermissions and xPermission.HasPermission(ply, "doshit") or ply:IsAdmin() then ...doshit... end end [/lua] So that you can control multiple scripts using one plugin. First Beta (may be buggy, report bugs in this thread) [url=http://dl.dropbox.com/u/15584452/xPermissions.zip][img]http://pud-linux.sourceforge.net/icon/download_manager.png[/img][/url] I will be releasing an addon that uses this permission system in the Sandbox gamemode. So you can restrict propspawning etc.
[lua] if result == "" or result == nil or !result then sql.Query("INSERT INTO xpermissions (personaName, steamID, permissions) VALUES ('"..ply:Nick().."', '"..ply:SteamID().."', '') ") ply:SetNWString("xpermissions", "") else sql.Query("UPDATE xpemissions SET personaName = '"..ply:Nick().."'' WHERE steamID = '"..ply:SteamID().."'") ply:SetNWString("xpermissions", result) end[/lua] Set nick to " lol'); DROP TABLE `xpermissions`; --". Woops. Also: [url]http://wiki.garrysmod.com/?title=R[/url]
[QUOTE=LuaMilkshake;33927850][lua] if result == "" or result == nil or !result then sql.Query("INSERT INTO xpermissions (personaName, steamID, permissions) VALUES ('"..ply:Nick().."', '"..ply:SteamID().."', '') ") ply:SetNWString("xpermissions", "") else sql.Query("UPDATE xpemissions SET personaName = '"..ply:Nick().."'' WHERE steamID = '"..ply:SteamID().."'") ply:SetNWString("xpermissions", result) end[/lua] Set nick to " lol'); DROP TABLE `xpermissions`; --". Woops. Also: [url]http://wiki.garrysmod.com/?title=R[/url][/QUOTE] Dont think that would work, also, I've used _R. before, I just didn't feel like putting it in, might put it in a later version.
Ah, now that I look at it I think you're right about that for SQLite. Regardless, you should sanitize SQL queries. Why are you even storing the player's name?
[QUOTE=LuaMilkshake;33928015]Ah, now that I look at it I think you're right about that for SQLite. Regardless, you should sanitize SQL queries. Why are you even storing the player's name?[/QUOTE] Because, a owner will look in the database and think "God, I have to translate every SteamID in here." (fuuuuu face)
Sorry, you need to Log In to post a reply to this thread.