<action itemid="1735" event="script" value="ccadd.lua"/>
function onUse(cid, item, fromPosition, itemEx, toPosition)
local ccrand = {25, 50} -- add player from 25cc to 50cc
local onetime = false -- how many times player can use item
local storage = 55551
local cap = getItemWeightById(2160, ccrand[2])
if getPlayerStorageValue(cid, storage) ~= 1 or onetime == false then
if getPlayerFreeCap(cid) >= cap then
doPlayerAddItem(cid, 2160, math.random(ccrand[1], ccrand[2]))
setPlayerStorageValue(cid, storage, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you do not have enough cap.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you can use this one time.")
end
return true
end
<action itemid="1735" event="script" value="addcrystalcoin.lua"/>
function onUse(cid, item, fromPosition, itemEx, toPosition)
local random = math.random(25, 50)
local capacity = getItemWeightById(2160, random)
if getPlayerFreeCap(cid) >= capacity then
doTransformItem(item.uid, 2160, random)
else
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHCAPACITY)
end
return true
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
doTransformItem(item.uid, 2160, math.random(25, 50))
return true
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local random = math.random(25, 50)
local capacity = getItemWeightById(2160, random)
if(getPlayerStorageValue(cid, 55551) <= 0) then
if getPlayerFreeCap(cid) >= capacity then
doTransformItem(item.uid, 2160, random)
setPlayerStorageValue(cid, 55551, 1)
else
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHCAPACITY)
end
else
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
end
return true
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(getPlayerStorageValue(cid, 55551) <= 0) then
doTransformItem(item.uid, 2160, math.random(25, 50))
setPlayerStorageValue(cid, 55551, 1)
else
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
end
return true
end
local random = math.random(25, 50)
local capacity = getItemWeightById(2160, random)
function onUse(cid, item, fromPosition, itemEx, toPosition)
Fail @ random..
I wouldn't call that random because player will get same amount each time..
Code:local random = math.random(25, 50) local capacity = getItemWeightById(2160, random) function onUse(cid, item, fromPosition, itemEx, toPosition)
Fix:
put this line:
local random = math.random(25, 50)
after onUse line..