• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

House system

Amiroslo

Excellent OT User
Joined
Jul 28, 2009
Messages
6,768
Solutions
5
Reaction score
769
Hello,
I want a system that when u press on X item u own a house. for ex.
I have 8 big houses, no one can buy them only who got the X item, when u got the X item, u right click it and u get one of the 8houses and it says, Congratulation, Now you own Big House #1. the the rune dissapers. if another one got this item and right click it he get house #2 cuz 1 is no more there. and when all houses r gone, and someone got the X item and press it, it says: Sorry, There are no more big houses PLEASE CONTACT THE ADMIN.

rep++
 
Lua:
local t = {
	a = {
		[0] = {x="x", y="y", z="z"},
		[1] = {x="x", y="y", z="z"},
		[2] = {x="x", y="y", z="z"},
		[3] = {x="x", y="y", z="z"},
		[4] = {x="x", y="y", z="z"},
		[5] = {x="x", y="y", z="z"},
		[6] = {x="x", y="y", z="z"},
		[7] = {x="x", y="y", z="z"}
	},
	s = 1002
}
function onUse(cid, item, fromPositio, itemEx, toPosition)
	if getGlobalStorageValue(t.s) > #t.a then
		doPlayerSendTextMessage(cid, 21, "Sorry, There are no more big houses PLEASE CONTACT THE ADMIN.")
	else
		doPlayerSendTextMessage(cid, 21, "Congratulations! You've won "..getHouseName(getHouseFromPos(t.a.getGlobalStorageValue(t.s))).." which is located in "..getHouseTown(getHouseFromPos(t.a.getGlobalStorageValue(t.s))))
		setHouseOwner(getHouseFromPos(t.a.getGlobalStorageValue(t.s)), getPlayerGUIDByName(getCreatureName(cid)))
		setGlobalStorageValue(t.s, getGlobalStorageValue(t.s)+1)
	end
return TRUE
end
 
Last edited:
[1] = {x="x", y="y", z="z"},
[2] = {x="x", y="y", z="z"},
[3] = {x="x", y="y", z="z"},
[4] = {x="x", y="y", z="z"},
[5] = {x="x", y="y", z="z"},
[6] = {x="x", y="y", z="z"},
[7] = {x="x", y="y", z="z"},
[8] = {x="x", y="y", z="z"}
},
s = 1002
the pos x y z, should i be the door pos or 1sqm infront of door, and what is the s = 1002?
 
I added the file to the actions folder and in actions.xml
<action itemid="2356" event="script" value="XXX.lua"/>

but it aint working, i cant open my console, its compilcated so nvm, but can u check the script and see whats wrong?
im using 0.3.6pl1
 
@bogart script

You need to put the "local a = blablabla" before the if statement or within the else statement as you can see it is now a local variable and when you put it in the if block then it is only available there (AFAIK).
 
@bogart script

You need to put the "local a = blablabla" before the if statement or within the else statement as you can see it is now a local variable and when you put it in the if block then it is only available there (AFAIK).

Oh yeah, my bad.
 
Code:
[Error - Action Interface] 
data/actions/scripts/AOD/donhouse.lua:onUse
Description: 
data/actions/scripts/AOD/donhouse.lua:18: attempt to call field 'getGlobalStorageValue' (a nil value)
stack traceback:
	data/actions/scripts/AOD/donhouse.lua:18: in function <data/actions/scripts/AOD/donhouse.lua:14>
 
try this ?
Lua:
local t = {
	a = {
		[-1] = {x="x", y="y", z="z"},
		[0] = {x="x", y="y", z="z"},
		[1] = {x="x", y="y", z="z"},
		[2] = {x="x", y="y", z="z"},
		[3] = {x="x", y="y", z="z"},
		[4] = {x="x", y="y", z="z"},
		[5] = {x="x", y="y", z="z"},
		[6] = {x="x", y="y", z="z"}
	},
	s = 1002
}
function onUse(cid, item, fromPositio, itemEx, toPosition)

	if getStorage(t.s) > #t.a then
		doPlayerSendTextMessage(cid, 21, "Sorry, There are no more big houses PLEASE CONTACT THE ADMIN.")
	else
		local house = getHouseFromPos(t.a[getStorage(t.s)])
		doPlayerSendTextMessage(cid, 21, "Congratulations! You've won "..getHouseName(house).." which is located in "..getHouseTown(house))
		setHouseOwner(house, getPlayerGUIDByName(getCreatureName(cid)))
		doSetStorage(t.s, getStorage(t.s)+1)
	end
	
return true
end
 
Last edited:
Code:
[Error - Action Interface] 
data/actions/scripts/AOD/donhouse.lua:onUse
Description: 
attempt to index a nil value
stack traceback:
	[C]: in function 'getHouseFromPos'
	data/actions/scripts/AOD/donhouse.lua:19: in function <data/actions/scripts/AOD/donhouse.lua:14>
 
Back
Top