SA-MP Forums Archive
Player Death - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Player Death (/showthread.php?tid=65918)



Player Death - acade - 17.02.2009

Hey, I am trying to do it so when a player health reaches 5, it freezes them and sets a animation. Which section in the code does this go under?

I got this so far
pawn Код:
/*Start*/
    new Float:health;
    PlayerInfo[playerid][pLocal] = 255;
    if(GetPlayerHealth(playerid, health) < 5)
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Please Wait for an Ambulance");
        TogglePlayerControllable(playerid, 0);
        PlayerFrozen(playerid) = 1;
    }
    /*End*/
All this is under OnPlayerDeath which I guess is wrong.


Re: Player Death - Joe Staff - 17.02.2009

mhm that's wrong. You're supposed to figure if a player's health is under 5 (which IMO is too little) by using OnPlayerUpdate


Re: Player Death - acade - 17.02.2009

Quote:
Originally Posted by SilentHuntR
mhm that's wrong. You're supposed to figure if a player's health is under 5 (which IMO is too little) by using OnPlayerUpdate
Ok, So is the coding correct so far?


Re: Player Death - Joe Staff - 17.02.2009

Yeah but without a toggle variable it will spam that. I suggest using a looping animation like Sweet's injury, that way the player doesn't become invincible. Also make sure to kick the player out of any vehicle he/she may be in.


Re: Player Death - acade - 17.02.2009

May you correct the code for me? I dont fully understand. Thanks


Re: Player Death - acade - 17.02.2009

Quote:
Originally Posted by SilentHuntR
Yeah but without a toggle variable it will spam that. I suggest using a looping animation like Sweet's injury, that way the player doesn't become invincible. Also make sure to kick the player out of any vehicle he/she may be in.
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerConnected(playerid))
    {
    new Float:health;
        if(GetPlayerHealth(playerid, health) < 5)
        {
//          PlayerInfo[playerid][pLocal] = 255;
            SendClientMessage(playerid, COLOR_YELLOW, "Please Wait for an Ambulance");
            TogglePlayerControllable(playerid, 0);
            return 1;
        }
    return 1;
    }
return 1;
}
What do I have to do now to add the varibels and for it to remove the player from the car?


Re: Player Death - acade - 20.02.2009

I have done this
but, when my HP is 5 and 4, it doesnt work.. I want it when your HP is 5, it does the animation, and then keeps hp at 5/4.. It doesnt work
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerConnected(playerid))
    {
    new Float:health;
    new sendername[MAX_PLAYER_NAME];
    new string[256];
        if(GetPlayerHealth(playerid, health) == 5)
        {
//          PlayerInfo[playerid][pLocal] = 255;
            SendClientMessage(playerid, COLOR_YELLOW, "Please wait for a Ambulance to arrive");
            TogglePlayerControllable(playerid, 0);
            ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 0, 0, 0, 0, 0);
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "** %s is in need of a Medic. (use /accept medic to accept the call)", sendername);
            SendJobMessage(11, TEAM_AZTECAS_COLOR, string);
            MedicCall = playerid;
            return 1;
        }
        return 1;
        }
        if(SetPlayerHealth(playerid, 4))
        {
            return 1;
        }
        return 1;
}



Re: Player Death - Jefff - 20.02.2009

Код:
public OnPlayerUpdate(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		new Float:health;
		new sendername[MAX_PLAYER_NAME];
		new string[128];
		GetPlayerHealth(playerid, health);
		if(health == 5.0){
//			PlayerInfo[playerid][pLocal] = 255;
			SendClientMessage(playerid, COLOR_YELLOW, "Please wait for a Ambulance to arrive");
			TogglePlayerControllable(playerid, 0);
			ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 0, 0, 0, 0, 0);
			GetPlayerName(playerid, sendername, sizeof(sendername));
		  	format(string, sizeof(string), "** %s is in need of a Medic. (use /accept medic to accept the call)", sendername);
		  	SendJobMessage(11, TEAM_AZTECAS_COLOR, string);
		  	MedicCall = playerid;
		}
	return 1;
}



Re: Player Death - acade - 20.02.2009

thanks