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

[TF2]Need help with adding health to a player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
uniformveloc
Junior Member
Join Date: Jul 2011
Old 07-13-2011 , 11:19   [TF2]Need help with adding health to a player
Reply With Quote #1

I was making a plugin which randomly pick a person from team RED and set the person's health to 500, in the following code, it works fine except that the person's health will decreases down to its normal health. How could i modify the following code so that the health won't decrease back to normal? I have done a lot of research and still unable to find a solution. Please help! Thanks. Btw i am new to sourcepawn.

PHP Code:
 
 
public OnPluginStart( ) 
{
   
HookEvent("teamplay_round_start"GameStart);
}
 
 
public 
Action:GameStart(Handle:Event, const String:Name[], bool:Broadcast)
{
   new 
randomplayer GetRandomPlayer(2);
   for (new 
client 1client <= MaxClientsclient++)
   
SetEntityHealth(randomplayer500
   return 
Plugin_Continue;

 
 
stock GetRandomPlayer(team)
{
    new 
clients[MaxClients+1], clientCount;
    for (new 
1<= MaxClientsi++)
        if (
IsClientInGame(i) && (GetClientTeam(i) == team))
            
clients[clientCount++] = i;
    return (
clientCount == 0) ? -clients[GetRandomInt(0clientCount-1)];


Last edited by uniformveloc; 07-13-2011 at 11:41.
uniformveloc is offline
napalm00
Veteran Member
Join Date: Jun 2011
Location: Italy, sadly
Old 07-13-2011 , 11:25   Re: Need help with adding health to a player
Reply With Quote #2

Here is an example of Health giving without decay.

EDIT: just a suggestion, if you post parts of codes use the [PHP] tags, it's easier to read for us ^-^
__________________

Last edited by napalm00; 07-13-2011 at 11:28.
napalm00 is offline
uniformveloc
Junior Member
Join Date: Jul 2011
Old 07-13-2011 , 11:46   Re: [TF2]Need help with adding health to a player
Reply With Quote #3

sorry, you mean the code or the attachment? Because i tried the attachment, it's an extension which works fine for setting the class health, but i can't set it for a specific client.
uniformveloc is offline
napalm00
Veteran Member
Join Date: Jun 2011
Location: Italy, sadly
Old 07-13-2011 , 11:50   Re: [TF2]Need help with adding health to a player
Reply With Quote #4

Quote:
Originally Posted by uniformveloc View Post
sorry, you mean the code or the attachment? Because i tried the attachment, it's an extension which works fine for setting the class health, but i can't set it for a specific client.
use both
__________________
napalm00 is offline
uniformveloc
Junior Member
Join Date: Jul 2011
Old 07-13-2011 , 12:02   Re: [TF2]Need help with adding health to a player
Reply With Quote #5

The code also doesn't work. Any ideas?
uniformveloc is offline
Pawn 3-pg
Senior Member
Join Date: Jul 2009
Old 07-13-2011 , 13:18   Re: [TF2]Need help with adding health to a player
Reply With Quote #6

The only way I've found to properly set one client's health is to add a +hp bonus to their weapon with TF2Items.
Pawn 3-pg is offline
napalm00
Veteran Member
Join Date: Jun 2011
Location: Italy, sadly
Old 07-13-2011 , 13:25   Re: [TF2]Need help with adding health to a player
Reply With Quote #7

Quote:
Originally Posted by Pawn 3-pg View Post
The only way I've found to properly set one client's health is to add a +hp bonus to their weapon with TF2Items.
exactly.
you may want to check out Vs Saxton Hale's source code, i found this so far :
PHP Code:
    SetEntProp(HaleProp_Data"m_iMaxHealth",HaleHealthMax);
    
SetEntProp(HaleProp_Data"m_iHealth",HaleHealthMax);
    
ChangeEdictState(HaleGetEntSendPropOffs(Hale"m_iMaxHealth"));
    
ChangeEdictState(HaleGetEntSendPropOffs(Hale"m_iHealth")); 
Check it out yourself -> http://forums.alliedmods.net/showthread.php?t=146884
__________________
napalm00 is offline
uniformveloc
Junior Member
Join Date: Jul 2011
Old 07-13-2011 , 14:14   Re: [TF2]Need help with adding health to a player
Reply With Quote #8

Thanks for the help, many people suggested to use tf2items, but i don't have a clue how to use it, e.g give a weapon to a player with a attribute of +hp bonus, can anyone help me please. Thanks a lot.
uniformveloc is offline
Tylerst
Veteran Member
Join Date: Oct 2010
Old 07-13-2011 , 16:03   Re: [TF2]Need help with adding health to a player
Reply With Quote #9

The code I posted wasn't meant to work, It was a response to the question of
Quote:
Originally Posted by Max_Damage View Post
Quote:
Originally Posted by bl4nk View Post
Why not try changing m_iMaxHealth on PostThink using SDKHooks?
Not quite at that level of SourceMod knowledge, can you elaborate?
I even said at the begining of the post that it wouldn't work.
Quote:
Originally Posted by Tylerst View Post
I'm guessing he meant something like this, but that would only cause the hp to fluxuate between 125 and 150 since the game resets it per frame.
The attached plugin/extension is the proper way for setting class health.



Anyhow...as for the tf2items extension, it's quite easy, you just need to install it, it comes with a tf2items.weapons.txt where you can add attributes to it, such as increased health.

The attached file would give admins with the z flag an extra 50 health, and everyone else 25
(Note, you can also use steamids instead of/in addition to the wildcard to do things for specific players)
Attached Files
File Type: txt tf2items.weapons.txt (1.3 KB, 172 views)

Last edited by Tylerst; 07-14-2011 at 00:16.
Tylerst is offline
uniformveloc
Junior Member
Join Date: Jul 2011
Old 07-14-2011 , 04:31   Re: [TF2]Need help with adding health to a player
Reply With Quote #10

Thanks for the help, Tylerst, but how do i give that item to the random player selected from red team in my code?
uniformveloc 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 22:51.


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