RP death system bug
#1

Hello guys.I am trying ti make an RP death system and I got it to work but it's not perfect.The first time I die it asks me to press spawn so I fixed that but spawning the player OnPlayerRequestClass but it still doesn't look cool and a drink shows up at the location where I died.You can watch this video to see what happens

https://www.youtube.com/watch?v=wOF7tf3mr5Q

I hope you can tell me how to fix it.Thank you
Reply
#2

In OnPlayerUpdate

PHP код:
new Float:life;
            
GetPlayerHealth(i,life);
            if(
life <= 10)
            {
                
//Your Code
            

Reply
#3

To skip spawn selection, add
pawn Код:
SpawnPlayer(playerid);
under the OnPlayerRequestClass.
And to remove bottle, etc, you can preload the anim libraries under OnPlayerSpawn.
pawn Код:
PreloadAnimLib(playerid,"BOMBER");
        PreloadAnimLib(playerid,"RAPPING");
        PreloadAnimLib(playerid,"SHOP");
        PreloadAnimLib(playerid,"BEACH");
        PreloadAnimLib(playerid,"SMOKING");
        PreloadAnimLib(playerid,"FOOD");
        PreloadAnimLib(playerid,"ON_LOOKERS");
        PreloadAnimLib(playerid,"DEALER");
        PreloadAnimLib(playerid,"CRACK");
        PreloadAnimLib(playerid,"CARRY");
        PreloadAnimLib(playerid,"COP_AMBIENT");
        PreloadAnimLib(playerid,"PARK");
        PreloadAnimLib(playerid,"INT_HOUSE");
        PreloadAnimLib(playerid,"FOOD");
PreloadAnimLib(playerid,"PED");
And this func
pawn Код:
PreloadAnimLib(playerid, animlib[])
{
    ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
}
Reply
#4

I am already preloading the animations here is my code

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    GetPlayerPos(playerid, PlayerVar[playerid][LastPos][0], PlayerVar[playerid][LastPos][1], PlayerVar[playerid][LastPos][2]);
    FirstSpawn[playerid] = 0;
    MyDReason[playerid] = reason;
    MyKiller[playerid] = killerid;
	return 1;
}
Код:
public OnPlayerSpawn(playerid)
{
    if(!AnimLibPreloaded[playerid])
	{
			PreloadAnimLib(playerid,"BOMBER");
			PreloadAnimLib(playerid,"RAPPING");
			PreloadAnimLib(playerid,"SHOP");
			PreloadAnimLib(playerid,"BEACH");
			PreloadAnimLib(playerid,"SMOKING");
			PreloadAnimLib(playerid,"FOOD");
			PreloadAnimLib(playerid,"ON_LOOKERS");
			PreloadAnimLib(playerid,"DEALER");
			PreloadAnimLib(playerid,"CRACK");
			PreloadAnimLib(playerid,"CARRY");
			PreloadAnimLib(playerid,"COP_AMBIENT");
			PreloadAnimLib(playerid,"PARK");
			PreloadAnimLib(playerid,"INT_HOUSE");
			PreloadAnimLib(playerid,"FOOD");
			PreloadAnimLib(playerid,"PED");
			AnimLibPreloaded[playerid] = 1;
	}
	TextDrawShowForPlayer(playerid, FuseGaming);
    SetPlayerScore(playerid, PlayerVar[playerid][Level]);
    SetPlayerToTeamColor(playerid);
	SetPlayerSkin(playerid, PlayerVar[playerid][Skin]);
	TextDrawShowForPlayer(playerid, Time), TextDrawShowForPlayer(playerid, Date);
	 if(FirstSpawn[playerid] == 1)
	{
	    WorldTime(playerid);
	}
	SetPlayerSpawn(playerid);
	return 1;
}
Код:
forward SetPlayerSpawn(playerid);
public SetPlayerSpawn(playerid)
{
 if(SpawnOnSight[playerid] == 1 && FirstSpawn[playerid] == 0)
	{
	    GameTextForPlayer(playerid, "~r~Injured", 5000, 3);
		ClearAnimations(playerid);
		TogglePlayerControllable(playerid,0);
		SetPlayerHealth(playerid, 100);
		SetPlayerArmour(playerid,0);
		SetPlayerPos(playerid, PlayerVar[playerid][LastPos][0], PlayerVar[playerid][LastPos][1], PlayerVar[playerid][LastPos][2]);
		ApplyAnimation(playerid,"CRACK","crckdeth3", 4.0, 0, 0, 0, 1, 0);
		SpawnOnSight[playerid] = 0;
		SpawnInHospital[playerid] = 1;
		D_Timer[playerid] = SetTimerEx("DeathTimer",60000,true,"u",playerid);
	}
	else if(SpawnInHospital[playerid] == 1 && SpawnOnSight[playerid] == 0)
	{
	    SendDeathMessage(MyKiller[playerid], playerid, MyDReason[playerid]);
	    TogglePlayerControllable(playerid,1);
	    SetCameraBehindPlayer(playerid);
    	SetPlayerVirtualWorld(playerid, 0);
    	SetPlayerInterior(playerid, 0);
    	SetPlayerHealth(playerid, 55);
    	SetPlayerArmour(playerid, 0);
		SetPlayerPos(playerid, 1177.3965, -1323.7709, 14.0686);
		SendClientMessageEx(playerid, COL_GREY, "NOTICE: You have been injured and immediately sent to the hospital for treatment");
		SendClientMessageEx(playerid, COL_GREY, "(( OOC NOTICE: You have lost 30 minutes of your memory, to prevent Revenge Killing ))");
		SpawnOnSight[playerid] = 1;
		SpawnInHospital[playerid] = 0;
		KillTimer(D_Timer[playerid]);
  		ResetPlayerWeaponsEx(playerid);
	}
	return 1;
}
This is weird because my script looks clean and simple.Oh btw for the ones who didn't watch the video,The bottle is not in my hand it's just on the ground and only the player who died can see it.
Reply
#5

