sourcemod icon indicating copy to clipboard operation
sourcemod copied to clipboard

Editing existing timers: Ability to get a timer's time left & data

Open eyal282 opened this issue 3 years ago • 3 comments

In l4d2, I want to pass variables to bots that replace players and vice versa. This is easily done with the events here: https://wiki.alliedmods.net/Left_4_Dead_2_Events#player_bot_replace https://wiki.alliedmods.net/Left_4_Dead_2_Events#bot_player_replace

However, it becomes practically impossible ( it is possible, but requires insane computation which is beyond my skill to point at every single take over until I find one at the end of the timer )

I want to be able to, given a timer's handle, get the timers time left until execution, and data. This is to alter it. If I can just alter the data, I will be perfectly fine. I'm asking for the solution that is easiest for Sourcemod to implement, because I cannot pass anything to a timer to grab the character itself, because it creates and destroys them during takeovers.

Edit: You can make an ugly move that might be a burden on a programmer: Upon creation of a timer, you grab the timestamp of creation, and time it should fire, and the data you wanna pass to it. Upon takeover you recreate the timer. This on top of being a burden can have inaccuracies, because of 0.1 precision, so I still believe you should add the ability to edit a timer's data on the fly. I can yet to find a reason to edit a timer's time left, but data is needed.

eyal282 avatar Apr 18 '22 14:04 eyal282

Allowing modification of live timers feels extremely risky, but adding natives to get information about them seems reasonable. This'll probably require finally figuring out the Timer typeset / methodmap soup so we can have these as properties - hopefully renaming the callback type isn't too breaking a change.

asherkin avatar Apr 25 '22 09:04 asherkin

Allowing modification of live timers feels extremely risky, but adding natives to get information about them seems reasonable. This'll probably require finally figuring out the Timer typeset / methodmap soup so we can have these as properties - hopefully renaming the callback type isn't too breaking a change.

It will basically result in recreating timers, so might as well allow editing their data, but up to you.

I cannot pull request it unfortunately, I don't understand the language Sourcepawn is written in

eyal282 avatar Apr 26 '22 12:04 eyal282