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
#2

Anyone ?
Reply
#3

Please some help me, I'll award him with rep.
Reply
#4

This should work
Код:
CMD:revive(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1)
	{
		SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
		return 1;
	}
	new toplayerid;
	if(!sscanf(params, "u", toplayerid))
	{
		if(IsPlayerConnected(toplayerid))
		{
		    if(toplayerid != INVALID_PLAYER_ID)
			{
		        if(PlayerJustDied[toplayerid] == 1)
				{
	                if(PlayerCalledEMS[playerid] == 0)
					{
     	    			KillTimer(DeathTimer(toplayerid));
	                    SetPlayerHealth(toplayerid, 100);
						SetPlayerArmour(toplayerid, 0);
						ClearAnimations(toplayerid);
						PlayerJustDied[toplayerid] = 0;
	     				TextDrawHideForPlayer(toplayerid, Text:DieText);
		       	 		TextDrawHideForPlayer(toplayerid, Text:InjuredText);
						SendClientMessage(toplayerid, COLOR_WHITE, "   Revived by admin !");
						format(string, sizeof(string), "{FF0000}AdmWarning{FFFFFF}: %s has revived %s.",PlayerRPName(playerid),PlayerRPName(toplayerid));
						ABroadCast(COLOR_WHITE,string,1);
					}
					else
					{
					    SendClientMessage(playerid, COLOR_GRAD1, "   The player is awaiting a paramedic !");
					}
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GRAD1, "   Player is not injured !");
				}
		    }
		}
	}
	else
	{
	    SendClientMessage(playerid, COLOR_GREY, "USAGE: '/revive [playerid/PartOfName]'");
	}
	return 1;
}
Reply
#5

I'll try and tell you if it works.
Reply
#6

It works +rep
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)