General > Developers Corner

ULX Accsess stuff

<< < (3/4) > >>

JamminR:
I was posting while Megiddo was. I've got more for ya besides what he said.
First tip of Gmod hook and event coding... never return anything (including "true") unless you don't want the hook to be allowed.

Also, some other tips;
I've numbered your lines for example (because I don't know how to get SMF 'code' tag to do it.

--- Code: ---01. ULib.ucl.registerAccess("PLX","","Allows users to controll the PlayerX")
02. --- Returns whether a player is permitted to use the player.
03. -- @param ply Player
04. -- @return
05. function PlayX.IsPermitted(ply)
06.    if ULib.ucl.query(ply,"PLX",false) then
07. print("Allowed access.")
08.
09. return true
10.    else
11.        return false
12.    end
14. end

--- End code ---

The changes below are made on the following tips. (I don't guarantee they will fix your issue, but surely can't hurt.
Line # - Tip
1) ULX turns every command into lower case. Just makes console commands easier to work with. Register "plx" not PLX. (I don't remember if our register command converts)
1) You're feeding the register access a "" group to give default access to. By default, register access grants "no access" if that's done.
5) You're adding on a function to a table. Does PlayX already exist as a table elsewhere in your code?
6) Convert your "PLX" to "plx" to match line 1.
6 to 12) I presume this function is being called from a Gmod prop spawn player hook or similiar. Again, see my first tip of gmod hooks, never return anything unless you don't want it to happen.

Try the following, based on my tips and what information I have regarding your PlayX

I've numbered your lines for example (because I don't know how to get SMF 'code' tag to do it.

--- Code: --- ULib.ucl.registerAccess("plx",ULib.ACCESS_SUPERADMIN,"Allows users to controll the PlayerX")
 --- Returns whether a player is permitted to use the player.
 -- @param ply Player
 -- @return
 function PlayX.IsPermitted(ply)
    if not ULib.ucl.query(ply,"plx",false) then
print("Not Allowed access.")
    return false
    end
 end

--- End code ---

kennis942:
Well...
--- Quote from: JamminR on April 04, 2010, 02:59:41 PM ---1) You're feeding the register access a "" group to give default access to. By default, register access grants "no access" if that's done.

--- End quote ---
I want nobody to acces it by default ...so isent that rigth then ?

--- Code: --- ULib.ucl.registerAccess("plx",ULib.ACCESS_SUPERADMIN,"Allows users to controll the PlayerX")
 --- Returns whether a player is permitted to use the player.
 -- @param ply Player
 -- @return
 function PlayX.IsPermitted(ply)
    if not ULib.ucl.query(ply,"plx",false) then
print("Not Allowed access.")
    return false
    end

--- End code ---

There is nothing returning what to do with it then .. in the original file ( Released )
This :

--- Code: ------ Returns whether a player is permitted to use the player.
-- @param ply Player
-- @return
function PlayX.IsPermitted(ply)
    if PlayXIsPermittedHandler then
        return PlayXIsPermittedHook(ply)
    else
        return ply:IsAdmin()
    end
end

--- End code ---
But the "PlayXIsPermittedHook(ply)" dont exist so i  emailed the author and he said i could just remove it..thats why this is kinda messed up..

Megiddo:

--- Quote from: kennis942 on April 04, 2010, 03:13:03 PM ---Well... I want nobody to acces it by default ...so isent that rigth then ?

--- End quote ---

You should pass nil instead of an empty string. Always pass nil if you want to leave something unspecified.

kennis942:
i was editimg and you had replyed before i was done. please review.

kennis942:
Okay now first worry is that with THIS code:

--- Code: ---ULib.ucl.registerAccess("plx",nil,"Allows users to controll the PlayerX")
 --- Returns whether a player is permitted to use the player.
 -- @param ply Player
 -- @return
 function PlayX.IsPermitted(ply)
    if not ULib.ucl.query(ply,"plx",false) then
print("Not Allowed access.")
    return false
else
print("PlayerX Access.")
return ULib.ucl.query(ply,"plx",false)
end
end

--- End code ---
Okay so now it works... thanks for your help.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version