Need Help with onplayerdeath
#1

Hello so today i make new interior for my hospital (interior id 2) i have tested with enter exit pickups and one teleportation command its working and its get my ware i should , the thing is when i dead i get in thos pos but i am start falling ant nothing appear around :
hare is my onplayerdeath
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	
	SetPlayerPos(playerid, 2563.9680,-1821.03295,1223.7919);
	SetPlayerInterior(playerid, 2);
	SetTimerEx("UnfreezePlayer", 10000, false, "i", playerid);



	//SetPlayerVirtualWorld(playerid, 0);
	return 1;
}
and as i said i have tried this commands to set my at same pos and interior like on player death is works :
Код:
if(strcmp(cmdtext, "/tele", true) == 0)
	{
			SetPlayerPos(playerid, 2563.9680,-1821.03295,1223.7919);
	SetPlayerInterior(playerid, 2);
            return 1;
    }
so after death i am start alling in interior 2 when i reach ground i dead again and then my pos are set to there ware i spawn at start . And i have problem with vehicle to if i dead in vehicle i just get in my spawn pos
Reply
#2

Do you have a forward for unfreezeplayer , if yes show it and try setplayerinterior before setting the position
Reply
#3

[code]forward UnfreezePlayer(playerid);[/CODE
Код:
public UnfreezePlayer(playerid)
{
    TogglePlayerControllable(playerid, true);
    return 1;
}
]
what this have to do with that ?
have tried already to set interior before pos , but in my /tele cmd i set it after it it still works without bugs
Reply
#4

Does the player get freezed?
Try to set a variable after death and on the spawn freeze and set the player pos

Код:
new PlayerDied[MAX_PLAYERS];
public OnPlayerConnect(playerid) {
	PlayerDied[playerid] = false;
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	PlayerDied[playerid] = true;
	return 1;
}

public OnPlayerSpawn(playerid) {
	if(PlayerDied[playerid] == true) {
		SetPlayerPos(playerid, 2563.9680,-1821.03295,1223.7919);
		SetPlayerInterior(playerid, 2);
		TogglePlayerControllable(playerid,0);
		SetTimerEx("UnfreezePlayer", 10000, false, "i", playerid);
		//SetPlayerVirtualWorld(playerid, 0);
		PlayerDied[playerid] = false;
	}
	else { 
		// Spawn the player on the spawn pos
	}
	return 1;
}
Reply
#5

Quote:
Originally Posted by Pasa
Посмотреть сообщение
Does the player get freezed?
Try to set a variable after death and on the spawn freeze and set the player pos

Код:
new PlayerDied[MAX_PLAYERS];
public OnPlayerConnect(playerid) {
	PlayerDied[playerid] = false;
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	PlayerDied[playerid] = true;
	return 1;
}

public OnPlayerSpawn(playerid) {
	if(PlayerDied[playerid] == true) {
		SetPlayerPos(playerid, 2563.9680,-1821.03295,1223.7919);
		SetPlayerInterior(playerid, 2);
		TogglePlayerControllable(playerid,0);
		SetTimerEx("UnfreezePlayer", 10000, false, "i", playerid);
		//SetPlayerVirtualWorld(playerid, 0);
		PlayerDied[playerid] = false;
	}
	else { 
		// Spawn the player on the spawn pos
	}
	return 1;
}
i have tried your way its not working , after death i just get same pos like after spawn
Reply
#6

To avoid spawning at the position where you spawned the first time.
Try using
Код:
SetSpawnInfo(playerid, team, skin, Float:x, Float:y, Float:z, Float:Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
at OnPlayerDeath
Reply
#7

Ok, I got your problem. You are using the wrong callback, you should use the "OnPlayerSpawn" instead.
Try this:

pawn Код:
//On top:

new bool:pDead[MAX_PLAYERS] = false;

// Callbacks:

public OnPlayerDeath(playerid, killerid, reason)
{
    // Your code

    pDead[playerid] = true;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(pDead[playerid] == true)
    {
    SetPlayerInterior(playerid, 2);
    SetPlayerVirtualWorld(playerid, 0);
    SetPlayerPos(playerid, 2563.9680, -1821.03295, 1223.7919);
    TogglePlayerControllable(playerid, 0);
    SetTimerEx("UnfreezePlayer", 10000, false, "i", playerid);
    return 1;    
    }

   // Put this code in the BEGINNING of the callback.
}


forward UnfreezePlayer(playerid);

public UnfreezePlayer(playerid)
{
      TogglePlayerControllable(playerid, 1);    
      pDead[playerid] = false;
      SpawnPlayer(playerid);
      SendClientMessage(playerid, -1, "You are free!");
      return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)