General > Developers Corner
A few questions about ULX commands...
feldma:
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.
roastchicken:
--- Quote from: feldma on February 15, 2016, 02:25:23 AM ---Firstly, is it possible to restrict a ULX command to once every, let's say, TTT round?
--- End quote ---
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.
--- Quote from: feldma on February 15, 2016, 02:25:23 AM ---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)?
--- End quote ---
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.
Decicus:
--- Quote from: roastchicken on February 15, 2016, 06:15:54 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.
--- End quote ---
They do indeed. They're listed here: http://ttt.badking.net/guides/hooks
feldma:
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: ---if TTTPrepareRound() then
-- code
end
--- End code ---
Since I'm horrible at coding and hooks, I'm not sure if that would work.
Bytewave:
--- Quote from: feldma 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: ---if TTTPrepareRound() then
-- code
end
--- End code ---
Since I'm horrible at coding and hooks, I'm not sure if that would work.
--- End quote ---
No. You add hooks like this.
--- Code: ---hook.Add(string eventname, string uniquehookname, function callback)
--- End code ---
So, an example (for TTTBeginRound) would be:
--- Code: ---hook.Add( "TTTBeginRound", "unique_name_goes_here", function()
-- code goes here
end
--- End code ---
edit: whew it's been a while
Navigation
[0] Message Index
[#] Next page
Go to full version