English Health Script

4 replies
Goto Page
To the start Previous 1 Next To the start
13.01.21 03:43:12 pm
Up
DX
User
Offline Off
how so that I receive more than 250 damage I will not die
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function initArray(m)
     local array = {}
     for i = 1, m do
          array[i]=0
     end
     return array
end

HP = initArray(32)
AP = initArray(32)

addhook("spawn","spawn")
function spawn(id)
     HP[id]=1000
     AP[id]=1000
end

addhook("always","always")
function always()
     for id = 1, 32 do
          if HP[id]>0 then
               parse("setmaxhealth "..id.." 250")
               parse('hudtxt2 '..id..' 1 "©000500000Health: '..HP[id]..'" 10 440')
          elseif HP[id]<1 then
               parse("sethealth "..id.." 1")
               parse('hudtxt2 '..id..' 1 "©000500000Health: 0" 10 440')
          end

          if AP[id]>0 then
               parse("setarmor "..id.." 200 ")
               parse('hudtxt2 '..id..' 2 "©000500000Armor: '..AP[id]..'" 10 460')
          elseif AP[id]<1 then
               parse("setarmor "..id.." 0 ")
               parse('hudtxt2 '..id..' 2 "©000500000Armor: 0" 10 460')
          end
     end
end

addhook("hit","hit")
function hit(id,source,wpn,hpdmg,apdmg)
     if HP[id]>0 then
          HP[id]=HP[id]-hpdmg
     end

     if AP[id]>0 then
          AP[id]=AP[id]-apdmg
     end
end
Kontol bapak kau pecah!!!
13.01.21 08:13:32 pm
Up
Bowlinghead
User
Offline Off
1. Think of when your health changes. It only accurs on the "hit" event (or the die, leave event) therefore you dont have to check it "always"!


2. Use return 1 to neglect ALL damage received at the end and then use
Code:
1
parse("sethealth "..id.." "..HP[id])

when HP[id] < 250.

3. table optimization or something like that. When there are 3 players on the servers, you store 29x "0".


Example:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function yourHit(id,source,wpn,hpdmg,apdmg)
     
    HP[id] = HP[id] - hpdmg;
   if (HP[id] <= 0) then 
     parse("killplayer "..id)
   end


    if (HP[id] < 250) then
     parse("sethealth "..id.." "..tostring(HP[id]))
   else 
     parse("sethealth "..id.." 250");
   end

   return 1;
   -- note that everything below "return" WILL NOT BE EXECUTED!
end
Share time limited free games here
13.01.21 10:08:04 pm
Up
DX
User
Offline Off
@user Bowlinghead: Mr i dont understand can you make it
I have made use of return 1 but that makes me immune
Kontol bapak kau pecah!!!
13.01.21 10:29:40 pm
Up
Mami Tomoe
User
Offline Off
You might want to try file cs2d [SP] Percent Health Module (9).
Is death truly a bad thing? If it is, then why do we all get to experience it? And... Why does it take so long? - What is the meaning of death?
14.01.21 11:08:43 am
Up
Cure Pikachu
User
Offline Off
Wait, so if incoming (raw) damage is more than 250 it is negated? Or a health script that extends your max HP past 250 like the kind user Mami Tomoe shared?
edited 1×, last 14.01.21 11:21:49 am
IMG:https://i.imgur.com/uUrye71.png
IMG:https://i.imgur.com/xpsyQRX.png
To the start Previous 1 Next To the start