Injured after die
#1

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	PlayerInfo[playerid][pOverdose] = 0;
    new string[128];
	if(PlayerInfo[playerid][pAdmin] < 2)
	{
		new time = gettime();
	    switch(time - LastDeath[playerid])
	    {
	        case 0..3:
	        {
	            DeathSpam[playerid]++;
	            if(DeathSpam[playerid] == 3) // The maximum spam of deaths after the cheater will get banned.
	            {
	                new IP[128];
	                GetPlayerIp(playerid, IP, sizeof(IP));
	                format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s has been automatically kicked for death spamming.", GetPlayerNameEx(playerid), playerid);
					ABroadCast(COLOR_YELLOW, string, 2);
	            
	                format(string, sizeof(string), "[Death Spam] %s has been kicked for death spam. (IP: %s)",GetPlayerNameEx(playerid), playerid, IP);
	                Log("logs/fakedeath.log", string);
	            
	               	ShowPlayerDialog(playerid, DIALOG_SHOW_INFO, DIALOG_STYLE_MSGBOX, "{FFFFFF}Kicked from server", "You have been kicked from the server for fake kill.", "Ok", "Cancel");
                    SetTimerEx("SendToKick", 300, 0, "i", playerid);
	            }
	            return 1;
	        }
	        default: DeathSpam[playerid] = 0;
	    }
	    LastDeath[playerid] = time;
	}
	if(IsPlayerConnected(killerid))
	{
		new hour,minute,second, weaponname[32];
		gettime(hour,minute,second);
		FixHour(hour);
		hour = shifthour;
		GetWeaponName(reason, weaponname, sizeof(weaponname));
		format(PlayerInfo[playerid][pKillLog9], 256, "%s", PlayerInfo[playerid][pKillLog8]);
		format(PlayerInfo[playerid][pKillLog8], 256, "%s", PlayerInfo[playerid][pKillLog7]);
		format(PlayerInfo[playerid][pKillLog7], 256, "%s", PlayerInfo[playerid][pKillLog6]);
		format(PlayerInfo[playerid][pKillLog6], 256, "%s", PlayerInfo[playerid][pKillLog5]);
		format(PlayerInfo[playerid][pKillLog5], 256, "%s", PlayerInfo[playerid][pKillLog4]);
		format(PlayerInfo[playerid][pKillLog4], 256, "%s", PlayerInfo[playerid][pKillLog3]);
		format(PlayerInfo[playerid][pKillLog3], 256, "%s", PlayerInfo[playerid][pKillLog2]);
		format(PlayerInfo[playerid][pKillLog2], 256, "%s", PlayerInfo[playerid][pKillLog1]);
		format(PlayerInfo[playerid][pKillLog1], 256, "%s", PlayerInfo[playerid][pKillLog0]);
	 	format(PlayerInfo[playerid][pKillLog0], 256, "(%d:%d:%d) %s killed me with %s", hour,minute,second,GetPlayerNameEx(killerid), weaponname);

	 	format(PlayerInfo[killerid][pKillLog9], 256, "%s", PlayerInfo[killerid][pKillLog8]);
		format(PlayerInfo[killerid][pKillLog8], 256, "%s", PlayerInfo[killerid][pKillLog7]);
		format(PlayerInfo[killerid][pKillLog7], 256, "%s", PlayerInfo[killerid][pKillLog6]);
		format(PlayerInfo[killerid][pKillLog6], 256, "%s", PlayerInfo[killerid][pKillLog5]);
		format(PlayerInfo[killerid][pKillLog5], 256, "%s", PlayerInfo[killerid][pKillLog4]);
		format(PlayerInfo[killerid][pKillLog4], 256, "%s", PlayerInfo[killerid][pKillLog3]);
		format(PlayerInfo[killerid][pKillLog3], 256, "%s", PlayerInfo[killerid][pKillLog2]);
		format(PlayerInfo[killerid][pKillLog2], 256, "%s", PlayerInfo[killerid][pKillLog1]);
		format(PlayerInfo[killerid][pKillLog1], 256, "%s", PlayerInfo[killerid][pKillLog0]);
	 	format(PlayerInfo[killerid][pKillLog0], 256, "(%d:%d:%d) Killed %s with %s", hour,minute,second,GetPlayerNameEx(playerid), weaponname);
	 	if(GetPVarInt(killerid, "IsInArena") == 0) PlayerInfo[killerid][pDMKills]++;
	}
	pTazer[playerid] = 0;
	InsideShamal[playerid] = INVALID_VEHICLE_ID;
	DeletePVar(playerid, "SpeedRadar");
    DeletePVar(playerid, "UsingSprunk");
	if(arr_Wrecking[playerid] != INVALID_VEHICLE_ID)
	{
		//UnwreckVehicle(arr_Wrecking[playerid], 1);
		arr_Wrecking[playerid] = INVALID_VEHICLE_ID;
	}
	DestroyDynamicObject(GetPVarInt(playerid, "neon"));
	DestroyDynamicObject(GetPVarInt(playerid, "neon1"));
	DeletePVar(playerid, "neon0");
	DeletePVar(playerid, "neon1");
    KillTimer(GetPVarInt(playerid, "firstaid5"));
  	DeletePVar(playerid, "usingfirstaid");
	DeletePVar(playerid, "usingbandage");
	if(GetPVarInt(playerid, "MovingStretcher") != -1)
	{
	    KillTimer(GetPVarInt(playerid, "TickEMSMove"));
	    DeletePVar(GetPVarInt(playerid, "MovingStretcher"), "OnStretcher");
	    SetPVarInt(playerid, "MovingStretcher", -1);
	}
	if(GetPVarInt(playerid, "runningRadar") >= 1)
	{
		new vehid = gLastCar[playerid];
		if(CheckingSpeed[vehid] > 0)
	    {
	        KillTimer(CheckingSpeed[vehid]);
	        CheckingSpeed[vehid] = 0;
	    }
		PlayerTextDrawDestroy(playerid, RadarHud);
		PlayerTextDrawDestroy(playerid, SpeedAndModel);
		DeletePVar(playerid, "runningRadar");
		Radars -= 1;
	}
	new caller = Mobile[playerid];
	if(IsPlayerConnected(Mobile[playerid]))
	{
		SendClientMessageEx(caller,  COLOR_GRAD2, "The line went dead.");
		format(string, sizeof(string), "* %s puts away their cellphone.", GetPlayerNameEx(caller));
		ProxDetector(30.0, caller, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		CellTime[caller] = 0;
		KillTimer(VmailTmer[caller]);
		KillTimer(VmailTmer[playerid]);
		Mobile[caller] = INVALID_PLAYER_ID;
	}
	Mobile[playerid] = INVALID_PLAYER_ID;
	CellTime[playerid] = 0;
	KillTimer(VmailTmer[playerid]);
	KillTimer(VmailTmer[caller]);
	RingTone[playerid] = 0;
	
	foreach(Player, i)
	{
		if(EMSAccepted[i] < 999)
		{
 			if(EMSAccepted[i] == playerid)
   			{
     			EMSAccepted[i] = 999;
       			GameTextForPlayer(i, "~w~EMS Caller~n~~r~Has Died", 5000, 1);
	        	EMSCallTime[i] = 0;
	        	DisablePlayerCheckpoint(i);
			}
		}
	}

	if( GetPVarInt(playerid, "SpecOff" ) == 1 )
	{
		SpawnPlayer(playerid);
		return 1;
	}

	if(GetPVarInt(playerid, "Injured") == 1)
	{
     	SendClientMessageEx(playerid, COLOR_WHITE, "You appear to be stuck in limbo, medics are trying to revive you.");
	    KillEMSQueue(playerid);
	    ResetPlayerWeaponsEx(playerid);
		if(GetPVarInt(playerid, "activesling") > 0)
		{
			DeletePVar(playerid, "activesling");
		}
	    //SpawnPlayer(playerid);
	    return 1;
	}
	if(GetPVarInt(playerid, "IsOnFire"))
	{
		TogglePlayerBurning(playerid, false);
		return 1;
	}
	new Float:px,Float:py,Float:pz;
	if(GetPVarInt(playerid, "EventToken") == 0)
	{
	    if(GetPVarInt(playerid, "IsInArena") == -1)
		{
			SetPVarInt(playerid, "Injured", 1);

			new Float:mX, Float:mY, Float:mZ;
			GetPlayerPos(playerid, mX, mY, mZ);

			SetPVarFloat(playerid, "MedicX", mX);
			SetPVarFloat(playerid, "MedicY", mY);
			SetPVarFloat(playerid, "MedicZ", mZ);
			SetPVarInt(playerid, "MedicVW", GetPlayerVirtualWorld(playerid));
			SetPVarInt(playerid, "MedicInt", GetPlayerInterior(playerid));
		}
	}
With that code , after die the player goes straight to hospital. What I want to ask is how to make the player after die , the player is injured first (waiting for EMS). Can someone help me?
Reply
#2

You'll have to disable client damage (set everyone's team to 0 with SetPlayerTeam to force anti-teamkill on everyone) and handle damage server-side using OnPlayerTakeDamage.
Reply
#3

