SA-MP Forums

Go Back   SA-MP Forums > SA-MP Server > Server Support

Reply
 
Thread Tools Display Modes
Old 04/01/2020, 05:41 PM   #1
Mahzen
Little Clucker
 
Join Date: Dec 2019
Posts: 43
Reputation: 0
Default How To SetHealth ?

How can I set my health or armor to 150
SetPlayerHealth(playerid, 150); And SetPlayerArmour(playerid, 150); I tried to do it but it doesn't.
Mahzen is offline   Reply With Quote
Old 05/01/2020, 04:42 PM   #2
iHunterJ
Little Clucker
 
Join Date: Feb 2019
Posts: 10
Reputation: 23
Default Re: How To SetHealth ?

Use the SA-MP wiki for basic functions.

https://wiki.sa-mp.com/wiki/Function:SetPlayerHealth
https://wiki.sa-mp.com/wiki/SetPlayerArmour
iHunterJ is offline   Reply With Quote
Old 05/01/2020, 04:45 PM   #3
PPC23
Little Clucker
 
Join Date: Feb 2013
Posts: 28
Reputation: 9
Default Re: How To SetHealth ?

The "amount" is a float.
pawn Code:
SetPlayerHealth(playerid, 150.0);
SetPlayerArmour(playerid, 150.0);
PPC23 is offline   Reply With Quote
Old 25/01/2020, 04:30 PM   #4
Sasinosoft
Little Clucker
 
Sasinosoft's Avatar
 
Join Date: Jan 2020
Location: Tampa, FL
Posts: 27
Reputation: 1
Default Re: How To SetHealth ?

Quote:
Originally Posted by Mahzen View Post
How can I set my health or armor to 150
SetPlayerHealth(playerid, 150); And SetPlayerArmour(playerid, 150); I tried to do it but it doesn't.
If you are expecting the health bars to increase over 100%, I'm sorry but it can't be done in SA-MP. You should try to draw custom progress bars over them.

Quote:
Originally Posted by PPC23 View Post
The "amount" is a float.
pawn Code:
SetPlayerHealth(playerid, 150.0);
SetPlayerArmour(playerid, 150.0);
150 and 150.0 are both treated as floats if you put them in a float parameter or var.
Sasinosoft is offline   Reply With Quote
Old 25/01/2020, 04:53 PM   #5
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 440
Reputation: 20
Default Re: How To SetHealth ?

Quote:
Originally Posted by Sasinosoft View Post
If you are expecting the health bars to increase over 100%, I'm sorry but it can't be done in SA-MP. You should try to draw custom progress bars over them.



150 and 150.0 are both treated as floats if you put them in a float parameter or var.
I'm fairly sure you can have values >100. However, it just won't show it on the HUD.
__________________
Developer @ Trucknation
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
An upcoming mix of trucking & light roleplay
Proxus is offline   Reply With Quote
Old 25/01/2020, 06:24 PM   #6
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,229
Reputation: 205
Default Re: How To SetHealth ?

Quote:
Originally Posted by Proxus View Post
I'm fairly sure you can have values >100. However, it just won't show it on the HUD.
https://wiki.sa-mp.com/wiki/Function:SetPlayerHealth
Quote:
The value to set the player's health to. Max health that can be displayed in the HUD is 100, though higher values are valid.
Quote:
If a player's health is below 10 or above 32768, their health bar will flash.
https://wiki.sa-mp.com/wiki/GetPlayerHealth
Quote:
Even though the health can be set to near infinite values on the server side, the individual clients will only report values up to 255. Anything higher will wrap around; 256 becomes 0, 257 becomes 1, etc.
Quote:
Originally Posted by Sasinosoft View Post
150 and 150.0 are both treated as floats if you put them in a float parameter or var.
It is converted to float but why? Treat parameters the way they are and do not rely on the compiler to do it for you.

pawn Code:
#include <a_samp>

main()
{
    SetPlayerHealth(5, 100.0);
}
pawn Code:
CODE 0  ; 0
;program exit point
    halt 0

    proc    ; main
    ; line 4
    break   ; c
    ; line 5
    break   ; 10
    const.pri 42c80000
    push.pri
    ;$par
    const.pri 5
    push.pri
    ;$par
    push.c 8
    sysreq.c 0  ; SetPlayerHealth
    stack c
    ;$exp
    zero.pri
    retn


STKSIZE 1000
pawn Code:
#include <a_samp>

main()
{
    SetPlayerHealth(5, 100);
}
Code:
CODE 0	; 0
;program exit point
	halt 0

	proc	; main
	; line 4
	break	; c
	; line 5
	break	; 10
	const.pri 64
	push.pri
	;$par
	push.c 4
	sysreq.c 0	; Float:operator=(_:)
	stack 8
	push.pri
	;$par
	const.pri 5
	push.pri
	;$par
	push.c 8
	sysreq.c 1	; SetPlayerHealth
	stack c
	;$exp
	zero.pri
	retn


STKSIZE 1000
__________________
Calisthenics is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help me for /sethealth rashidkhoso37 Scripting Help 10 21/09/2014 07:54 AM
I need help with /sethealth AleckRP Scripting Help 10 26/08/2014 06:26 AM
/sethealth and string Qaiis Scripting Help 3 08/09/2012 01:56 PM
[HElp] /sethealth, /setarmour [Lsgw]LoL Help Archive 1 28/06/2011 12:49 PM
help with /sethealth mrcoolballs Help Archive 2 22/08/2010 04:35 PM


All times are GMT. The time now is 07:33 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.