AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need to find CURRENT hp (https://forums.alliedmods.net/showthread.php?t=45813)

hippo.exe 10-12-2006 04:28

Need to find CURRENT hp
 
Title pretty much sums it up..

I need to know what would give me the info of someones CURRENT HP. So i could plug that into an equasion.

Silencer123 10-12-2006 07:08

Re: Need to find CURRENT hp
 
new health=get_user_health(id)
Requires to include fun.inc:
#include <fun>
Next Time try searching in the amxmodx.org FuncWiki first:
http://www.amxmodx.org/funcwiki.php

Imanoobie 10-12-2006 09:53

Re: Need to find CURRENT hp
 
*cough*

Isnt that wrong?

shouldnt it be

Code:
new g_hp g_hp = get_user_health(id)


You just need to include the file "Amxmodx"


Btw, the HP data is saved to the variable g_hp.

And silencer is right, look in the FuncWiki before asking. (I hate it, but whatever :) )

Rolnaaba 10-12-2006 09:57

Re: Need to find CURRENT hp
 
Quote:

Originally Posted by Imanoobie (Post 390254)
*cough*

Isnt that wrong?

shouldnt it be

Code:
new g_hp g_hp = get_user_health(id)




You just need to include the file "Amxmodx"


Btw, the HP data is saved to the variable g_hp.

And silencer is right, look in the FuncWiki before asking. (I hate it, but whatever :) )

what are you talking about all you did was change the name of the variable, that changes nothing, and get_user_health(id) I believe is a comand reserved for the amxmodx module here is the code from the include file:
Code:

/* Returns player health. */
native get_user_health(index);


Imanoobie 10-12-2006 10:01

Re: Need to find CURRENT hp
 
No, its just that you cant do:

Code:
new g_hp = get_user_health(id)

You must do:
Code:
new g_hp g_hp = get_user_health(id)

Rolnaaba 10-12-2006 10:05

Re: Need to find CURRENT hp
 
incorrect, infact it is sometimes better to initialize a variable at a specific value otherwise the variable when created can be any number of things
Code:
new health = get_user_health
is correct as is your way but the above is better

P34nut 10-12-2006 10:07

Re: Need to find CURRENT hp
 
u can
Code:
new iHp = get_user_health(id)

and there is no need to include fun

Imanoobie 10-12-2006 10:09

Re: Need to find CURRENT hp
 
Hmm...i saw in the old AmxX doc that you have to do it the way i did.

Oh well.

schnitzelmaker 10-12-2006 11:21

Re: Need to find CURRENT hp
 
both can be used:
Code:
new g_hp g_hp = get_user_health(id)
Code:
new g_hp = get_user_health(id)

But"new g_hp = get_user_health(id)" is better.
Here the explain why.
The "new" command reserve memory to store the value.If you use "new g_hp" the variable "g_hp" can hold a number that was stored in the memory from another (old) variable.This is a high risk when you use something like this
Code:
new g_hp //sometimes "g_hp" are not initalize with "0" if(!g_hp) //if g_hp was not initalize with "0" ,the if can be false and not work right   {//g_hp was used befor it was initalize.   g_hp = get_user_health(id) //initalize g_hp with the value of get_user_health(id)   //...   }

Always initalize a variable with a value before you use them.

MaximusBrood 10-12-2006 17:09

Re: Need to find CURRENT hp
 
Incorrect. Pawn automaticly zeroes variables, unlike the C family.


All times are GMT -4. The time now is 04:46.

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