Forum

> > CS2D > Scripts > Script error
Forums overviewCS2D overview Scripts overviewLog in to reply

English Script error

2 replies
To the start Previous 1 Next To the start

old Script error

Pamoon
User Off Offline

Quote
Ha, this is my knocback script
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:
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

old Re: Script error

Rainoth
Moderator Off Offline

Quote
add
1
if player(id,"exists") and player(source,"exists") then
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview