ULX

Author Topic: Spawnmenu as Permission  (Read 3229 times)

0 Members and 1 Guest are viewing this topic.

Offline Darklordx

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Spawnmenu as Permission
« on: December 08, 2019, 04:27:19 AM »
First off all Im sorry for my bad english and my very bad lua skills

I want to make a Permission wich can open the Spawnmenu. So a group without this permission can't open the Spawnmenu.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Darklordx

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: Spawnmenu as Permission
« Reply #2 on: December 16, 2019, 02:25:07 AM »
Yeah but how can i make a Permission with this?

Offline Darklordx

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: Spawnmenu as Permission
« Reply #3 on: December 18, 2019, 07:29:19 AM »
I had try a little bit but i get the Error:

Code: [Select]
[ERROR] addons/ulx/lua/ulx/modules/sh/roger.lua:41: attempt to call field 'registerAccess' (a nil value)
  1. unknown - addons/ulx/lua/ulx/modules/sh/roger.lua:41
   2. include - [C]:-1
    3. unknown - addons/ulx/lua/ulx/cl_init.lua:17
     4. include - [C]:-1
      5. unknown - addons/ulx/lua/ulib/modules/ulx_init.lua:4
       6. include - [C]:-1
        7. unknown - addons/ulib/lua/ulib/cl_init.lua:24
         8. include - [C]:-1
          9. unknown - addons/ulib/lua/autorun/ulib_init.lua:5


I only want to disable the Spawnmenu with an Ulx permission

my code :
Code: [Select]
ULib.ucl.registerAccess("Qmenu", ULib.ACCESS_ALL, "Öffne das Spawnmenu", "Darklord")

local function  qmenu()
    if ULib.ucl.query(ply, qmenu) then
        return true
    else
        return false
    end
end

hook.Add("SpawnMenuOpen", "dontspawn", qmenu()

)
What is wrong? pls help me im very lost





Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Spawnmenu as Permission
« Reply #4 on: December 18, 2019, 06:22:51 PM »
I'm not 100% sure why.
That first line says 'registerAccess' isn't working.
In looking at our other code, it often seems to run on 'server' side. Tried "if SERVER then ULib.ucl.registerAccess(... "?
It isn't _always_ used on server though, so if that doesn't help it, unsure.
You also include an extra close parenthesis ")" at bottom of your code. Make sure that's after your hook function, and don't call the function using qmenu(), just use ", qmenu)"

Also, try to never return 'true' when using a hook. It will often break other functions using the same hook.
Either just 'return', or 'return false'.

Your query player statement is incorrect.
You call function qmenu(), but don't pass information to it in ().

function qmenu(ply)
 if ULib.ucl.query(ply, "Qmenu") then



« Last Edit: December 18, 2019, 06:29:29 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming