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

Action Bar of Gold = Use to give Gold?

Was this helpful?

  • Yes!

    Votes: 4 40.0%
  • No.

    Votes: 6 60.0%

  • Total voters
    10

God Mythera

Veteran OT User
Joined
Aug 11, 2012
Messages
2,048
Solutions
2
Reaction score
256
Location
United States
gy5ejt6.png

data/actions/actions.xml
Code:
<action itemid="15515" script="other/barofgold.lua"/>

data/actions/scripts/barofgold.lua
Code:
local config = {
{ rate = 1, item = 2152, count = { min = 5, max = 25 }}
}

local sumOfRate = 0

for i,v in ipairs(config) do
sumOfRate = sumOfRate + v.rate
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have received some gold.")
   
local rand = math.random(1, sumOfRate)

local subSum = 0
local exactItem = nil
for i,v in ipairs(config) do
if (subSum > rand) then
if (i > 1) then
exactItem = i-1
end
break
end
subSum = subSum + v.rate
if (subSum >= rand) then
exactItem = i
break
end
end

if (config[exactItem].count.const ~= nil) then
doPlayerAddItem(cid, config[exactItem].item, config[exactItem].count.const)
else
doPlayerAddItem(cid, config[exactItem].item, math.random(config[exactItem].count.min, config[exactItem].count.max))
end
doRemoveItem(item.uid, 1)
end
 
Back
Top