AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   how to set player health (https://forums.alliedmods.net/showthread.php?t=314558)

Naleksuh 02-25-2019 00:05

how to set player health
 
hello, i'm try to find way to set player health without problems. Previous i was using
PHP Code:

SetEntityHealth(clientnumber); 

but this has problems that it say it's not valid entity, even if client i give it is right. Is there better approach to this? it's the only thing i've been able to find in searches

Psyk0tik 02-25-2019 00:27

Re: how to set player health
 
Quote:

Originally Posted by Naleksuh (Post 2640847)
hello, i'm try to find way to set player health without problems. Previous i was using
PHP Code:

SetEntityHealth(clientnumber); 

but this has problems that it say it's not valid entity, even if client i give it is right. Is there better approach to this? it's the only thing i've been able to find in searches

You probably just need to check if the client is a valid index, is in-game, and is alive.

PHP Code:

if (client <= MaxClients && IsClientInGame(client) && IsPlayerAlive(client))
{
    
SetEntityHealth(clientnumber);



Naleksuh 02-25-2019 00:40

Re: how to set player health
 
alright i'll try it but what happens if that returns "false" then player don't have health set

Indarello 02-25-2019 13:06

Re: how to set player health
 
Then
1)client index is invalid
Or
2)Not in game
Or
3)Not alive

And this code dont have return

Dragokas 02-25-2019 16:33

Re: how to set player health
 
Naleksuh, what moment or event do you use to set health in?
Show complete code.

Naleksuh 02-28-2019 01:13

Re: how to set player health
 
Quote:

Originally Posted by Naleksuh (Post 2640851)
alright i'll try it but what happens if that returns "false" then player don't have health set

problem fixed. thank you, crasher.


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

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