SA-MP Forums Archive
OnPlayerDeath Help - 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: OnPlayerDeath Help (/showthread.php?tid=606456)



OnPlayerDeath Help - GoldenLion - 04.05.2016

Hi, I got a problem with this code:

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(IsPlayerInAnyVehicle(playerid))
	{	
	}
	else
	{
		SpawnPlayer(playerid);
		SetPlayerHealth(playerid, 100.0);
	}
So as you can see it's supposed to spawn player immediately after death when the player is on foot and when player is in a vehicle then let him die normally. So the problem is that even if player is in a vehicle it spawns him immediately like he was on foot, but as you can see if player is in a vehicle it's supposed to do nothing. How to fix that?


Re: OnPlayerDeath Help - Ritzy2K - 04.05.2016

The Callback will be called "OnPlayerSpawn" after OnPlayerDeath is called for any specific player. What do you want when a player dies in a vehicle? Set them to spectating? You can use a variable and set its value to 1, if a player dies in vehicle. Then under OnPlayerSpawn check if the variable value is 1, if it is, set him to spectating or whatever you wana do with him.


Re: OnPlayerDeath Help - GoldenLion - 04.05.2016

Quote:
Originally Posted by [ND]xXZeusXx.
Посмотреть сообщение
The Callback will be called "OnPlayerSpawn" after OnPlayerDeath is called for any specific player. What do you want when a player dies in a vehicle? Set them to spectating? You can use a variable and set its value to 1, if a player dies in vehicle. Then under OnPlayerSpawn check if the variable value is 1, if it is, set him to spectating or whatever you wana do with him.
I want player do nothing when he dies in a vehicle. Just like default death like the view is from above then the screen goes up and in a few seconds player respawns. I use SCRP script which has injury system. After player death the player is injured and if player dies and respawns quickly in the vehicle then he gets bugged, but when he is on foot then it's good.


Re: OnPlayerDeath Help - Ritzy2K - 04.05.2016

Freeze the player and apply an animation.


Re: OnPlayerDeath Help - GoldenLion - 04.05.2016

Quote:
Originally Posted by [ND]xXZeusXx.
Посмотреть сообщение
Freeze the player and apply an animation.
After IsPlayerInAnyVehicle line or what? :P Also how would this help? :/


Re: OnPlayerDeath Help - Micko123 - 05.05.2016

If you want to freeze player just type TogglePlayerControllable(playerid, 0);. Put it under IsPlayerInAnyVehicle


Re: OnPlayerDeath Help - GoldenLion - 05.05.2016

Quote:
Originally Posted by Micko123
Посмотреть сообщение
If you want to freeze player just type TogglePlayerControllable(playerid, 0);. Put it under IsPlayerInAnyVehicle
I know how to freeze a player, but how would this help?


Re: OnPlayerDeath Help - Micko123 - 05.05.2016

Can you tell me what is exact problem when player dies in vehicle.


Re: OnPlayerDeath Help - Dayrion - 05.05.2016

Have you tried :
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    if(
IsPlayerInAnyVehicle(playerid))
    {
    return 
1;
    }
    else if(!
IsPlayerInAnyVehicle(playerid))
    {
        
SpawnPlayer(playerid);
        
SetPlayerHealth(playerid100.0);
    }




Re: OnPlayerDeath Help - GoldenLion - 05.05.2016

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Have you tried :
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    if(
IsPlayerInAnyVehicle(playerid))
    {
    return 
1;
    }
    else if(!
IsPlayerInAnyVehicle(playerid))
    {
        
SpawnPlayer(playerid);
        
SetPlayerHealth(playerid100.0);
    }

Didn't help.

Quote:
Originally Posted by Micko123
Посмотреть сообщение
Can you tell me what is exact problem when player dies in vehicle.
I want player to respawn instantly after death on foot, but I don't want it to work when player is in a vehicle. I want him to die normally and not respawn by SpawnPlayer, but for some reason it does all the same stuff that it does on foot. Here's a video: https://www.youtube.com/watch?v=gax9...ature=*********