• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Help with adding percent chance function to the script.

Permamently

New Member
Joined
Jul 23, 2015
Messages
34
Reaction score
3
Hello, so I'm thinking about adding a percent chance to this script:
Code:
function onUse (cid, item, fromPosition, itemEx, toPosition)


if(itemEx.itemid == 7385) then
doRemoveItem(item.uid)
doTransformItem(itemEx.uid, 8209)
doSendMagicEffect(toPosition, 28)
return true
end
end
Could someone help me adding this?
This should work like this:
-30 % chance,
-if success the item is transformed from id 7385 to 8209(like in the script),
-if fail the item about number 2382 which is specified here:
Code:
<action itemid="2382" event="script" value="upgrade.lua"/>
should be removed.
Thanks in advance.
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(itemEx.itemid == 7385) and math.random(10) <= 3 then  
        doTransformItem(itemEx.uid, 8209)
        doSendMagicEffect(toPosition, 28)
    else
        doRemoveItem(item.uid)
    end
    return true
end
Try this
 
Back
Top