English Knockback Script?

5 replies
Goto Page
To the start Previous 1 Next To the start
18.02.14 12:27:27 pm
Up
N13-SHADOW
User
Offline Off
i finally thinked about something cool

can any body make a script that can push players on hit?

i know we have it already but its for zambie mod
i want a sample script that we can paste it in "autorun"folder
[to use it]

did we have?
here.. eat some cookies! (LOL)
N13~SHADOW

Admin/mod comment:

"is it going to create?" isn't a title which makes any sense at all. fixed. /DC
18.02.14 12:41:21 pm
Up
MikuAuahDark
User
Offline Off
find the knockback code in zombie plague, edit it as necessary, save, put it at autorun folder
file cs2d LuaJIT for Dedicated Server (11) JIT POWER! | Know your Lua errors! | Draw stuff at Pixelize Art --xx-- server!
18.02.14 12:59:53 pm
Up
Ortimh
User
Offline Off
Here it is:
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
addhook("hit", "hithook")
function hithook (id, source, weapon, hpdmg)
     if (weapon < 50 or weapon > 69) then
          knockback(source, id, weapon)
     end
end

function knockcheck (x, y, rotation, knock)
     local breaks, op1, op2
     for distance = 5, math.ceil(knock), 2 do
          op1 = x + math.cos(rotation) * distance
          op2 = y + math.sin(rotation) * distance
          if (not tile(math.ceil(op1 / 32) - 1, math.ceil(op2 / 32) - 1, "walkable")) then
               breaks = true
               break
          end
     end
     return breaks
end

function knockback (id, source, weapon)
     if (weapon < 99) then
          local knock = itemtype(weapon, "dmg") / 2
          local rotation = player(id, "rot")
          if (rotation < -90) then
               rotation = rotation + 360
          end
          local angle = math.rad(math.abs(rotation + 90)) - math.pi
          x = player(source, "x") + math.cos(angle) * knock
          y = player(source, "y") + math.sin(angle) * knock
          if (not knockcheck(player(source, "x"), player(source, "y"), angle, knock)) then
               parse("setpos " .. source .. " " .. x .. " " .. y)
          end
     end
end

It is fresh from Zombie Plague. It works perfectly fine. Edited the necessary component to make it compatible without Zombie Plague data.
I'm awesome ... and I really like cookies.
18.02.14 01:35:55 pm
Up
N13-SHADOW
User
Offline Off
is it gonna work when i paste it in "autorun" folder?
N13~SHADOW
18.02.14 02:05:43 pm
Up
Ortimh
User
Offline Off
user N13-SHADOW has written:
is it gonna work when i paste it in "autorun" folder?

Of course, I think.
I'm awesome ... and I really like cookies.
18.02.14 04:01:31 pm
Up
Yates
Reviewer
Offline Off
The Zombie Plague knock back script is bugged hard. Good luck with that.

Also note that turrets and barbed wire do not knock back.
To the start Previous 1 Next To the start