How to make a Healing like in other RP?
#1

How to make healing health like in other rp after you die your camera will set lookat hospital and you are healing yet
how to do that? i try this but failed

pawn Код:
new HealingTimer[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
    if(IsPlayerDead[playerid] == 1)
    {
        SetPlayerHealth(playerid, 0.0);
        SetPlayerVWIPosAng(playerid, 0, 0, 2012.0902,-1451.8118,13.5547,92.7932);
        SetPlayerCamPosLookAt(playerid, 2010.6136,-1440.9576,13.6466, 2032.8142,-1408.2061,17.1641);
        TogglePlayerControllable(playerid, false);
        HealingTimer[playerid] = SetTimerEx("Healing", 1000, true, "i", playerid);
        return 1;
    }
    return 1;
}

public Healing(playerid)
{
    new Float:hp;
    GetPlayerHealth(playerid, hp);
    if(hp == 100.0)
    {
        if(GetPlayerMoney(playerid) > 100) {
            GivePlayerMoney(playerid, -100);
            SendClientMessage(playerid, COLOR_GREY, "Medical Bills: $100, You pay $100 to the doctor");
        } else if(GetPlayerMoney(playerid) < 100) {
            SendClientMessage(playerid, COLOR_GREY, "The Doctor heals you for free, because you do not have enough money to pay him!");
        }
        SetPlayerVWIPosAng(playerid, 0, 0, 2030.7820,-1407.5547,17.1802,164.7021);
        SetCameraBehindPlayer(playerid);
        TogglePlayerControllable(playerid, true);
    }
    SetPlayerHealth(playerid, hp + 1);
    KillTimer(HealingTimer[playerid]);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    SetPlayerHealth(playerid, 0.0);
    IsPlayerDead[playerid] = 1;
    return 1;
}
Reply
#2

anyone got ideas?
Reply
#3

You forgot to forward the timer, then make public HealingTimer(playerid)

forward HealingTimer(playerid);
public HealingTimer(playerid)
{
// code here
}
Reply
#4

dude i already have it i just forgot to post it.
Reply
#5

Oh. Well post that to.
Reply
#6

Exact code:

Код:
new HealingTimer[MAX_PLAYERS];
new IsPlayerDead[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
      IsPlayerDead[playerid] = 0;
}
public OnPlayerSpawn(playerid)
{
    if(IsPlayerDead[playerid] == 1)
    {
        SetPlayerHealth(playerid, 1.0);// If not death
        SetPlayerVWIPosAng(playerid, 0, 0, 2012.0902,-1451.8118,13.5547,92.7932);
        SetPlayerCamPosLookAt(playerid, 2010.6136,-1440.9576,13.6466, 2032.8142,-1408.2061,17.1641);
        TogglePlayerControllable(playerid, 0);
        HealingTimer[playerid] = SetTimerEx("Healing", 1000, 1, "i", playerid);
        return 1;
    }
    return 1;
}

public Healing(playerid)
{
    new Float:hp;
    GetPlayerHealth(playerid, hp);
    if(hp >= 100.0)
    {
        if(GetPlayerMoney(playerid) > 100) {
            GivePlayerMoney(playerid, -100);
            SendClientMessage(playerid, COLOR_GREY, "Medical Bills: $100, You pay $100 to the doctor");
        } else if(GetPlayerMoney(playerid) < 100) {
            SendClientMessage(playerid, COLOR_GREY, "The Doctor heals you for free, because you do not have enough money to pay him!");
        }
        SetPlayerVWIPosAng(playerid, 0, 0, 2030.7820,-1407.5547,17.1802,164.7021);
        SetCameraBehindPlayer(playerid);
        TogglePlayerControllable(playerid, 1);
     KillTimer(HealingTimer[playerid]);
    }
    SetPlayerHealth(playerid, hp + 1);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    IsPlayerDead[playerid] = 1;
    return 1;
}
Reply
#7

What did you change?
Reply
#8

If you look closer in your script, you killed the player when he spawned, but ultrascripter sets it to 1 when the player spawns
Reply
#9

Look carefully ..

- Add new variable IsPlayerDead [MAX_PLAYERS].
- Change health of spawn.
- Moved KillTimer

Be checked to see change.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)