General > Developers Corner

Referencing ULX command from a separate hook

(1/1)

iViscosity:
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  :) )

Megiddo:
You don't need Lua for this.

Bind I "ulx slap @;say are you AFK?"

iViscosity:
Oh... So the @ makes it the target player?

MrPresident:
That is correct. :)

There are a couple modifiers you should know:

^ yourself
* everyone
@ your target

iViscosity:
Ah I didn't know about @ thanks.  :)

Navigation

[0] Message Index

Go to full version