Reviving
#1

I have a problem I tried scripting reviving in every possible way and nothing.

This is my code for death.
Quote:
Код:
#define AFTERLIFE_SECONDS            
#define AUTODEATH_SECONDS   


new Float:DeathPosX [MAX_PLAYERS];
new Float:DeathPosY [MAX_PLAYERS];
new Float:DeathPosZ [MAX_PLAYERS];
new IsDead [MAX_PLAYERS];
new SecsToGo [MAX_PLAYERS];
new IsAfterLifing [MAX_PLAYERS];
new AfterLifeTimer;

forward AfterLife(playerid);
forward AutoDeath(playerid);


public AfterLife(playerid)
{
        IsAfterLifing[playerid] = 1;
        SecsToGo[playerid]--;
        new string[128];
        format(string,sizeof(string),"~r~ ~h~ ~h~You are dead.~n~ ~r~ ~h~ ~h~You will spawn in %d seconds~n~ ~r~ ~h~ ~h~ Your IC memories are lost !",SecsToGo[playerid]);
        GameTextForPlayer(playerid,string,1100,3);
        if (SecsToGo[playerid] <= 0)
        {
            KillTimer(AfterLifeTimer);
            SpawnPlayer(playerid);
            return 1;
        }
        return 1;
}

public AutoDeath(playerid)
{
        if (IsDead[playerid] == 0) { return 0; }
        else if (IsDead[playerid] == 1)
        {
            new name[28];
            GetPlayerName(playerid,name,sizeof(name));

            IsDead[playerid] = 0;
            SecsToGo[playerid] = AFTERLIFE_SECONDS;
            SetPlayerPos(playerid,0, 0, 0);
            SetPlayerCameraPos(playerid,DeathPosX[playerid],DeathPosY[playerid],DeathPosZ[playerid]);
            SetPlayerCameraLookAt(playerid,DeathPosX[playerid],DeathPosY[playerid],DeathPosZ[playerid]+50);
            AfterLifeTimer = SetTimerEx("AfterLife",1000,true,"i",playerid);
            return 1;
        }
        return 1;
}


public OnPlayerDeath(playerid, killerid, reason)
{
    new Float:pX, Float:pY, Float:pZ;
    GetPlayerPos(playerid, pX, pY, pZ);
    DeathPosX[playerid] = pX;
    DeathPosY[playerid] = pY;
    DeathPosZ[playerid] = pZ;
    IsDead[playerid] = 1;
return 1;
}

public OnPlayerSpawn(playerid)
{
        IsAfterLifing[playerid] = 0;
    	if (IsDead[playerid] == 1)
        {
            SetPlayerPos(playerid,DeathPosX[playerid],DeathPosY[playerid],DeathPosZ[playerid]);
            SetPlayerCameraPos(playerid,DeathPosX[playerid],DeathPosY[playerid],DeathPosZ[playerid]+5);
            SetPlayerCameraLookAt(playerid,DeathPosX[playerid],DeathPosY[playerid],DeathPosZ[playerid]);
            TogglePlayerControllable(playerid,false);
            SetTimerEx("AutoDeath",AUTODEATH_SECONDS * 1000,false,"i",playerid);
            ApplyAnimation(playerid,"PED","KO_skid_front",4.1,0,1,1,1,0);
            SetPlayerHealth(playerid, 20.0);
            SendClientMessage(playerid,COLOR_IRC,"------------------ Health Advise -----------------");
            SendClientMessage(playerid,COLOR_WHITE,"You are now laying death. You are bleeding to death.");
            SendClientMessage(playerid,COLOR_WHITE,"Remember that the medics can revive you.");
            SendClientMessage(playerid,COLOR_WHITE,"You can type /acceptdeath, if no medics are available.");
            SendClientMessage(playerid,COLOR_IRC,"--------------------------------------------------------");
            return 1;
        }
return 0;
}
And this is my restore command. I want it to revive the person who is lying on the ground. But its not working. I tried being medic too, but nothing works. Please help me.

Quote:
Код:
CMD:revive(playerid, params[])
{
	if(strcmp(PlayerInfo[playerid][job],"Medic",true)==0)
    {
    new iPlayer;
    if(IsDead[iPlayer] == 1)
    {
            IsAfterLifing[iPlayer] = 0;
            SecsToGo[iPlayer] = REVIVE_SECONDS;
            TogglePlayerControllable(iPlayer, true);
            //AfterLifeTimer = SetTimerEx("AfterLife",1000,true,"i",playerid);
            SetPlayerBack(iPlayer, 1);
      }
     }
return 1;
}
Reply


Messages In This Thread
Reviving - by xdarren - 16.10.2013, 14:55
Re: Reviving - by xdarren - 16.10.2013, 16:21
Re: Reviving - by xdarren - 16.10.2013, 19:44
Re: Reviving - by DStreet - 16.10.2013, 20:16
Re: Reviving - by xdarren - 16.10.2013, 21:07
Re: Reviving - by xdarren - 16.10.2013, 21:21

Forum Jump:


Users browsing this thread: 2 Guest(s)