• Print

Author Topic: Under the hood question  (Read 25 times)

0 Members and 1 Guest are viewing this topic.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Under the hood question
« on: April 25, 2015, 06:52:35 pm »
I'm looking into a system to allow targeting permissions on commands that call players by ID.

In the function that is used to determine if a player can target another player I see this:
Code: Lua
  1. local return_value, err_msg2 = hook.Call( ULib.HOOK_PLAYER_TARGET, _, ply, cmdInfo.cmd, target )
  2.         if return_value == false then
  3.                 return nil, err_msg2 or "you cannot target this person"
  4.         elseif type( return_value ) == "Player" then
  5.                 target = return_value
  6.         end
  7.  

And I see this in defines:
Code: Lua
  1. ULib.HOOK_PLAYER_TARGET = "ULibPlayerTarget"
  2.  

I cannot for the life of me find where that hook is defined. It's not in the table of hooks. Can anyone help me out with this one?

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Under the hood question
« Reply #1 on: April 26, 2015, 10:06:00 am »
It's for third party hooks. It's not defined anywhere in ULib. :)
Experiencing God's grace one day at a time.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Under the hood question
« Reply #2 on: April 26, 2015, 12:33:43 pm »
Well then, I don't suppose you could point me in the right direction for what I'm trying to do then?
Do we have a helper function or anything that handles if a player can target another player or group?

Ideally I think a helper function that accepted three parameters and returned true or false.

calling_ply
command
target_ply or target_group

I spent a good amount of time yesterday trying to reverse engineer how ULX handles this when a command is run, but I couldn't figure it out.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Under the hood question
« Reply #3 on: April 26, 2015, 02:13:50 pm »
Isn't that what cmds.BaseArg (PlayerArg, PlayersArg) . parseandValidate(_, _, plyRestrictions) does?
http://ulyssesmod.net/docs/files/lua/ulib/shared/commands-lua.html#cmds.BaseArg
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Under the hood question
« Reply #4 on: April 27, 2015, 08:07:39 pm »
The hook you posted about is the hook you're looking for, Mr. P. Here's the documentation for it: http://ulyssesmod.net/docs/files/lua/ulib/shared/defines-lua.html#ULibPlayerTarget
Experiencing God's grace one day at a time.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Under the hood question
« Reply #5 on: April 27, 2015, 09:52:02 pm »
I figured, but then I wasn't able to find where the hook is defined. I'm a little confused.. but it doesn't matter right now. :P

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Under the hood question
« Reply #6 on: April 28, 2015, 04:37:56 pm »
I am confused. You posted the definition in your first code block. There doesn't need to be any underlying function that's being called -- it's simply calling out into the void "does anyone want to process this information?" If there's no response, it continues.
Experiencing God's grace one day at a time.

  • Print