• 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++
 
Try again, as I said, I doubt it'd work :3

[Error - LuaScriptInterface::loadFile] data/actions/scripts/AOD/donhouse.lua:35: 'end' expected (to close 'function' at line 25) near 'endend'
[Warning - Event::loadScript] Cannot load script (data/actions/scripts/AOD/donhouse.lua)
data/actions/scripts/AOD/donhouse.lua:35: 'end' expected (to close 'function' at line 25) near 'endend'
 
Try
Lua:
local a = {   -- A Position in each house.
			{x=0, y=0, z=0},
			{x=0, y=0, z=0},
			{x=0, y=0, z=0},
			{x=0, y=0, z=0},
			{x=0, y=0, z=0},
			{x=0, y=0, z=0},
			{x=0, y=0, z=0}

	}

--[[Script]]--
function getPlayersByAccount(id)
	local f = db.getResult("SELECT `id` FROM `players` WHERE `account_id` = "..id..";")
	local players = {}
	if f:getID() ~= -1 then
		repeat
			table.insert(players, f:getDataInt("id"))
		until not f:next()
		f:free()
	end
	return players
end

function accountOwnHouse(id)
	local players, haveHouse = getPlayersByAccount(id), false
	for _,ids in ipairs(players) do
		if getHouseByPlayerGUID(ids) ~= nil then
			haveHouse = true
			break
		end
	end
	return haveHouse
end
function getFreeHouse()
	for _,housePos in ipairs(a) do
		local house = getHouseFromPos(housePos)
		if getHouseOwner(house) == 0 then
			return house
		end
	end
	return false
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local house = getFreeHouse()
	if not house then
		doPlayerSendTextMessage(cid, 21, "Sorry, There are no more big houses PLEASE CONTACT THE ADMIN.")
		return true
	end
	if accountOwnHouse(getPlayerAccountId(cid)) then
		doPlayerSendTextMessage(cid, 21, "Sorry, This account already owns a house.")
		return true
	end
	doPlayerSendTextMessage(cid, 21, "Congratulations! You've won "..getHouseName(house).." which is located in "..getTownName(getHouseTown(house)).." town.")
	setHouseOwner(house, getPlayerGUIDByName(getCreatureName(cid)))
	
	return true
end
 
B4 testing: Looks like its gonna work :D
After Testing: It works, but i want that u cant buy those houses with !buyhouse, u can only get it by that item!
 
Last edited:
Back
Top