Ulysses

General => Developers Corner => Topic started by: iViscosity on May 09, 2016, 02:34:57 PM

Title: Referencing ULX command from a separate hook
Post by: iViscosity on May 09, 2016, 02:34:57 PM
Hey guys, so I'm trying to make a script for a TTT server that I'm staff on, and what I want it to do is when I press "I" it will slap the target I'm looking at and then in the chat "Are you afk?", as a "check afk" script. What I have now is this (and I don't know if I'm doing this right, should it be in a hook or a function?):

hook.Add( "Tick", "CheckAFK", function()
   local ply = LocalPlayer()
   local trace = util.GetPlayerTrace( ply )
   local traceRes = util.TraceLine( trace )
      if traceRes.HitNonWorld then
      local target = traceRes.Entity
         if target:IsPlayer() then
            if ply:input.WasKeyPressed( I ) then

            end

         end
      end
end)

I don't know if this is right or not, and if it is, how do I continue it?

(If you need any clarification, just ask  :) )
Title: Re: Referencing ULX command from a separate hook
Post by: Megiddo on May 09, 2016, 02:40:16 PM
You don't need Lua for this.

Bind I "ulx slap @;say are you AFK?"
Title: Re: Referencing ULX command from a separate hook
Post by: iViscosity on May 09, 2016, 03:36:42 PM
Oh... So the @ makes it the target player?
Title: Re: Referencing ULX command from a separate hook
Post by: MrPresident on May 09, 2016, 03:58:12 PM
That is correct. :)

There are a couple modifiers you should know:

^ yourself
* everyone
@ your target
Title: Re: Referencing ULX command from a separate hook
Post by: iViscosity on May 09, 2016, 04:11:13 PM
Ah I didn't know about @ thanks.  :)