ULX

Author Topic: Referencing ULX command from a separate hook  (Read 1835 times)

0 Members and 1 Guest are viewing this topic.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Referencing ULX command from a separate hook
« 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  :) )
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Referencing ULX command from a separate hook
« Reply #1 on: May 09, 2016, 02:40:16 PM »
You don't need Lua for this.

Bind I "ulx slap @;say are you AFK?"
Experiencing God's grace one day at a time.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Referencing ULX command from a separate hook
« Reply #2 on: May 09, 2016, 03:36:42 PM »
Oh... So the @ makes it the target player?
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Referencing ULX command from a separate hook
« Reply #3 on: May 09, 2016, 03:58:12 PM »
That is correct. :)

There are a couple modifiers you should know:

^ yourself
* everyone
@ your target

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Referencing ULX command from a separate hook
« Reply #4 on: May 09, 2016, 04:11:13 PM »
Ah I didn't know about @ thanks.  :)
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.