Raised This Month: $51 Target: $400
 12% 

[L4D] Find which tank has passed the control


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-06-2020 , 15:36   [L4D] Find which tank has passed the control
Reply With Quote #1

So my question is related to Tanks passing control on L4D/L4D2.

I didn't found how to detect that the Tank has been passed to another client.

Any events hooked on "tank_spawn" will execute again (reset).

Does anybody have some best practices on how to detect that?

I mean, is possible to hook the "tank_frustrated" and create a global variable that holds the last human tank. But that is like a workaround. When there are 2+ tanks spawned, this logic may fail(?)
__________________
Marttt is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-06-2020 , 16:03   Re: [L4D] Find which tank has passed the control
Reply With Quote #2

By now the only solution seems to hook the "tank_frustrated" event and then set a bool to "true", and reset it to false on "tank_spawn" that runs next, is not 100% but may work on 99% of times
__________________
Marttt is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 07-06-2020 , 18:14   Re: [L4D] Find which tank has passed the control
Reply With Quote #3

Left4DHooks has:

PHP Code:
// Not invoked if tank is bot
forward void L4D_OnReplaceTank(int tankint newtank);

// Is used for displaying the "X gets Tank" window and transferring Tank control
forward Action L4D_OnTryOfferingTankBot(int tank_indexbool &enterStasis); 
__________________
Silvers is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-07-2020 , 05:59   Re: [L4D] Find which tank has passed the control
Reply With Quote #4

Thanks Silvers!

Gonna try to use that, probably I will need to use it.

Btw will be my first time creating a plugin with an optional #include (kinda noob on it yet).
Gonna check some examples.

I found that many tanks plugins would fail on versus when tank gets frustrated, or even when the player left the match or change team while tank, because "tank_spawn" event runs again, probably would be an issue with most of the plugins that use this event to do something.
__________________
Marttt is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-07-2020 , 11:42   Re: [L4D] Find which tank has passed the control
Reply With Quote #5

Well did some tests and doesn't seem to fire when Tank becomes a bot

I know that has this note:
// Not invoked if tank is bot

But actually there is a scenario where the tank = client, and the new tank is the bot.

L4D_OnReplaceTank(int tank, int newtank);

Anyway maybe through "tank_index" parameter I could check it, but don't know how to get it.
__________________
Marttt is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 07-07-2020 , 15:09   Re: [L4D] Find which tank has passed the control
Reply With Quote #6

tank_index is just the client index passed as a variable when L4D_OnTryOfferingTankBot is triggered. Same way any other forward works.

When frustrated or a player takes over a tank, the last tank is kicked and a new one is created for the player to take over, theres a delay between the actions happening. You would have to play around with it, debug print to figure out what's going on.
__________________
Silvers is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:06.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode