Code
addhook("attack","napad")
function napad(id)
if player(id,"weapontype")<41 then
for i=0,768,4 do
local u=math.rad(player(id,"rot")-90); local x,y=player(id,"x")+math.cos(u)*i,player(id,"y")+math.sin(u)*i
if tile(math.floor(x/32),math.floor(y/32),"walkable")==true then
for _,od in pairs(object(0,"table")) do
if object(od,"type")==21 then
if object(od,"tilex")==math.floor(x/32) and object(od,"tiley")==math.floor(y/32) then
u=math.rad(object(od,"rot")*90-90); local ox,oy=math.floor(x/32)*32+16+math.cos(u)*12,math.floor(y/32)*32+16+math.sin(u)*12
if math.sqrt((ox-x)^2+(oy-y)^2)<8 then
if player(id,"weapontype")~=10 or player(id,"weapontype")==10 and math.sqrt((x-player(id,"x"))^2+(y-player(id,"y"))^2)<=160 then
parse("killobject "..od); i=768; break
end
end
end
end
end if i==768 then break end else break
end
end
end
end
I used "<41" because i'm also working on ammo for weapons. And some weapons will be changed:
P90 -> MP5
G3SG1 -> Galil
XM1014 -> M3
Laser -> Five-Seven
Flameth -> SG550
UMP45 -> G3SG1
(i'm trying to make similar to hl1 fire rate)