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

[REQUEST] Donor Item To Buy House

Kibidon

New Member
Joined
Mar 4, 2009
Messages
132
Reaction score
1
Hello.

I want to have Donor only houses. I want to have it be so a certain item is available in item shop, you buy it, it comes to your character. You go in front of a house that is for sale, and you hit the item. The item disappears and the house is now that players.


Thank much!
will rep++



Kibi
 
Code:
function onSay(cid, words, param, channel)
	local donor = XXXX
	return words == "alana res" and getPlayerItemCount(cid, donor) > 0 and doRemoveItem(donor.uid) or doPlayerSendCancel(cid, "Sorry, you do not have the correct item.")
end
 
@Up,
Script goes into talkactions/scripts.

NO IDEA if this works, but try it.
In talkactions.xml, find this line and replace it.

Code:
<talkaction words="alana res" filter="word-spaced" event="function;script" value="houseBuy;donor_house.lua"/>
 
talkaction.cpp, buyHouse part, above house->isGuild()~:
Code:
	uint8_t itemCount = player->__getItemTypeCount(item_id, sub_type);
	if(itemCount < count)
	{
		player->sendCancel("gtfo");
		return false;
 	}
 
That did not work. Does anyone know a way to use lua, so when your in front of the door, right click the house token item, you then gain ownership of the house. It must also be sure to check that the house is vacant so other players cant use one on someones house and steal it.


Thanks!!
 
Something like this ..
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if not getConfigInfo('buyableAndSellableHouses') then
		return false
	end

	local house = getHouseFromPos(getCreatureLookPosition(cid))
	if not house or getTileThingByType(getCreatureLookPosition(cid), ITEM_TYPE_DOOR).uid < 1 then
		doPlayerSendCancel(cid, "You have to be looking at door of flat you would like to purchase.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		return true
	end

	if not getHouseInfo(house).guildHall then
		if getHouseByPlayerGUID(getPlayerGUID(cid)) then
			doPlayerSendCancel(cid, "You already rent another house.")
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
			return true
		end

		--[[ FIXME: Houses/account limit
		local accountHouses = getConfigInfo('housesPerAccount')
		if accountHouses > 0 and getHousesCount(getPlayerAccountId(cid)) >= accountHouses
			doPlayerSendCancel(cid, "You may own only " .. accountHouses .. " house" .. (accountHouses ~= 1 and "s" or "") .. " per account.")
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
			return true
		end]]

		if getConfigInfo('houseNeedPremium') and not isPremium(cid) then
			doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUNEEDPREMIUMACCOUNT)
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
			return true
		end

		local levelToBuyHouse = getConfigInfo('levelToBuyHouse')
		if getPlayerLevel(cid) < levelToBuyHouse then
			doPlayerSendCancel(cid, "You have to be at least Level " .. levelToBuyHouse .. " to purchase a house.")
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
			return true
		end
	else
		if getPlayerGuildId(cid) == 0 or getPlayerGuildLevel(cid) ~= GUILDLEVEL_LEADER then
			doPlayerSendCancel(cid, "You have to be at least a guild leader to purchase a hall.")
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
			return true
		end
		
		-- FIXME: Only 1 GH per guild
	end

	if getHouseOwner(house) > 0 then
		doPlayerSendCancel(cid, "This flat is already owned by someone else.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		return true
	end

	setHouseOwner(house, getPlayerGUID(cid))
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have successfully bought this " .. (getHouseInfo(house).guildHall and "hall" or "house") .. ", remember to leave money at " .. (getHouseInfo(house).guildHall and "guild owner " or "") .. (getConfigInfo('buyableAndSellableHouses') and "bank or " or "") .. "depot of this town for rent.")

	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
	return true
end
 
Back
Top