kamilcioo
Veteran OT User
- Joined
- Jul 25, 2008
- Messages
- 977
- Solutions
- 1
- Reaction score
- 289
The system is configurable, you can add some option or just one:
The value in [ ] is unique id
yyyy - unique id
xxx - name of script
For example, you can make quest which gives only exp/money/items/storage or all of them at once!
For the player:addMoneyNpc(t.money) add this in global.lua
Lua:
local config = {
[31925] = {
storage = 31925,
storageValue = 1,
storageMessage = 'You have gained the access to one of the doors',
},
[31926] = {
backpackId = 1993,
itemsInside = {
{id = 2145, amount = 7}
},
money = 3500,
exp = 12000,
},
[31927] = {
money = 1500,
exp = 5000,
},
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local t = config[item.uid]
if t then
queststatus = getPlayerStorageValue(cid, item.uid)
if queststatus == -1 then
local player = Player(cid)
if t.backpackId and t.itemsInside then
local backpack = Container(doCreateItemEx(t.backpackId))
for i = 1, #t.itemsInside do
backpack:addItem(t.itemsInside[i].id, t.itemsInside[i].amount)
end
if player:addItemEx(backpack) ~= RETURNVALUE_NOERROR then
local weight = backpack:getWeight()
if player:getFreeCapacity() < weight then
local text = string.format('You have found a bag weighing %.2f oz. You have no capacity.', (weight / 100))
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, text)
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a bag, but you have no room to take it.')
end
return true
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a bag with items inside.")
end
if t.exp then
player:addExperience(t.exp)
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "You received "..t.exp.." experience.")
end
if t.money then
player:addMoneyNpc(t.money)
end
if t.storage and t.storageValue and t.storageMessage then
player:setStorageValue(t.storage, t.storageValue)
player:sendTextMessage(MESSAGE_INFO_DESCR, t.storageMessage)
end
setPlayerStorageValue(cid, item.uid, 1)
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have already used it!")
end
else
return false
end
return true
end
The value in [ ] is unique id
Lua:
<action uniqueid="yyyy" script="xxx.lua"/>
xxx - name of script
For example, you can make quest which gives only exp/money/items/storage or all of them at once!
For the player:addMoneyNpc(t.money) add this in global.lua
Lua:
function Player.addMoneyNpc(self, amount)
if type(amount) == 'string' then
amount = tonumber(amount)
end
local bankCount = self:getBankBalance()
self:setBankBalance(bankCount + amount)
self:sendTextMessage(MESSAGE_INFO_DESCR, ("%d gold was added to your bank account, your balance is now %d gold."):format(amount, self:getBankBalance()))
end