Author Topic: A few questions about ULX commands...  (Read 2429 times)

0 Members and 4 Guests are viewing this topic.

Offline feldma

  • Newbie
  • *
  • Posts: 47
  • Karma: 5
  • 5696 hours in Gmod and counting!
    • Mega-Strike Network
A few questions about ULX commands...
« on: February 15, 2016, 02:25:23 AM »
Hi all.

I'm working on stuff and I need to know if a few things are possible:

Firstly, is it possible to restrict a ULX command to once every, let's say, TTT round?

And is it possible to have a command that saves (such as "every round do this", but you can override that with a different command)?

I know this will require a fair amount of coding, but yeah, if anyone could point me in the right direction (if it's even possible).

Chances are I'll need to create an entirely new addon for this, no doubt.

Thanks,
Feldma.
Solving 50% of people's questions by searching it up on google.

Trying to think of a cool idea to code, so I can inspire myself to code. If you want something done, please message me!

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: A few questions about ULX commands...
« Reply #1 on: February 15, 2016, 06:15:54 AM »
Firstly, is it possible to restrict a ULX command to once every, let's say, TTT round?

Yes, but there isn't any premade ULib/ULX way to do it. Just slap an if statement in your code checking if a TTT round has passed since the last time it was called.

And is it possible to have a command that saves (such as "every round do this", but you can override that with a different command)?

Not exactly sure what you're asking for. If you want something to happen every round you can go ahead and put it in a hook (I would assume TTT has some round hooks). Then just have another command to remove that hook when called.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: A few questions about ULX commands...
« Reply #2 on: February 15, 2016, 08:29:31 AM »
Not exactly sure what you're asking for. If you want something to happen every round you can go ahead and put it in a hook (I would assume TTT has some round hooks). Then just have another command to remove that hook when called.

They do indeed. They're listed here: http://ttt.badking.net/guides/hooks
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline feldma

  • Newbie
  • *
  • Posts: 47
  • Karma: 5
  • 5696 hours in Gmod and counting!
    • Mega-Strike Network
Re: A few questions about ULX commands...
« Reply #3 on: February 15, 2016, 12:16:50 PM »
Nevermind the last question, I'm going to need to think of a better way of doing what I want to do.

However, regarding the hooks, if I wished to use TTTPrepareRound(), would I do it like:

Code: [Select]
if TTTPrepareRound() then
-- code
end

Since I'm horrible at coding and hooks, I'm not sure if that would work.
Solving 50% of people's questions by searching it up on google.

Trying to think of a cool idea to code, so I can inspire myself to code. If you want something done, please message me!

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: A few questions about ULX commands...
« Reply #4 on: February 15, 2016, 12:33:01 PM »
Nevermind the last question, I'm going to need to think of a better way of doing what I want to do.

However, regarding the hooks, if I wished to use TTTPrepareRound(), would I do it like:

Code: [Select]
if TTTPrepareRound() then
-- code
end

Since I'm horrible at coding and hooks, I'm not sure if that would work.
No. You add hooks like this.
Code: [Select]
hook.Add(string eventname, string uniquehookname, function callback)So, an example (for TTTBeginRound) would be:
Code: [Select]
hook.Add( "TTTBeginRound", "unique_name_goes_here", function()
    -- code goes here
end

edit: whew it's been a while
bw81@ulysses-forums ~ % whoami
Homepage

Offline feldma

  • Newbie
  • *
  • Posts: 47
  • Karma: 5
  • 5696 hours in Gmod and counting!
    • Mega-Strike Network
Re: A few questions about ULX commands...
« Reply #5 on: February 15, 2016, 01:10:15 PM »
Ahh, yes. I see now how that works.

Thanks.
Solving 50% of people's questions by searching it up on google.

Trying to think of a cool idea to code, so I can inspire myself to code. If you want something done, please message me!