English Why it won't work?

5 replies
Goto Page
To the start Previous 1 Next To the start
15.05.18 12:18:11 pm
Up
NanuPlayer
User
Offline Off
What is the wrong with this 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
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
mode = {}
parse("mp_hudscale 1")

for _,e in pairs(entitylist()) do
     if entity(e.x,e.y,"typename") == "Env_Hurt" and entity(e.x,e.y,"int0") == -100 and entity(e.x,e.y,"int1") == 2 then
          local x=e.x
          local y=e.y
          local x2=(e.x-1)+entity(e.x,e.y,"int2")
          local y2=(e.y-1)+entity(e.x,e.y,"int3")
          
          table.insert(safe,{x,x2,y,y2})
     end
end

function init_array(length,mode)
     local array = {}
     for i = 1,length do 
          array[i] = mode     
     end
     return array
end

player_safe = init_array(32,false)

addhook("movetile","movetile")
addhook("hit","hit")

function hit(id)
     if player_safe[id] then
          return 1
     end
     return 0
end

function movetile(id,x,y)
     for i in ipairs(safe) do
          if x >= safe[i][1] and x <= safe[i][2] and y >= safe[i][3] and y <= safe[i][4] then
               player_safe[id] = true
               mode[id] = "SAFE ZONE"
               break
          else
               player_safe[id] = false
               mode[id] = "NOT IN SAFE!"
          end
     end     
     update_hud(id)
end

function update_hud(id)
          parse("hudtxt2 "..id.." 1 "..mode[id].." 50 425 1")
end

addhook("join","join1")
function join1(id)
mode[id] = "NOT IN SAFE!"
end
Bad Life
15.05.18 01:35:10 pm
Up
Yates
Reviewer
Offline Off
15.05.18 02:10:08 pm
Up
NanuPlayer
User
Offline Off
@user Yates:

everythin! really -_-?

just tell me where is the error
Bad Life
15.05.18 02:46:40 pm
Up
Yates
Reviewer
Offline Off
Could be line 5, 11 or 18.

My bet goes to 18. If not then definitely line 11.
15.05.18 02:54:00 pm
Up
Jenko63
User
Offline Off
@user Yates:

Thaaanks!

line 18 fix didn't worked

that's just keep 11 and 5 and idk how to fix those
JENKO
15.05.18 02:57:52 pm
Up
Yates
Reviewer
Offline Off
You have
mode
defined at the top which could conflict with the
init_array
function and its
mode
parameter.

safe
is not defined as far as I can see. Can't insert into a table that doesn't exist eyy. Just add it at the top:
Code:
1
safe = {}


Line 5 is me just thinking the entity isn't set to these strict statements. It's not really a code error. Double check it matches by spamming success messages inside the statement.
To the start Previous 1 Next To the start