Forum

> > CS2D > Scripts > Crouching script error
Forums overviewCS2D overview Scripts overviewLog in to reply

English Crouching script error

4 replies
To the start Previous 1 Next To the start

old Crouching script error

J4x
User Off Offline

Quote
hi guys,i have this crouching script, but it dont works it always says me this error : attempt to index local "rot" ( a number value)

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
function array(v,e,m)
     if not v then v = 0 end
     if not e then e = 32 end
     if not m then m = 1 end
     local tbl = {}
     for i = m,e,1 do
          tbl[i] = v
     end
     return tbl
end

duck = array(false)
duck.x = array()
duck.y = array()
duck.rot = array()
rot = array()
rot.x = array()
rot.y = array()

function around(x,y,what)
     if not what then what = "wall" end
     if tile(x - 1,y,what) then
          return true,x - 1,y,270
     elseif tile(x + 1,y,what) then
          return true,x + 1,y,90
     elseif tile(x,y - 1,what) then
          return true,x,y - 1,0
     elseif tile(x,y + 1,what) then
          return true,x,y + 1,180
     elseif tile(x + 1,y + 1,what) then
          return true,x + 1,y + 1,135
     elseif tile(x + 1,y - 1,what) then
          return true,x + 1,y - 1,45
     elseif tile(x - 1,y + 1,what) then
          return true,x - 1,y + 1,225
     elseif tile(x - 1,y - 1,what) then
          return true,x - 1,y - 1,315
     else
          return false
     end
end

function table.find(tbl,val)
     for i,v in pairs(tbl) do
          if v == val then
               return true
          end
     end
     return false
end

addhook([[serveraction]],[[sac]])
function sac(id,a)
     if a == 3 then
          if player(id,"health") > 0 then
               local x,y = player(id,"tilex"),player(id,"tiley")
               local bla,bld,bls,bll = around(x,y,"obstacle")
               duck.x[id] = bld
               duck.y[id] = bls
               duck.rot[id] = bll
               if bla == true then
                    if duck[id] == true then
                         duck[id] = false
                         parse([[speedmod ]]..id..[[ 0]])
                    else
                         msg2(id,"©000255000Now you crouch behind an obstacle.")
                         parse([[speedmod ]]..id..[[ -100]])
                         duck[id] = true
                    end
               else
                    duck[id] = false
                         parse([[speedmod ]]..id..[[ 0]])
               end
          end
     end
end

addhook([[attack]],[[attacker]])
function attacker(id)     
     local x,y,rot = player(id,"x"),player(id,"y"),player(id,"rot")
     if rot > 360 then
          rot = rot - 360
     elseif rot < 0 then
          rot = rot + 360
     end
     rot.x[id] = x + math.sin(math.rad(rot[id])) * 32
     rot.y[id] = y - math.cos(math.rad(rot[id])) * 32
     rot.x[id] = math.ceil(rot.x[id]/32)
     rot.y[id] = math.ceil(rot.y[id]/32)
     if duck[id] == true then
          return 1
     end
end

addhook([[hit]],[[hitter]])
function hitter(id,src,wpn,hpdmg,apdmg)
     if duck[id] == true then
          if not table.find({49,48,51,72,73,75,76,77,86},wpn) then
               if math.sqrt((rot.x[src] - player(id,"tilex"))^2 + (rot.y[src] - player(id,"tiley"))^2) < 350 then
                    if duck.rot[id] - rot[src] < 0 and duck.rot[id] - rot[src] > 360 then
                         return 1
                    else
                         return 0
                    end
               else
                    return 1
               end
          end
     end
end
Spoiler >
edited 1×, last 01.01.11 07:39:51 pm

old Re: Crouching script error

archmage
User Off Offline

Quote
Since it was written by Yasday why not just PM him instead?
The problem is that in the function attacker the script attempts to index rot which is a number maybe you meant duck.rot?

old Re: Crouching script error

Yasday
User Off Offline

Quote
I will take care of this tomorrow ... what I wrote there is total bullsh*t and why did you post this here, lol.
And the error, hmm.. I don't get that error. When do you get it?

old Re: Crouching script error

Lee
Moderator Off Offline

Quote
1
local x,y,rot = player(id,"x"),player(id,"y"),player(id,"rot")

Rename the last variable

old Re: Crouching script error

J4x
User Off Offline

Quote
@Darkbyte i post it here because de dont know how to soleve it...

@Yasday, i get that error when i start using it

@lee thx the answer..
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview