SA-MP Forums Archive
public onPlayerDeath error, Not going injured... (+rep) - 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)
+--- Thread: public onPlayerDeath error, Not going injured... (+rep) (/showthread.php?tid=500236)



public onPlayerDeath error, Not going injured... (+rep) - FutureGenerationGaming - 12.03.2014

So in game i kill myself and i just go straight to the medic bill i skip the whole /service ems part...

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	PlayerInfo[playerid][pOverdose] = 0;

    new string[128];
    // Anti-Fake Kill by Neonman
	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;
	}



Re: public onPlayerDeath error, Not going injured... (+rep) - Drago987 - 12.03.2014

Do you really think that when you make 3 threads with the same question they will answer you ??


Re: public onPlayerDeath error, Not going injured... (+rep) - CuervO - 12.03.2014

You can not prevent death (so philosophical...), and in fact if you happen to read the callback name OnPlayerDeath it gets called when the player dies, so no, there's no error at OnPlayerDeath, it works as it's meant to.

If you want to do an injury system, you've got to spawn the player AFTER he died back on the position of where he died and apply all the needed commands and functions there, alternatively you could work it out with an scripted damage system and all but that's sort of harder to make.


Re: public onPlayerDeath error, Not going injured... (+rep) - FutureGenerationGaming - 12.03.2014

Quote:
Originally Posted by CuervO
Посмотреть сообщение
You can not prevent death (so philosophical...), and in fact if you happen to read the callback name OnPlayerDeath it gets called when the player dies, so no, there's no error at OnPlayerDeath, it works as it's meant to.

If you want to do an injury system, you've got to spawn the player AFTER he died back on the position of where he died and apply all the needed commands and functions there, alternatively you could work it out with an scripted damage system and all but that's sort of harder to make.
I didnt say its not a death system when i die i just go straight to hospital and heres the code...

Код:
if(GetPVarInt(playerid, "Finding")>=1)
	{
	    DeletePVar(playerid, "Finding");
	    DisablePlayerCheckpoint(playerid);
	    GameTextForPlayer(playerid, "~w~Reached destination", 5000, 1);
	}
	if(TaxiCallTime[playerid] > 0 && TaxiAccepted[playerid] < 999)
	{
		TaxiAccepted[playerid] = 999;
		GameTextForPlayer(playerid, "~w~Reached destination", 5000, 1);
		TaxiCallTime[playerid] = 0;
		DisablePlayerCheckpoint(playerid);
	}
	else if(EMSCallTime[playerid] > 0 && EMSAccepted[playerid] < 999)
	{
	    if(GetPVarInt(EMSAccepted[playerid], "Injured") == 1)
	    {
	    	SendEMSQueue(EMSAccepted[playerid],2);
	    	EMSAccepted[playerid] = 999;
	    	GameTextForPlayer(playerid, "~g~Reached destination", 5000, 1);
			if(PlayerInfo[playerid][pMember]==4||PlayerInfo[playerid][pLeader]==4 || (PlayerInfo[playerid][pMember] == 12 && PlayerInfo[playerid][pDivision] == 3) || (PlayerInfo[playerid][pMember] == 11 && (PlayerInfo[playerid][pDivision] == 7 || PlayerInfo[playerid][pDivision] == 3))) {
			SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* Don't forget to grab your ALS bag in the back of the Ambulance (/getals)");
			}
	    	EMSCallTime[playerid] = 0;
	    	DisablePlayerCheckpoint(playerid);
		}
		else
		{
            EMSAccepted[playerid] = 999;
		    GameTextForPlayer(playerid, "~r~Patient has died", 5000, 1);
		    EMSCallTime[playerid] = 0;
	    	DisablePlayerCheckpoint(playerid);
		}
	}
	else if(BusCallTime[playerid] > 0 && BusAccepted[playerid] < 999)
	{
		BusAccepted[playerid] = 999;
		GameTextForPlayer(playerid, "~w~Reached destination", 5000, 1);
		BusCallTime[playerid] = 0;
		DisablePlayerCheckpoint(playerid);
	}
	else if(MedicCallTime[playerid] > 0 && MedicAccepted[playerid] < 999)
	{
		MedicAccepted[playerid] = 999;
		GameTextForPlayer(playerid, "~w~Reached patient", 5000, 1);
		MedicCallTime[playerid] = 0;
		DisablePlayerCheckpoint(playerid);
	}



Re: public onPlayerDeath error, Not going injured... (+rep) - FutureGenerationGaming - 12.03.2014

And here is the onPlayerSpawn EMS function:

Код:
public MoveEMS(playerid)
{
    new Float:mX, Float:mY, Float:mZ;
    GetPlayerPos(playerid, mX, mY, mZ);

    SetPVarFloat(GetPVarInt(playerid, "MovingStretcher"), "MedicX", mX);
	SetPVarFloat(GetPVarInt(playerid, "MovingStretcher"), "MedicY", mY);
	SetPVarFloat(GetPVarInt(playerid, "MovingStretcher"), "MedicZ", mZ);
	SetPVarInt(GetPVarInt(playerid, "MovingStretcher"), "MedicVW", GetPlayerVirtualWorld(playerid));
	SetPVarInt(GetPVarInt(playerid, "MovingStretcher"), "MedicInt", GetPlayerInterior(playerid));

	Streamer_UpdateEx(GetPVarInt(playerid, "MovingStretcher"), mX, mY, mZ);
	SetPlayerPos(GetPVarInt(playerid, "MovingStretcher"), mX, mY, mZ);
	SetPlayerInterior(GetPVarInt(playerid, "MovingStretcher"), GetPlayerVirtualWorld(playerid));
	SetPlayerVirtualWorld(GetPVarInt(playerid, "MovingStretcher"), GetPlayerVirtualWorld(playerid));

	ClearAnimations(GetPVarInt(playerid, "MovingStretcher"));
	ApplyAnimation(GetPVarInt(playerid, "MovingStretcher"), "SWAT", "gnstwall_injurd", 4.0, 0, 1, 1, 1, 0, 1);

	DeletePVar(GetPVarInt(playerid, "MovingStretcher"), "OnStretcher");
	SetPVarInt(playerid, "MovingStretcher", -1);
}