Doctor script
#1

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

Please give me function
Reply
#2

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

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 );
Reply
#4

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..
Reply
#5

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
Reply
#6

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

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

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 ?
Reply
#9

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;
}
Reply
#10

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 );
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)