givehp gethp? -
Crystallize - 12.06.2017
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.
Re: givehp gethp? -
FaLLenGirL - 12.06.2017
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;
GetPlayerHealth( playerid, healthx );
pInfo[ playerid ][ 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[ i ] == TEAM_HUMAN )
{
new Float:hp;
GetPlayerHealth( i, hp );
if( hp < 80 )
{
SetPlayerHealth( i, hp + 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.
Re: givehp gethp? -
Crystallize - 12.06.2017
Quote:
Originally Posted by FaLLenGirL
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;
GetPlayerHealth( playerid, healthx );
pInfo[ playerid ][ 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[ i ] == TEAM_HUMAN )
{
new Float:hp;
GetPlayerHealth( i, hp );
if( hp < 80 )
{
SetPlayerHealth( i, hp + 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.
Re: givehp gethp? -
FaLLenGirL - 12.06.2017
"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;
GetHealth( i, hp );
2. I think if u use it like this may it will work:
PHP Code:
GetHealth( playerid, health ) return pInfo[ playerid ][ pHealth ] = health;
3. And this i think it will work too:
PHP Code:
GiveHealth( playerid, health ) return pInfo[ playerid ][ pHealth ] += health;
Try it and let me know if it works.
Re: givehp gethp? -
Crystallize - 12.06.2017
Quote:
Originally Posted by FaLLenGirL
"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;
GetHealth( i, hp );
2. I think if u use it like this may it will work:
PHP Code:
GetHealth( playerid, health ) return pInfo[ playerid ][ pHealth ] = health;
3. And this i think it will work too:
PHP Code:
GiveHealth( playerid, health ) return pInfo[ playerid ][ 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);
Re: givehp gethp? -
FaLLenGirL - 12.06.2017
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.
Re: givehp gethp? -
Crystallize - 12.06.2017
Quote:
Originally Posted by FaLLenGirL
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
Re: givehp gethp? -
Whatname - 12.06.2017
stock GiveHealth(playerid { return pInfo[playerid][pHealth] ++; )
should be } not )
Also stock Float:GiveHealth
Re: givehp gethp? -
FaLLenGirL - 12.06.2017
PHP Code:
GiveHealth( playerid, health )
change to:
PHP Code:
GiveHealth( playerid, Float:health )
and same as GetHealth.
Re: givehp gethp? -
Crystallize - 12.06.2017
Quote:
Originally Posted by FaLLenGirL
PHP Code:
GiveHealth( playerid, health )
change to:
PHP Code:
GiveHealth( playerid, Float: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;
}