[HELP] - OnPlayerDeath [+rep]
#1

Hi,

This script is complicated a bit [well for me], i had 2 bugs.
1. When you suicided, you would just freeze and not spawn to the hospital, however i fixed it.
2. When someone shoots you, you freeze and again, not spawning at the hospital.

Here is the code:

Код:
public OnPlayerDeath(playerid,killerid,reason)
{
	if(License[playerid][StepB] >=1||License[playerid][StepD] >=1||License[playerid][StepF] >=1)
	{
	    License[playerid][StepB]=0;
        License[playerid][StepF]=0;
        License[playerid][StepD]=0;
        DisablePlayerRaceCheckpoint(playerid);
        DestroyVehicle(License[playerid][Vehicle]);
	    SendClientMessage(playerid,LRED,"You have failed the test");
	}
	if(PB[playerid]==0)
    {
		Died[playerid]=1;
		SetPlayerPos(playerid, 2035.2500,-1411.8441,16.9922,142.2312);
        SendDeathMessage(killerid,playerid,reason);
	}
    if(killerid !=INVALID_PLAYER_ID)
	{
  		if(PB[playerid]==1)
 		{
			new str[128];
        	format(str,sizeof(str),"'%s' has been terminated by '%s'",PlayerName(playerid),PlayerName(killerid));
        	GivePlayerMoneyEx(killerid,200);
        	SendNearbyMessage(playerid,250,str,RED);
        	GameTextForPlayer(killerid,"~g~+$200",3000,1);
		}
		if(PB[playerid]==0)
 		{
        	if(PlayerOrgType(killerid)==LAW&&GetPlayerWantedLevel(playerid) >=1)
			{
 				new string[128];
				Died[playerid]=0;
				Jailed[playerid]=2;
				new rand=100 +random(1000);
				GivePlayerMoneyEx(killerid,rand);
 				format(string,sizeof(string),"~g~+$%i",rand);
 				GameTextForPlayer(killerid,string,3000,1);
 				format(string,sizeof(string),"%s has been arrested by Officer %s",PlayerName(playerid),PlayerName(killerid));
  				SendClientMessageToAll(RED,string);
                if(PlayerAwards[killerid][Jailer]==0)
				{
 					GivePlayerMoneyEx(killerid,800);
					PlayerAwards[killerid][Jailer]=1;
 					GamerScore[playerid]=GamerScore[playerid]+50;
  					SendClientMessage(killerid,YELLOW,"Achievement Unlocked: {FFFFFF}Cleaning The Streets!");
					SendClientMessage(killerid,LGREEN,"BONUS: $800 || +50 Gamer Score");
				}
			}
			if(PlayerOrgType(killerid)!=LAW)
			{
			    format(Reason[killerid],25,"Murder");
				SetPlayerWantedLevel(killerid,GetPlayerWantedLevel(killerid)+2);
				for(new a=0;a<MAX_PLAYERS;a++)
				{
        			if(IsPlayerConnectedEx(a))
       				{
   				    	new str[128];
        				if(PlayerOrgType(a)==LAW)
        	 			{
							format(str,sizeof(str),"RADIO - %s has been reported for a murder",PlayerName(killerid));
        	   				SendClientMessage(a,BLUE,str);
        	    		}
						GetPlayerPos(playerid,pX[playerid],pY[playerid],pZ[playerid]);
						if(IsPlayerInRangeOfPoint(a,7,pX[playerid],pY[playerid],pZ[playerid]))
						{
						    if(a!=playerid&&a!=killerid)
						    {
								format(str,sizeof(str),"You saw how badly %s was murdered by %s",PlayerName(playerid),PlayerName(killerid));
        	   					SendClientMessage(a,BLUE,str);
							}
       	 	    		}
					}
				}
			}
		}
	}
	if(killerid==INVALID_PLAYER_ID)
	{
		if(PlayerAwards[playerid][Suicide]==0)
		{
   			GivePlayerMoneyEx(playerid,250);
		    PlayerAwards[playerid][Suicide]=1;
		    SetPlayerPos(playerid, 2035.2500,-1411.8441,16.9922,142.2312);
			GamerScore[playerid]=GamerScore[playerid]+60;
  			SendClientMessage(playerid,YELLOW,"Achievement Unlocked: {FFFFFF}Good Bye Cruel World!");
  			SendClientMessage(playerid,LGREEN,"BONUS: $250 || +60 Gamer Score");
		}
	}
	if(GetPlayerMoneyEx(playerid) > 4)
	{
		GivePlayerMoneyEx(playerid,-GetPlayerMoneyEx(playerid)/2);
	}
    if(IsRobbing[playerid]==1)
	{
		Died[playerid]=1;
        rcash[playerid]=0;
        IsRobbing[playerid]=0;
        SendDeathMessage(killerid,playerid,reason);
        SetPlayerPos(playerid, 2035.2500,-1411.8441,16.9922,142.2312);
        SendClientMessage(playerid,LRED,"Robbery failed,you lost all of your loot");
    }
    Suited[playerid]=0;
    IsBleeding[playerid]=0;
    SetPlayerInterior(playerid,0);
	ResetPlayerWeaponsEx(playerid);
    SetPlayerVirtualWorld(playerid,0);
	SetPlayerSkin(playerid,Skin[playerid]);
    TextDrawHideForPlayer(playerid,Textdraw1);
    TextDrawHideForPlayer(playerid,Textdraw2);
    TextDrawHideForPlayer(playerid,Textdraw3);
    TextDrawHideForPlayer(playerid,Textdraw4);
    TextDrawHideForPlayer(playerid,Textdraw5);
	TextDrawHideForPlayer(playerid,Zones[playerid]);
	SetPlayerFightingStyle(playerid,Fstyle[playerid]);
 	return 1;
}
Any of you got a clue, how to spawn at the Hospital after getting killed by another player?

Thanks.
Reply


Messages In This Thread
[HELP] - OnPlayerDeath [+rep] - by Escobabe - 08.09.2017, 16:33
Re: [HELP] - OnPlayerDeath [+rep] - by Primes007 - 08.09.2017, 16:42
Re: [HELP] - OnPlayerDeath [+rep] - by Escobabe - 08.09.2017, 17:09
Re: [HELP] - OnPlayerDeath [+rep] - by Escobabe - 08.09.2017, 17:32
Re: [HELP] - OnPlayerDeath [+rep] - by SetPlayerNameTag - 09.09.2017, 02:56
Re: [HELP] - OnPlayerDeath [+rep] - by Kane - 09.09.2017, 03:01
Re: [HELP] - OnPlayerDeath [+rep] - by Escobabe - 09.09.2017, 07:36

Forum Jump:


Users browsing this thread: 2 Guest(s)