Gelio
Lua PHP C++ programmer
Player on your OTS are bored with buying house with !buyhouse? Do you want to add something new? Now buying house with commands is old! Now are house documents! Try it and check that you will get new players, and RPG level on your server will be much better.
Script
House documents is placed in 2 scripts:
1. Level which give you house document.
2. House document.
If you look on house document you will see owner of house and name of house. This text is changing by using script. Attention! To every house (without global storages reset) can be setten only one house document. If owner of house will lose it house is able to live only by last owner or other (by comends). Ok, let's go and add it to server:
First you need to add 2 files in data/actions/scripts:
house document.lua, add:
lever add document.lua and add:
And then to actions.xml, which is in folder data/actions add:
Now we need to put lever and set unique id to 1952. House document's ID is 1952. Every house document's action id is house id-100 of house it belongs to. Script was written full by me. I tested it on TFS 0.3.1.
Sorry for my english.
Waiting for comments,
Gelio
Script
House documents is placed in 2 scripts:
1. Level which give you house document.
2. House document.
If you look on house document you will see owner of house and name of house. This text is changing by using script. Attention! To every house (without global storages reset) can be setten only one house document. If owner of house will lose it house is able to live only by last owner or other (by comends). Ok, let's go and add it to server:
First you need to add 2 files in data/actions/scripts:
house document.lua, add:
Code:
-- House documents by Gelio
local cleanHouse = "yes" -- Does it clean house ("yes"/"no")
local payingForSQM = "no" -- Does player who want to buy house need to pay for all SQM that house got ("yes"/"no")
local goldForSQM = 200 -- How many gold you need to pay for every SQM in house if payingForSQM is set
function onUse(cid, item, frompos, item2, topos)
local houseID = item.actionid-100
local text = ""
local playerGUID = getPlayerGUID(cid)
local error = 0
if(item.actionid <= 100) then
text = text .. "That house document is not setted to any house. "
error = error+1
end
if(error == 0) then
if(getHouseByPlayerGUID(playerGUID) ~= nil) then
text = text .. "You have got one house and you can't got more. "
error = error+1
end
end
if(error == 0) then
if(getHouseOwner(houseID) == cid) then
text = text .. "You are now owner of this house. "
error = error+1
end
end
if(error == 0) then
if(payingForSQM == "yes") then
local price = goldForSQM * getHouseTilesSize(houseID)
if(getPlayerMoney(cid) < cena) then
text = text .. "To buy this house you need to have ".. price .." gold."
error = error+1
else
doPlayerRemoveMoney(cid,price)
end
end
if(error == 0) then
if(cleanHouse == "yes") then
cleanHouse(houseID)
end
setHouseOwner(houseID, playerGUID)
text = text .. "You have just bought house ".. getHouseName(houseID) .."."
doSetItemSpecialDescription(item.uid,"This is house document of house ".. getHouseName(houseID) .." and owner of this house is ".. getCreatureName(cid))
end
end
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,text)
return TRUE
end
Code:
-- House documents by Gelio
local itemID = 1952
function onUse(cid, item, frompos, item2, topos)
local houseID = getHouseByPlayerGUID(getPlayerGUID(cid))
if(houseID ~= nil and getGlobalStorageValue(houseID) == -1) then
local document = doPlayerAddItem(cid,itemID,1)
doSetItemActionId(akt,houseID+100)
doSetItemSpecialDescription(akt,"This is house document of house ".. getHouseName(houseID) .." and owner of this house is ".. getCreatureName(cid))
setGlobalStorageValue(houseID,1)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You have just get your house document. Don't lose it.")
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"House document for your house already exists or you don't have got a house.")
end
return TRUE
end
Code:
<action uniqueid="1952" script="lever add document.lua" />
<action itemid="1952" script="house document.lua" />
Sorry for my english.
Waiting for comments,
Gelio