Quote:
Originally Posted by mirou123
Посмотреть сообщение
I am already preloading the animations here is my code

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    GetPlayerPos(playerid, PlayerVar[playerid][LastPos][0], PlayerVar[playerid][LastPos][1], PlayerVar[playerid][LastPos][2]);
    FirstSpawn[playerid] = 0;
    MyDReason[playerid] = reason;
    MyKiller[playerid] = killerid;
	return 1;
}
Код:
public OnPlayerSpawn(playerid)
{
    if(!AnimLibPreloaded[playerid])
	{
			PreloadAnimLib(playerid,"BOMBER");
			PreloadAnimLib(playerid,"RAPPING");
			PreloadAnimLib(playerid,"SHOP");
			PreloadAnimLib(playerid,"BEACH");
			PreloadAnimLib(playerid,"SMOKING");
			PreloadAnimLib(playerid,"FOOD");
			PreloadAnimLib(playerid,"ON_LOOKERS");
			PreloadAnimLib(playerid,"DEALER");
			PreloadAnimLib(playerid,"CRACK");
			PreloadAnimLib(playerid,"CARRY");
			PreloadAnimLib(playerid,"COP_AMBIENT");
			PreloadAnimLib(playerid,"PARK");
			PreloadAnimLib(playerid,"INT_HOUSE");
			PreloadAnimLib(playerid,"FOOD");
			PreloadAnimLib(playerid,"PED");
			AnimLibPreloaded[playerid] = 1;
	}
	TextDrawShowForPlayer(playerid, FuseGaming);
    SetPlayerScore(playerid, PlayerVar[playerid][Level]);
    SetPlayerToTeamColor(playerid);
	SetPlayerSkin(playerid, PlayerVar[playerid][Skin]);
	TextDrawShowForPlayer(playerid, Time), TextDrawShowForPlayer(playerid, Date);
	 if(FirstSpawn[playerid] == 1)
	{
	    WorldTime(playerid);
	}
	SetPlayerSpawn(playerid);
	return 1;
}
Код:
forward SetPlayerSpawn(playerid);
public SetPlayerSpawn(playerid)
{
 if(SpawnOnSight[playerid] == 1 && FirstSpawn[playerid] == 0)
	{
	    GameTextForPlayer(playerid, "~r~Injured", 5000, 3);
		ClearAnimations(playerid);
		TogglePlayerControllable(playerid,0);
		SetPlayerHealth(playerid, 100);
		SetPlayerArmour(playerid,0);
		SetPlayerPos(playerid, PlayerVar[playerid][LastPos][0], PlayerVar[playerid][LastPos][1], PlayerVar[playerid][LastPos][2]);
		ApplyAnimation(playerid,"CRACK","crckdeth3", 4.0, 0, 0, 0, 1, 0);
		SpawnOnSight[playerid] = 0;
		SpawnInHospital[playerid] = 1;
		D_Timer[playerid] = SetTimerEx("DeathTimer",60000,true,"u",playerid);
	}
	else if(SpawnInHospital[playerid] == 1 && SpawnOnSight[playerid] == 0)
	{
	    SendDeathMessage(MyKiller[playerid], playerid, MyDReason[playerid]);
	    TogglePlayerControllable(playerid,1);
	    SetCameraBehindPlayer(playerid);
    	SetPlayerVirtualWorld(playerid, 0);
    	SetPlayerInterior(playerid, 0);
    	SetPlayerHealth(playerid, 55);
    	SetPlayerArmour(playerid, 0);
		SetPlayerPos(playerid, 1177.3965, -1323.7709, 14.0686);
		SendClientMessageEx(playerid, COL_GREY, "NOTICE: You have been injured and immediately sent to the hospital for treatment");
		SendClientMessageEx(playerid, COL_GREY, "(( OOC NOTICE: You have lost 30 minutes of your memory, to prevent Revenge Killing ))");
		SpawnOnSight[playerid] = 1;
		SpawnInHospital[playerid] = 0;
		KillTimer(D_Timer[playerid]);
  		ResetPlayerWeaponsEx(playerid);
	}
	return 1;
}
This is weird because my script looks clean and simple.Oh btw for the ones who didn't watch the video,The bottle is not in my hand it's just on the ground and only the player who died can see it.
You're only preloading your anims on the first spawn, so when player spawn after death, anims not preloaded. Or try to clear player animations onplayerspawn
Reply
#6

Okay thanks I will try it
Reply
#7

I tried it and now I get a cigarette instead lol.
Edit: Sorry for double posting I forgot about the first message
Reply
#8

Quote:
Originally Posted by mirou123
Посмотреть сообщение
I tried it and now I get a cigarette instead lol.
Edit: Sorry for double posting I forgot about the first message
LOL! How about preloading anims with timers, like a second after spawn ?
Reply
#9

I will try but how will preloading animations help me to remove the cigarette from the ground?
Reply
#10

Quote:
Originally Posted by mirou123
Посмотреть сообщение
I will try but how will preloading animations help me to remove the cigarette from the ground?
I have RP death system just like you, and I always preloadanim when player respawn (OnPlayerSpawn), and I never gets ciggerate, even bottle.
I also tested when Im not preload the anim, player will spawn with bottle or ciggerate.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)