givehp gethp?
#1

OK so I basically have a server sided health and all that stuff recently I wanted to make a new system that gives players hp... (the actualy hp perk gives them like this pInfo[playerid][pHealth] += 150; )

So my code is here:
Code:
if(team[i] == TEAM_HUMAN)
			{
	            GetHealth(i,hp);
	            if(hp < 80)
				{
	                GiveHealth(i,hp+3.5);
My gethealth stock function
Code:
stock GetHealth(playerid) { return pInfo[playerid][pHealth]; }
My GiveHealth stock function
Code:
//stock GiveHealth(playerid { return pInfo[playerid][pHealth] ++; )
Disabled cuz it fucks the whole gm...
Now how do I correctly write the code? to store the hp and then give it.

I tried this and results:
Code:
pInfo[i][pHealth] += 3.5;
Empty statement lol.
Reply
#2

I really don't know what can this ever work.
Try this maybe it will be okay.

1. Why u use another stocks.. there are already functions to get health or to set health.
2. GetPlayerHealth( playerid, Float:health_amount ), is the fuction to get the health. Example:

PHP Code:
new Float:healthx;
GetPlayerHealthplayeridhealthx );
pInfoplayerid ][ pHealth ] = healthx
3. SetPlayerHealth( playerid, Float:health_amount ), is the function to set the health amount.

YOUR CODE IT WILL WORK IF U USE THIS:
PHP Code:
if( team] == TEAM_HUMAN )
{
    new 
Float:hp;
    
GetPlayerHealthihp );
    if( 
hp 80 )
    {
        
SetPlayerHealthihp 3.5 );
    }

In my opinion your functions are not correct and also why to use another functions
if there exist already fuctions for this and u can use it for sure.
Reply
#3

Quote:
Originally Posted by FaLLenGirL
View Post
I really don't know what can this ever work.
Try this maybe it will be okay.

1. Why u use another stocks.. there are already functions to get health or to set health.
2. GetPlayerHealth( playerid, Float:health_amount ), is the fuction to get the health. Example:

PHP Code:
new Float:healthx;
GetPlayerHealthplayeridhealthx );
pInfoplayerid ][ pHealth ] = healthx
3. SetPlayerHealth( playerid, Float:health_amount ), is the function to set the health amount.

YOUR CODE IT WILL WORK IF U USE THIS:
PHP Code:
if( team] == TEAM_HUMAN )
{
    new 
Float:hp;
     
GetPlayerHealthihp );
    if( 
hp 80 )
    {
        
SetPlayerHealthihp 3.5 );
    }

In my opinion your functions are not correct and also why to use another functions
if there exist already fuctions for this and u can use it for sure.
Hey dude thanks but as I said I have server sided health... setplayerhealth wont WORK.
Reply
#4

"dude" i'm a girl but that's ok, i try to make your functions work. Let me see.

1. So u get the health with this: GetHealth( i, hp );. Did u defined somewhere that hp ?
PHP Code:
new Float:hp;
GetHealthihp ); 
2. I think if u use it like this may it will work:
PHP Code:
GetHealthplayeridhealth ) return pInfoplayerid ][ pHealth ] = health
3. And this i think it will work too:
PHP Code:
GiveHealthplayeridhealth ) return pInfoplayerid ][ pHealth ] += health
Try it and let me know if it works.
Reply
#5

Quote:
Originally Posted by FaLLenGirL
View Post
"dude" i'm a girl but that's ok, i try to make your functions work. Let me see.

1. So u get the health with this: GetHealth( i, hp );. Did u defined somewhere that hp ?
PHP Code:
new Float:hp;
GetHealthihp ); 
2. I think if u use it like this may it will work:
PHP Code:
GetHealthplayeridhealth ) return pInfoplayerid ][ pHealth ] = health
3. And this i think it will work too:
PHP Code:
GiveHealthplayeridhealth ) return pInfoplayerid ][ pHealth ] += health
Try it and let me know if it works.
Code:
C:\Users\xc0de\Desktop\tst\gamemodes\zm1.pwn(2800) : warning 213: tag mismatch
C:\Users\xc0de\Desktop\tst\gamemodes\zm1.pwn(2802) : error 036: empty statement
C:\Users\xc0de\Desktop\tst\gamemodes\zm1.pwn(2803) : warning 213: tag mismatch
Code:
			{
	            GetHealth(i,hp);
	            if(hp < 80)
				{;
                 GiveHealth(i,3.5);
Reply
#6

Show me the errors on lines.. tell me what lines are the errors :]]
I know that's the code but write in front of them the lines numbers, please.
Reply
#7

Quote:
Originally Posted by FaLLenGirL
View Post
Show me the errors on lines.. tell me what lines are the errors :]]
I know that's the code but write in front of them the lines numbers, please.
gethealth and givehealth... thats why i posted it
Reply
#8

stock GiveHealth(playerid { return pInfo[playerid][pHealth] ++; )

should be } not )

Also stock Float:GiveHealth
Reply
#9

PHP Code:
GiveHealthplayeridhealth 
change to:
PHP Code:
GiveHealthplayeridFloat:health 
and same as GetHealth.
Reply
#10

Quote:
Originally Posted by FaLLenGirL
View Post
PHP Code:
GiveHealthplayeridhealth 
change to:
PHP Code:
GiveHealthplayeridFloat:health 
and same as GetHealth.
It wont work heres the full code
Code:
stock DoctorShield()
{
	new Float:X,Float:Y,Float:Z,Float:hp,str[128];
	GetObjectPos(DocShield,X,Y,Z);
	foreach(Player,i)
	{
	    if(IsPlayerInRangeOfPoint(i,4.5,X,Y,Z))
		{
	        if(team[i] == TEAM_HUMAN)
			{
	            GetHealth(i,Float:hp);
	            if(hp < 80);
				{
                 GiveHealth(i,3.5);

	                format(str,sizeof(str),"~n~~n~~n~~n~~g~GETTING HEALED BY DOCTOR SHIELD~w~ (NEW HP: %.2f HP)",hp);
	                GameTextForPlayer(i,str,1000,5);
	            }
	            else
				{
	                GameTextForPlayer(i,"~n~~n~~n~~n~~r~YOU HAVE ENOUGH HP TO SURVIVE",1000,5);
	            }
	        }
	    }
	}
	return 1;
}
Here's the original code with setplayerhealth
Code:
stock DoctorShield()
{
	new Float:X,Float:Y,Float:Z,Float:hp,str[128];
	GetObjectPos(DocShield,X,Y,Z);
	foreach(Player,i)
	{
	    if(IsPlayerInRangeOfPoint(i,4.5,X,Y,Z))
		{
	        if(team[i] == TEAM_HUMAN)
			{
	            GetPlayerHealth(i,hp);
	            if(hp < 80)
				{
	                SetPlayerHealth(i,hp+3.5);
	                format(str,sizeof(str),"~n~~n~~n~~n~~g~GETTING HEALED BY DOCTOR SHIELD~w~ (NEW HP: %.2f HP)",hp);
	                GameTextForPlayer(i,str,1000,5);
	            }
	            else
				{
	                GameTextForPlayer(i,"~n~~n~~n~~n~~r~YOU HAVE ENOUGH HP TO SURVIVE",1000,5);
	            }
	        }
	    }
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)