Hello,
I would like to present my very simple script, but with nice config :3
Not tested, but if someone really need this script, just post here if something wrong![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Greetings,
Erexo.
I would like to present my very simple script, but with nice config :3
Lua:
local list = {
{["id"] = 2160, ["name"] = "Crystal Coin", ["count"] = 1, ["chance"] = 25},
{["id"] = 2160, ["name"] = "Crystal Coin", ["count"] = 1, ["chance"] = 25},
{["id"] = 2160, ["name"] = "Crystal Coin", ["count"] = 1, ["chance"] = 25},
{["id"] = 2160, ["name"] = "Crystal Coin", ["count"] = 1, ["chance"] = 25},
{["id"] = 2160, ["name"] = "Crystal Coin", ["count"] = 1, ["chance"] = 25} -- <-- Remember to delete point from last one
}
local config = {
Effect = 2, --magic effect appears when player use item
Erexo_is_author = true,
chance_system_on = false
}
--[[
*Chance System*
If false, all items have same chance for roll
If true, get amount of chance's, then roll one of it, so if you set in first chance=5, in second=10 it will roll one number between 1 and 15, (so first have ~33% chance, and second ~66%)
]]--
--Script section
local sum = 0
function onUse(cid, item, frompos, item2, topos)
if (config.Erexo_is_author) then
if (chance_system_on) then
for j = 1, #list do
sum = sum + list[i].chance -- Idk += will works...
end
rand = math.random(1,sum)
sum = 0
for i = 1, #list do
if sum + list[i].chance <= rand then
doPlayerAddItem(cid, list[i].id, list[i].count)
doSendMagicEffect(getCreaturePosition(cid), config.Effect)
doPlayerSendTextMessage(cid,22, "You have recived " .. list[i].name .. ".")
doRemoveItem(item.uid, 1)
return true
else
sum = sum + list[i].chance
end
end
else
rand = math.random(1,#list)
doPlayerAddItem(cid, list[rand].id, list[rand].count)
doSendMagicEffect(getCreaturePosition(cid), config.Effect)
doPlayerSendTextMessage(cid,22, "You have recived " .. list[rand].name .. ".")
doRemoveItem(item.uid, 1)
return true
end
else
while(config.Erexo_is_author ~= true) do
print(":c")
end
end
return true
end
Not tested, but if someone really need this script, just post here if something wrong
Greetings,
Erexo.