Code that may help

Код:
public KillEMSQueue(playerid)
{
    DeletePVar(playerid, "Injured");
    DeletePVar(playerid, "EMSAttempt");
	SetPVarInt(playerid, "MedicBill", 1);
	DeletePVar(playerid, "MedicCall");

	return 1;
}

public SendEMSQueue(playerid,type)
{
	switch (type)
	{
		case 1:
		{
		    Streamer_UpdateEx(playerid, GetPVarFloat(playerid,"MedicX"), GetPVarFloat(playerid,"MedicY"), GetPVarFloat(playerid,"MedicZ"));
			SetPlayerPos(playerid, GetPVarFloat(playerid,"MedicX"), GetPVarFloat(playerid,"MedicY"), GetPVarFloat(playerid,"MedicZ"));
			SetPlayerVirtualWorld(playerid, GetPVarInt(playerid,"MedicVW"));
	  		SetPlayerInterior(playerid, GetPVarInt(playerid,"MedicInt"));

			SetPVarInt(playerid, "EMSAttempt", -1);

			if(GetPlayerInterior(playerid) > 0) Player_StreamPrep(playerid, GetPVarFloat(playerid,"MedicX"), GetPVarFloat(playerid,"MedicY"), GetPVarFloat(playerid,"MedicZ"), 4000);
			GameTextForPlayer(playerid, "~r~Injured~n~~w~ /service ems", 5000, 3);
			ClearAnimations(playerid);
			ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die", 4.0, 0, 1, 1, 1, 0, 1);
			SetPlayerHealth(playerid, 100);
			SetPlayerArmour(playerid,0);
			if(GetPVarInt(playerid, "usingfirstaid") == 1)
			{
			    firstaidexpire(playerid);
			}
			SetPVarInt(playerid,"MedicCall",1);
		}
		case 2:
		{
		    SetPVarInt(playerid,"EMSAttempt", 2);
			ClearAnimations(playerid);
		 	ApplyAnimation(playerid, "SWAT", "gnstwall_injurd", 4.0, 0, 1, 1, 1, 0, 1);
			SetPlayerHealth(playerid, 100);
			SetPlayerArmour(playerid,0);
		}
	}
	return 1;
}
Код:
ptask EMSUpdate[5000](playerid)
{
   if(GetPVarType(playerid, "Injured"))
    {
       if(GetPVarInt(playerid, "EMSAttempt") != 0)
		{

			new Float:health;
			GetPlayerHealth(playerid,health);
			SetPlayerHealth(playerid, health-1);
			if(GetPVarInt(playerid, "EMSAttempt") == -1)
			{
				if(GetPlayerAnimationIndex(playerid) != 746) ClearAnimations(playerid), ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die", 4.0, 0, 1, 1, 1, 0, 1);
				GameTextForPlayer(playerid, "~r~Injured~n~~w~/service ems", 5000, 3);
			}
			if(GetPVarInt(playerid, "EMSAttempt") == 1)
			{
				if(GetPlayerAnimationIndex(playerid) != 746) ClearAnimations(playerid), ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die", 4.0, 0, 1, 1, 1, 0, 1);
				GameTextForPlayer(playerid, "~r~Injured~n~~w~Waiting for EMS to Arrive...", 5000, 3);
			}
			if(GetPVarInt(playerid, "EMSAttempt") == 2)
			{
    			GameTextForPlayer(playerid, "~g~Rescued~n~~w~Awaiting Treatment...", 5000, 3);
			}
			if(GetPVarInt(playerid, "EMSAttempt") == 3)
			{
    			if(IsPlayerInAnyVehicle(playerid))
    			{
        			new ambmodel = GetPlayerVehicleID(playerid);
        			if(IsAnAmbulance(ambmodel) || IsATierraESCar(ambmodel))
        			{
    					GameTextForPlayer(playerid, "~g~Rescued~n~~w~Waiting for EMS to take to Hospital...", 5000, 3);
					}
					else
					{
	    				SendClientMessageEx(playerid, COLOR_WHITE, "You fell unconscious due to no life support, you were immediately sent to the hospital.");
        				KillEMSQueue(playerid);
						SpawnPlayer(playerid);
						TogglePlayerBurning(playerid, false);
					}
				}
				else
				{
	    			SendClientMessageEx(playerid, COLOR_WHITE, "You fell out of the vehicle, the Paramedics will have to try harder.");
				}
			}

			GetPlayerHealth(playerid, health);
			if(health <= 5)
			{
    			SendClientMessageEx(playerid, COLOR_WHITE, "You fell unconscious, you were immediately sent to the hospital.");
    			KillEMSQueue(playerid);
				SpawnPlayer(playerid);
				TogglePlayerBurning(playerid, false);
			}
        }
    }
}
Reply
#4

bump
Reply
#5

bump
Reply
#6

no one can help me?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)