SA-MP Forums Archive
Help with this very confusing problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with this very confusing problem (/showthread.php?tid=252339)



Help with this very confusing problem - Swiftz - 01.05.2011

I edited Admantis second life script

I created 3 values for a variable IsDead, It checks if player is in which state (2= Alive, 1= Waiting treatment (injured) 0 = hospital)

So my first function when player is dead is
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
 new Float:pX22, Float:pY22, Float:pZ22;
 GetPlayerPos(playerid, pX22, pY22, pZ22);
 PlayerInfo[playerid][pDeathPosX] = pX22;
 PlayerInfo[playerid][pDeathPosY] = pY22;
 PlayerInfo[playerid][pDeathPosZ] = pZ22;
  if(PlayerInfo[playerid][pIsDead] == 2)
  {
    PlayerInfo[playerid][pIsDead] = 1;
  }
  if(PlayerInfo[playerid][pIsDead] == 0)
  {
   Some script here..
	return 1;
  }
  return 1;
}
Код:
	if(newstate == PLAYER_STATE_WASTED) //PLAYER DIES
	{
	    if(PlayerInfo[playerid][pJailed] == 1)
	    {
		   if(PlayerInfo[playerid][pIsDead] == 0)
		   {
			  PlayerInfo[playerid][pHospital] = 1;
		   }
		   if(PlayerInfo[playerid][pIsDead] == 2)
		   {
            PlayerInfo[playerid][pIsDead] = 1;
		   }
	    }
	}
And under onplayerspawn
Код:
		if(PlayerInfo[playerid][pIsDead] == 1)
		{
            SetPlayerPos(playerid,PlayerInfo[playerid][pDeathPosX],PlayerInfo[playerid][pDeathPosY],PlayerInfo[playerid][pDeathPosZ]);
            SetPlayerCameraPos(playerid,PlayerInfo[playerid][pDeathPosX],PlayerInfo[playerid][pDeathPosY],PlayerInfo[playerid][pDeathPosX]+5);
            SetPlayerCameraLookAt(playerid,PlayerInfo[playerid][pDeathPosX],PlayerInfo[playerid][pDeathPosY],PlayerInfo[playerid][pDeathPosZ]);
            TogglePlayerControllable(playerid, 0);
            ApplyAnimation(playerid,"PARACHUTE","FALL_skyDive_DIE", 4.0, 0, 0, 0, 1, 0);
            SetTimerEx("AutoDeath",AUTODEATH_SECONDS * 1000,false,"i",playerid);
            SendClientMessage(playerid,CYAN,"------------------ Health Advise -----------------");
            SendClientMessage(playerid,WHITE,"You are wounded badly.");
            SendClientMessage(playerid,WHITE,"Do /service EMS For calling medics.");
            SendClientMessage(playerid,WHITE,"You can type /acceptdeath, if no medics are available.");
            SendClientMessage(playerid,CYAN,"--------------------------------------------------------");
		}
And the function SetPlayerinhospital puts player in some co-ordinates and camera e.t.c , Ok but when the player dies, He just spawns at the place he died and he can move, SendClientMessage (such as You are wounded badly) doesnt work, Any ideas? Please help it is major problme


Re: Help with this very confusing problem - leong124 - 01.05.2011

pawn Код:
GetPlayerPos(playerid, pX22, pY22, pZ22);
PlayerInfo[playerid][pDeathPosX] = pX22;
PlayerInfo[playerid][pDeathPosY] = pY22;
PlayerInfo[playerid][pDeathPosZ] = pZ22;
pawn Код:
SetPlayerPos(playerid,PlayerInfo[playerid][pDeathPosX],PlayerInfo[playerid][pDeathPosY],PlayerInfo[playerid][pDeathPosZ]);
When you death, you save the player's current position.
When they spawn, you set it back.

Also I can't see the function SetPlayerinhospital...


Re: Help with this very confusing problem - Swiftz - 01.05.2011

No need to see SetPlayerinhospital function, bcuz i explained it, and it is not called up at all at the first place