Scripts / Player health

Author
Message
Gtox
3D Media Maker
10
Years of Service
User Offline
Joined: 5th Jun 2014
Location: South Africa
Posted: 2nd Jan 2015 07:14
Is there a way to get the players health yet?
Duncan Peck
10
Years of Service
User Offline
Joined: 25th Apr 2014
Location:
Posted: 2nd Jan 2015 08:29
SetPlayerHealth(health) - assign a new health value to the player (total health).
AddPlayerHealth(health) - adds additional health to the player
HurtPlayer(e,v) - injure the player, great for custom objects

Not sure there is a way to actually get the current health value but the above commands should do most things in terms of player health... depends what you are trying to write a script to do...
PM
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 2nd Jan 2015 11:37
g_PlayerHealth holds current player health

smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd Jan 2015 13:12 Edited at: 3rd Jan 2015 20:28
Quote: "AddPlayerHealth(health) - adds additional health to the player"


just to clarify that actually needs an entity number not a value

also SetPlayerHealth isn't a good command to use as it doesn't have any noticeable effect in game if you set HP to 0 (or below) so use HurtPlayer(e,v) whenever possible
Quote: "HurtPlayer(e,g_PlayerHealth)"
would be the same as SetPlayerHealth(0) but would also have the desired effect of killing the player for example.



as avram said g_PlayerHealth stores the current HP

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Gtox
3D Media Maker
10
Years of Service
User Offline
Joined: 5th Jun 2014
Location: South Africa
Posted: 3rd Jan 2015 05:52
What I'm trying to do is to stop the player health going over the maximum when you take a medikit etc. In other words, if playerhealth > 500 then playerhealth = 500. I'll try g_PlayerHealth.
Gtox
3D Media Maker
10
Years of Service
User Offline
Joined: 5th Jun 2014
Location: South Africa
Posted: 3rd Jan 2015 06:01
Thanks Avram - g_PlayerHealth works perfectly.
smallg - it seems as though SetPlayerHealth takes a health value, not an entity value, as the following script worked for me.

smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 3rd Jan 2015 16:13
yep it does, i was talking about addplayerhealth

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Old Larry
GameGuru TGC Backer
12
Years of Service
User Offline
Joined: 26th Apr 2012
Location: Bucharest, Romania
Posted: 26th Mar 2015 10:34
Good script. I've used this to a Nurse character


Smile today, tomorrow could be worse

http://bestradiolarry.ro/fpsarea/

"The best forum, game software, operating system or web platform, it's that software which can give you most of the features and speed, not just amazing graphics."

Login to post a reply

Server time is: 2024-12-21 15:02:25
Your offset time is: 2024-12-21 15:02:25