Raised This Month: $32 Target: $400
 8% 

[L4D2] Tank HP for Versus


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SilentBr
Veteran Member
Join Date: Jan 2009
Old 07-04-2018 , 14:37   [L4D2] Tank HP for Versus
Reply With Quote #1

Hello all,

I'm trying to set Tank's HP on Versus through this plugin because sm_cvar z_tank_health 22000 doesn't work (it comes with 1 HP).

The main problem with this plugin is when a bot becomes Tank (after a player), the HP is set to 22000 again.

Anyone can help me to fix it?

Code:
#include <sourcemod>
#include <sdktools>

#define g_iCvarHealth 22000 

public OnPluginStart()
{
    HookEvent("tank_spawn", tank_spawn);
}

public tank_spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new userid = GetEventInt(event, "userid");
    CreateTimer(0.1, tmrHealth, userid);
}

public Action:tmrHealth(Handle:timer, any:userid)
{
    new client = GetClientOfUserId(userid)
    if( client && IsClientInGame(client))
    {
        SetEntityHealth(client, g_iCvarHealth);
    }
}
SilentBr is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 07-04-2018 , 16:39   Re: [L4D2] Tank HP for Versus
Reply With Quote #2

You probably need to store the tanks hp in a variable in tank_frustated event and then restore the hp. I would assume that player_bot_replace is called when that happens so you could use this event to restore the hp
xerox8521 is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 07-04-2018 , 17:45   Re: [L4D2] Tank HP for Versus
Reply With Quote #3

You cannot set an string to a int!

Where #define g_iCvarHealth 22000

Set int g_iCvarHealth = 22000;

Last edited by mug1wara; 07-04-2018 at 17:46.
mug1wara is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 07-04-2018 , 19:00   Re: [L4D2] Tank HP for Versus
Reply With Quote #4

When you #define something, it doesn't automatically become a string. There's nothing wrong with his #define as long as he doesn't plan to change it somewhere else in the plugin.

#define g_iCvarHealth 22000 // number
#define g_iCvarHealth "22000" // string

And even if it is a string, he can just use StringToInt() if he wants to keep the #define.
__________________
Psyk0tik is offline
SilentBr
Veteran Member
Join Date: Jan 2009
Old 07-04-2018 , 21:41   Re: [L4D2] Tank HP for Versus
Reply With Quote #5

Quote:
Originally Posted by xerox8521 View Post
You probably need to store the tanks hp in a variable in tank_frustated event and then restore the hp. I would assume that player_bot_replace is called when that happens so you could use this event to restore the hp
I agree, have no idea how to do it haha
SilentBr is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 07-04-2018 , 21:45   Re: [L4D2] Tank HP for Versus
Reply With Quote #6

// Global variable
int g_iTankHealth;

// Inside "tank_frustrated" event
g_iTankHealth = GetClientHealth(client);

// Inside "player_bot_replace" or "bot_player_replace" (whatever)
SetEntityHealth(client, g_iTankHealth);
__________________
Psyk0tik is offline
midnight9
Senior Member
Join Date: Nov 2012
Old 07-05-2018 , 14:08   Re: [L4D2] Tank HP for Versus
Reply With Quote #7

z_tank_health does work. To have tank's health set to 22000 set it like this sm_cvar z_tank_health 14666.7

Last edited by midnight9; 07-05-2018 at 14:08.
midnight9 is offline
SilentBr
Veteran Member
Join Date: Jan 2009
Old 07-06-2018 , 16:30   Re: [L4D2] Tank HP for Versus
Reply With Quote #8

Quote:
Originally Posted by Crasher_3637 View Post
// Global variable
int g_iTankHealth;

// Inside "tank_frustrated" event
g_iTankHealth = GetClientHealth(client);

// Inside "player_bot_replace" or "bot_player_replace" (whatever)
SetEntityHealth(client, g_iTankHealth);
Mate, I'm stupid about scripting haha

Quote:
Originally Posted by midnight9 View Post
z_tank_health does work. To have tank's health set to 22000 set it like this sm_cvar z_tank_health 14666.7
I've tried, but the HP is set to 0, if I type "sm_cvar z_tank_health" shows 0 on console. I have no idea why.

Last edited by SilentBr; 07-06-2018 at 16:38.
SilentBr is offline
midnight9
Senior Member
Join Date: Nov 2012
Old 07-06-2018 , 18:33   Re: [L4D2] Tank HP for Versus
Reply With Quote #9

You've tried sm_cvar z_tank_health 14666.7 specifically?
midnight9 is offline
SilentBr
Veteran Member
Join Date: Jan 2009
Old 07-06-2018 , 19:36   Re: [L4D2] Tank HP for Versus
Reply With Quote #10

Quote:
Originally Posted by midnight9 View Post
You've tried sm_cvar z_tank_health 14666.7 specifically?
Yes. It doesn't matter the value I put there, always at 0. Maybe is a plug-in or something causing this.
SilentBr is offline
Reply


Thread Tools
Display Modes

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 17:22.


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