OnPlayerDeath Help
#1

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?
Reply
#2

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.
Reply
#3

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.
Reply
#4

Freeze the player and apply an animation.
Reply
#5

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

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

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?
Reply
#8

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

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

Reply
#10

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=*********
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)