English House System ( Starkkz script )

10 replies
Goto Page
To the start Previous 1 Next To the start
Up
kalis
User
Offline Off
Hi everyone.
I'm trying to finish a script.
but I am having a few problems, I can not fix it.
I do not know why it appears this error!
can someone help me?

I created the script for the player only have a house, if the player into another house ,the old house will be zero for all(Free)
--Thank for reading--
error :
Code:
1
attempt to index field '?' (a nil value)

here is 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
house = {}

function create(name)
     return function (area)
          return function (triggers)
               return function (button_name)
                    house[name] = {
                         areaStartX = area[1],
                         areaStartY = area[2],
                         areaEndX = area[3],
                         areaEndY = area[4],
                         triggers = triggers,
                                   button = button_name,
                    

                         -- USGN owner
                         owner = 0,
                         }
               end
          end
     end
end
function Exists(name)
     return house[name] ~= nil
end

function Check_point(x,y)
     for name, check in pairs(house) do
          if x >= check.areaStartX and y >= check.areaStartY and x <= check.areaEndX and y <= check.areaEndY then
               return name
          end
     end
end

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
addhook("use","Use_")
function Use_(id,event,data,x,y)
     local usgn = player(id, "usgn")
     local house_name = Check_point(x,y)


     local name = {}
     for k,v in pairs(house) do
          name = v[k]
     end
     local e = entity(x,y,"name")
     local b = ""..house[house_name].button..""
     if Exists(house_name) then
               if e == b  then
                              if house[name].owner == usgn then          
                                        house[name].owner = 0
                                        parse("trigger "..house[name].button)
                                        parse("sv_msg  ©255000255"..name.." is free now")     
                                        house[house_name].owner = usgn     
                                        parse("trigger "..house[house_name].button)
                                        parse("sv_msg ©255000255"..player(id,"name").." is owner of 2 "..name)
                              elseif house[house_name].owner ~= usgn then
                                        house[house_name].owner = usgn
                                        parse("sv_msg  ©255000255"..name)
                                        parse("sv_msg  ©255000255"..player(id,"name").." is owner of "..house_name)
                                        parse("trigger "..house[house_name].button)
                              end
               
               end
               
     end
end
19.11.12 01:06:15 pm
Up
Shawni
User
Offline Off
What about telling the probleme line
We die once, do i have to hide to be visible ?
20.11.12 01:45:29 am
Up
kalis
User
Offline Off
in line 15
Code:
1
if house[name].owner == usgn then

Code:
1
attempt to index field '?' (a nil value)
20.11.12 02:18:18 am
Up
UltraX
BANNED
Offline Off
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
house = {}

function create(name)
     return function (area)
          return function (triggers)
               return function (button_name)
                    house[name] = {
                         areaStartX = area[1],
                         areaStartY = area[2],
                         areaEndX = area[3],
                         areaEndY = area[4],
                         triggers = triggers,
                                   button = button_name,
                    

                         -- USGN owner
                         owner = 0,
                         }
               end
          end
     end
end
function Exists(name)
     return house[name] ~= nil
end


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
function Check_point(x,y)
     for name, check in pairs(house) do
          if x >= check.areaStartX and y >= check.areaStartY and x <= check.areaEndX and y <= check.areaEndY then
               return name
          end
     end
end

addhook("use","Use_")
function Use_(id,event,data,x,y)
     local usgn = player(id, "usgn")
     local house_name = Check_point(x,y)


     local name = {}
     for k,v in pairs(house) do
          name = v[k]
     end
     local e = entity(x,y,"name")
     local b = '..house[house_name].button..'
     if Exists(house_name) then
               if e == b  then
                              if house.owner[name] == usgn then          
                                        house[name].owner = 0
                                        parse("trigger "..house[name].button)
                                        parse("sv_msg  ©255000255"..name.." is free now")     
                                        house[house_name].owner = usgn     
                                        parse("trigger "..house[house_name].button)
                                        parse("sv_msg ©255000255"..player(id,"name").." is owner of 2 "..name)
                              elseif house[house_name].owner ~= usgn then
                                        house[house_name].owner = usgn
                                        parse("sv_msg  ©255000255"..name)
                                        parse("sv_msg  ©255000255"..player(id,"name").." is owner of "..house_name)
                                        parse("trigger "..house[house_name].button)
                              end
               
               end
               
     end
end
20.11.12 02:46:23 am
Up
kalis
User
Offline Off
Nothing has changed in the script?
20.11.12 03:08:14 am
Up
UltraX
BANNED
Offline Off
user kalis has written:
Nothing has changed in the script?


changed...
20.11.12 03:14:21 am
Up
kalis
User
Offline Off
where? , i didn't see any change !
20.11.12 03:38:44 am
Up
Starkkz
Moderator
Offline Off
user kalis has written:
where? , i didn't see any change !


Second script on line 20, he bugged it. Also what's the point of name variable? It's being useless, you should use house_name instead.
lol
20.11.12 11:51:41 am
Up
kalis
User
Offline Off
@ultrax
wrong change !
@starkkz

variable "name" to the test in the houses if players got 2 or more houses, old houses that players got will be return to no one ( I mean ,house will be "free" )
edited 1×, last 20.11.12 12:06:00 pm
20.11.12 12:23:54 pm
Up
Starkkz
Moderator
Offline Off
user kalis has written:
@ultrax
wrong change !
@starkkz

variable "name" to the test in the houses if players got 2 or more houses, old houses that players got will be return to no one ( I mean ,house will be "free" )


Right, but it doesn't make much sense mixing two different scripts, it will only make bugs. You should make separately a function that checks every house's owner, and if the owner is offline then you can set a free slot for those houses.
lol
20.11.12 12:39:32 pm
Up
kalis
User
Offline Off
ok , you understood me !
Can you help me to make it ?
here my code :
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
function check_Owned(name)
     if Exists(name) then
          for a = 1,#house do
               for b = 1,#house do
                    if a ~= b then
                         if house[a].owner == house[b].owner then
                              house[a].owner = 0 or house[b].owner = 0
                         end
                    end
               end
          end          
     end
end

but , few errors , this house may be new house player owned !

My new code :
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
addhook("use","Use_")
function Use_(id,event,data,x,y)
     local usgn = player(id, "usgn")
     local house_name = Check_point(x,y)

     if Exists(house_name) then
               if entity(x,y,"name") == ""..house[house_name].button..""  then
                              if house[house_name].owner == 0 then
                                        house[house_name].owner = usgn
                                        parse("sv_msg  ©255000255"..player(id,"name").." is owner of "..house_name)
                                        parse("trigger "..house[house_name].button)
                              end
                    for v, k in pairs(house) do
                              if v ~= "..house_name.." then
                                   if house[v].owner == house[house_name].owner then
                                        if house[v].owner > 0 then
                                             house[v].owner = 0
                                             parse("sv_msg House : "..v.." is free")

                                        end
                                   end

                              end
                    end     

               end


     end

end

can some one help me to fix ?
script still error!
edited 1×, last 23.11.12 05:12:18 am
To the start Previous 1 Next To the start