SA-MP Forums Archive
to stop repeating the checkpoint - 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: to stop repeating the checkpoint (/showthread.php?tid=113032)



to stop repeating the checkpoint - WardenCS - 11.12.2009

hey,i wanted to make if player enters checkpoint,then he will get the thing only once,and the checkpoint wont dissapear,how to do that?Thanks,or if u dont know,how to make that it gives 1 hp per sec?


Re: to stop repeating the checkpoint - Abernethy - 11.12.2009

I took it to myself to create it for you. Edit it how you like. (Untested)
pawn Код:
new HealthTimer;
forward RaiseHealth(playerid, Float:Health);

public RaiseHealth(playerid)
{
    new
        Float:Health;
       
    GetPlayerHealth(playerid, Float:Health);
    SetPlayerHealth(playerid, Float:Health+1.00);
    return true;
}

public OnPlayerEnterCheckpoint(playerid)
{
    HealthTimer = SetTimerEx("RaiseHealth", 1000, true, "f", playerid);
    return true;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    KillTimer(HealthTimer);
    return true;
}



Re: to stop repeating the checkpoint - Correlli - 11.12.2009

Quote:
Originally Posted by Aber▲
I took it to myself to create it for you. Edit it how you like. (Untested)
pawn Код:
code..
You're code is wrong.

pawn Код:
new
    healthTimer[MAX_PLAYERS];
pawn Код:
forward RaiseHealth(playerid);
pawn Код:
public RaiseHealth(playerid)
{
  new
      Float:health;
  GetPlayerHealth(playerid, health);
  SetPlayerHealth(playerid, floatround(health) + 1);
  if(health >= 100.0)
  {
    KillTimer(healthTimer[playerid]);
    SetPlayerHealth(playerid, 100);
  }
  return true;
}
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
  healthTimer[playerid] = SetTimerEx("RaiseHealth", 1000, true, "i", playerid);
  return true;
}
pawn Код:
public OnPlayerLeaveCheckpoint(playerid)
{
  KillTimer(healthTimer[playerid]);
  return true;
}