English Script error

2 replies
Goto Page
To the start Previous 1 Next To the start
25.09.14 03:13:24 pm
Up
Pamoon
User
Offline Off
Ha, this is my knocback script
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
recoil_factor = 5
addhook('hit','knockback')
function knockback(id,source,weapon)
     if player(source,'exists') then
local killer_x = player(source,'x')
local killer_y = player(source,'y')
local victim_x = player(id,'x')
local victim_y = player(id,'y')
local recoil = itemtype(weapon,'recoil') * recoil_factor
          if killer_x > victim_x then 
               if tile(player(id,'tilex') - 1,player(id,'tiley'),'walkable') then
                    parse('setpos '..id..' '..(player(id,'x') - recoil)..' '..player(id,'y')) 
               end
          end
          if killer_x < victim_x then 
               if tile(player(id,'tilex') + 1,player(id,'tiley')) then
                    parse('setpos '..id..' '..(player(id,'x') + recoil)..' '..player(id,'y')) 
               end
          end
          if killer_y > victim_y then
               if tile(player(id,'tilex'),player(id,'tiley') - 1,'walkable') then
                    parse('setpos '..id..' '..player(id,'x')..' '..(player(id,'y') - recoil)) 
               end
          end
          if killer_y < victim_y then 
               if tile(player(id,'tilex'),player(id,'tiley') + 1) then
                    parse('setpos '..id..' '..player(id,'x')..' '..(player(id,'y') + recoil)) 
               end
          end     
     end
end

Its work fine, but when i hit by turret, flame thrower, rocket(grenade) launchers, have an error:
Code:
sys/lua/zm_outlast.lua:10: attempt to perform arithmetic on a boolean value.

Can you fix it? I mean i just knockback when i was hit by them (Turret, flame thrower, rocket[grenade] launchers) Bad English, thx.
edited 1×, last 25.09.14 04:15:42 pm
25.09.14 04:00:40 pm
Up
Rainoth
Moderator
Offline Off
add
Code:
1
if player(id,"exists") and player(source,"exists") then
25.09.14 04:16:32 pm
Up
Pamoon
User
Offline Off
Lol, i forgot them xD. Thx u.
To the start Previous 1 Next To the start