Health -
Mattakil - 16.12.2013
How do I bypass the player from respawning on player death? Or, how to bypass "OnPlayerDeath"
I tried
pawn Код:
new Float:health;
GetPlayerHealth(pid, health);
if(health <= 20)
but it still killed me. Any ideas?
Re: Health -
Dokins - 16.12.2013
If you put it under OnPlayerDeath then you are already dead aha...
You could do it under OnPlayerTakeDamage.
Re: Health -
Mattakil - 16.12.2013
I did it under OnPlayerUpdate.
Re: Health -
Mattakil - 17.12.2013
Anyone know? :3
Re: Health -
CutX - 17.12.2013
by bypassing onplayerdeath you mean stop the player from dying correct?
if so, just set his health to "infinite"
Код:
#define INFINITY (Float:0x7F800000)
SetPlayerHealth(pid, INFINITY);
ps: the "F" in that number is supposed to be a F, cuz it's HEX. just sayin'
Re: Health -
Mattakil - 17.12.2013
Bump :3
Re: Health -
jakejohnsonusa - 17.12.2013
At the top of your script, right after all the #include 's add:
pawn Код:
#define INFINITY (Float:0x7F800000)
Then under
OnPlayerTakeDamage add:
pawn Код:
//Code will go here...
SetPlayerHealth(pid, INFINITY);
//return 1;
Now, if OnPlayerTakeDamage isn't in your GM:
1. Locate the OnPlayerDeath callback.
2. Right above it add:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
//Code will go here soon enough...
return 1
}
3. Then add an empty line between: the line with a "}" (from the code above) and the OnPlayerDeath callback. Note that this isn't needed, but is good for neat code.
4. Add the code I gave you for the never-die system.
Re: Health -
Mattakil - 17.12.2013
I don't want to set the health to unlimited, lol.
Re: Health -
Mattakil - 17.12.2013
Quote:
Originally Posted by CutX
by bypassing onplayerdeath you mean stop the player from dying correct?
if so, just set his health to "infinite"
Код:
#define INFINITY (Float:0x7F800000)
SetPlayerHealth(pid, INFINITY);
ps: the "F" in that number is supposed to be a F, cuz it's HEX. just sayin'
|
That wouldn't work, cause I tried it with setting the health to 100, if its below 20?
Re: Health - Patrick - 17.12.2013
Quote:
Originally Posted by Mattakil
That wouldn't work, cause I tried it with setting the health to 100, if its below 20?
|
Try the code below, I thought for about 5 minutes how to do this and some stuff came in my head, but I am not sure if this will work, but at least give it a try.
pawn Код:
#define function:%0(%1) \
forward%0(%1); public%0(%1)
new
bool:ByPassOPD[ MAX_PLAYERS char ] = false, ByPassOPDTimer[MAX_PLAYERS char];
public OnPlayerDeath( playerid, killerid, reason )
{
new
Float:_PlayerHealth;
GetPlayerHealth( playerid, _PlayerHealth );
if( killerid == INVALID_PLAYER_ID) return false;
if(20 >= _PlayerHealth )
ByPassOPD{ playerid } = true, ByPassOPDTimer{ playerid } = SetTimerEx( "ByPassOnPlayerDeath", 1000, false, "i", playerid );
return true;
}
function: ByPassOnPlayerDeath(playerid)
{
if( true == ByPassOPD{ playerid } )
{
//sleeping animation for 5 minutes.
ApplyAnimation( playerid, "INT_HOUSE", "BED_In_L", 4.1, 0, 0, 0, 5*60, 1 ), SetPlayerHealth( playerid, 9999 );
}
else if( false == ByPassOPD{ playerid } )
{
KillTimer( ByPassOPDTimer{ playerid } ), ClearAnimations( playerid ), SetPlayerHealth( playerid, 20+10 );
}
}
Compilation with -d3
Код:
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
Header size: 344 bytes
Code size: 1136 bytes
Data size: 1164 bytes
Stack/heap size: 16384 bytes; estimated max. usage=17 cells (68 bytes)
Total requirements: 19028 bytes
[Finished in 0.1s]