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



Need Help :D - sekol - 26.08.2010

So i need to know how can i spawn player after death in place he died Simple, huh? So explain it to me
Код:
public MaloZycia(playerid)
{
    new Float:health;
    GetPlayerHealth(playerid,health);
    if (health < 2.0)
    {
    	TogglePlayerControllable(playerid, 0);
        ApplyAnimation(playerid, "SWEET", "Sweet_injuredloop", 4.1,1,1,1,1,0,1);
    	SetTimer("bw",4800000,false);
	}
}

public bw()
{
	for (new i = 0; i < MAX_PLAYERS; i++)
	TogglePlayerControllable(i, 1);
}



Re: Need Help :D - Hiddos - 26.08.2010

Eh, where's that code for?

Anyways, get his position when he dies and then set when the player spawns again.


Re: Need Help :D - LifeStyle - 26.08.2010

pawn Код:
new Float:x,Float:y,Float:z;
//onplayerdeath
GetPlayerPos(playerid,x,y,z);
//onplayerspawn
SetPlayerPos(playerid,x,y,z);
Should do it :P


Re: Need Help :D - sekol - 26.08.2010

This code is for brutally wounded system... So when player dies he must remain in death postion some time in unconscious state. Yeah, i don't know how to get his death position, i need explanation


Re: Need Help :D - Mauzen - 26.08.2010

Save his position in OnPlayerDeath, e.g. in an global array for every player. In OnPlayerSpawn you can set the pos again then with the values you stored - maybe with another check, if he should only spawn there, if he is healed or so.

pawn Код:
On the top with the other variables:
new Float:deathpos[MAX_PLAYERS][3];

In OnPlayerDeath:
GetPlayerPos(playerid, deathpos[playerid][0], deathpos[playerid][1], deathpos[playerid][2]);

in OnPlayerSpawn:
SetPlayerPos(playerid, deathpos[playerid][0], deathpos[playerid][1], deathpos[playerid][2]);



Re: Need Help :D - Adil - 26.08.2010

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Save his position in OnPlayerDeath, e.g. in an global array for every player. In OnPlayerSpawn you can set the pos again then with the values you stored - maybe with another check, if he should only spawn there, if he is healed or so.

pawn Код:
On the top with the other variables:
new Float:deathpos[MAX_PLAYERS][3];

In OnPlayerDeath:
GetPlayerPos(playerid, deathpos[playerid][0], deathpos[playerid][1], deathpos[playerid][2]);

in OnPlayerSpawn:
SetPlayerPos(playerid, deathpos[playerid][0], deathpos[playerid][1], deathpos[playerid][2]);
That's going to set your x,y, and z coordinates to 0 when you spawn after connecting to the server.

pawn Код:
new IsPlayerDead[MAX_PLAYERS]; //On top of script
pawn Код:
OnplayerDeath(playerid, killerid, reason)
{
    IsPlayerDead = 1;
    return 1;
}
pawn Код:
OnPlayerSpawn(playerid)
{
    if(IsPlayerDead[playerid] == 1)
    {
        //Do stuff here
    }
    return 1;
}