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

Cash item

kamilcioo

Veteran OT User
Joined
Jul 25, 2008
Messages
979
Solutions
1
Reaction score
291
I need script when you use item id 11735 you will get from 25cc to 50cc.
 
Did u mean item id 1735?

actions.xml

Code:
<action itemid="1735" event="script" value="ccadd.lua"/>

ccadd.lua :

Code:
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
 
Last edited:
In actions.xml:
Code:
<action itemid="1735" event="script" value="addcrystalcoin.lua"/>

Select one of the scripts below and save it as 'addcrystalcoin.lua':
  1. Adds the item if the player has enough cap:
    Code:
    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
  2. Adds the item without checking the player's cap:
    Code:
    function onUse(cid, item, fromPosition, itemEx, toPosition)
    		doTransformItem(item.uid, 2160, math.random(25, 50))
    	return true
    end
  3. Can only use it one time/Checks player cap:
    Code:
    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
  4. Can only use it one time/Ignores player cap:
    Code:
    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
 
Last edited:
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..
 
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..

Fixed.
 
Back
Top