House System ( Starkkz script )
10 replies



19.11.12 08:05:19 am
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 :
here is script :
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
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
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
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
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

in line 15
Code:
1
if house[name].owner == usgn then
Code:
1
attempt to index field '?' (a nil value)

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
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
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
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
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

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.
@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" )
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


@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" )
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.
ok , you understood me !
Can you help me to make it ?
here my code :
but , few errors , this house may be new house player owned !
My new code :
can some one help me to fix ?
script still error!
Can you help me to make it ?
here my code :
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
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
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
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
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




