SA-MP Forums Archive
Doctor script - 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: Doctor script (/showthread.php?tid=464518)



Doctor script - GrOobY - 17.09.2013

i search for function using SetTimer To send 2 health on 4 Seconds

Please give me function


Re: Doctor script - alinategh - 17.09.2013

You mean add 2 hp to player's health?
new hp = GetPlayerHealth(playerid);
hp += 2;
SetPlayerHealth(playerid, hp);


Re: Doctor script - Konstantinos - 17.09.2013

Quote:
Originally Posted by alinategh
Посмотреть сообщение
You mean add 2 hp to player's health?
new hp = GetPlayerHealth(playerid);
hp += 2;
SetPlayerHealth(playerid, hp);
Have you ever used GetPlayerHealth function?

It's stored to the variable by reference.

pawn Код:
new
    Float: hp
;
GetPlayerHealth( playerid, hp );
SetPlayerHealth( playerid, hp + 2 );



Re: Doctor script - alinategh - 17.09.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Have you ever used GetPlayerHealth function?

It's stored to the variable by reference.

pawn Код:
new
    Float: hp
;
GetPlayerHealth( playerid, hp );
SetPlayerHealth( playerid, hp + 2 );
My mistake. forgot the format kinda..


Re: Doctor script - GrOobY - 17.09.2013

Quote:
Originally Posted by alinategh
Посмотреть сообщение
You mean add 2 hp to player's health?
new hp = GetPlayerHealth(playerid);
hp += 2;
SetPlayerHealth(playerid, hp);
on open samp server closed automatic the server using this script please help


Re: Doctor script - alinategh - 17.09.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Have you ever used GetPlayerHealth function?

It's stored to the variable by reference.

pawn Код:
new
    Float: hp
;
GetPlayerHealth( playerid, hp );
SetPlayerHealth( playerid, hp + 2 );
use Konstantinos's one


Re: Doctor script - therainycat - 17.09.2013

Read theme twice, or
https://sampwiki.blast.hk/wiki/GetPlayerHealth
https://sampwiki.blast.hk/wiki/SetPlayerHealth
for right syntax


Re: Doctor script - GrOobY - 17.09.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Have you ever used GetPlayerHealth function?

It's stored to the variable by reference.

pawn Код:
new
    Float: hp
;
GetPlayerHealth( playerid, hp );
SetPlayerHealth( playerid, hp + 2 );
working fine how to stop on hp 100 ?


Re: Doctor script - alinategh - 17.09.2013

pawn Код:
new
    Float: hp
;
GetPlayerHealth( playerid, hp );
SetPlayerHealth( playerid, hp + 2 );

public OnPlayerUpdate(playerid)
{
  if(GetPlayerHealth(playerid, hp) >= 100) return SetPlayerHealth(playerid, 100);
  return 1;
}



Re: Doctor script - Konstantinos - 17.09.2013

Quote:
Originally Posted by GrOobY
Посмотреть сообщение
working fine how to stop on hp 100 ?
An example:
pawn Код:
new
    heal_Timer
;

// Where you start the timer
heal_Timer = SetTimer( ... );
// OR
heal_Timer = SetTimerEx( ... );
// Depending on what you want

// In the public of the Timer (either looping through connected players or passing parameter in SetTimerEx)
new
    Float: hp
;
GetPlayerHealth( playerid, hp );
SetPlayerHealth( playerid, hp + 2 );
if( hp + 2 >= 100 ) KillTimer( heal_Timer );