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=527366)
OnPlayerDeath help! -
dieuhanhphuc - 22.07.2014
PHP код:
new Injured[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
Injured[playerid] = 0;
return 1;
}
public OnPlayerSpawn(playerid)
{
if(Injured[playerid] == 1)
{
ClearAnimations(playerid);
ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die", 4.0, 0, 1, 1, 1, 0, 1);
TogglePlayerControllable(playerid, 0);
}
if(Injured[playerid] == 2)
{
TogglePlayerControllable(playerid, true);
SetPlayerCameraPos(playerid,2000.942,-1453.973,39.952);
SetPlayerCameraLookAt(playerid,2032.520,-1416.205,16.992);
SetTimerEx("NamVien", 8000, 0, "i",playerid);
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(Injured[playerid] == 1)
{
Injured[playerid] = 2;
SetSpawnInfo(playerid, 0, PInfo[playerid][Skin], 2032.5200,-1416.2058,12, 0,0,0,0,0,0,0);
SpawnPlayer(playerid);
return 1;
}
GetPlayerPos(playerid, BTPos[playerid][0], BTPos[playerid][1], BTPos[playerid][2]);
GetPlayerFacingAngle(playerid, BTPos[playerid][3]);
SetSpawnInfo(playerid, 0, PInfo[playerid][Skin], BTPos[playerid][0],BTPos[playerid][1],BTPos[playerid][2]-0.1, BTPos[playerid][3],0,0,0,0,0,0);
SpawnPlayer(playerid);
Injured[playerid] = 1;
return 1;
}
I want to make injured system, but the condition in OnPlayerDeath likely not performed
![Sad](images/smilies/sad.gif)
. Someone help me
Re: OnPlayerDeath help! -
BlackM - 22.07.2014
Код:
if(Injured[playerid] == 1)
{
Injured[playerid] = 2;
SetSpawnInfo(playerid, 0, PInfo[playerid][Skin], 2032.5200,-1416.2058,12, 0,0,0,0,0,0,0);
SpawnPlayer(playerid);
return 1;
}
else
{
GetPlayerPos(playerid, BTPos[playerid][0], BTPos[playerid][1], BTPos[playerid][2]);
GetPlayerFacingAngle(playerid, BTPos[playerid][3]);
SetSpawnInfo(playerid, 0, PInfo[playerid][Skin], BTPos[playerid][0],BTPos[playerid][1],BTPos[playerid][2]-0.1, BTPos[playerid][3],0,0,0,0,0,0);
SpawnPlayer(playerid);
Injured[playerid] = 1;
}
I think this will do what you wanted. The problem in the code you posted is if your if statement return true, the code inside WILL be executed, but after that it will be overwritten by the code under it, I assume you wanted them for two different cases. Try the code above and tell me if it works the way you want it to.
Re: OnPlayerDeath help! -
dieuhanhphuc - 22.07.2014
still not work
Re: OnPlayerDeath help! -
dieuhanhphuc - 22.07.2014
*pump*