Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local command = "#roll"; -- command used
- local roll_item_ID = 60030; -- id of the roll item
- local ItemName = GetItemLink(roll_item_ID);
- local cost = 1;
- local remove_roll_item_delay = 100;
- local Item_Drops = { -- {chance_Value {item_id_1, item_id_2, item_id_3, item_id_4, item_id_5....}},
- [1] = {60,{49917, 45629}}, -- green 60% deop rate.
- [2] = {30,{51997, 48945}}; -- blue 30% drop chance.
- [3] = {10,{48737, 48738}}; -- purple 10% drop chance.
- };
- local time = tonumber(os.time());
- math.randomseed(time*time);
- local function RemoveItemRollItem(event, _, _, player)
- player:RemoveItem(roll_item_ID, cost)
- end
- local function ItemRoll(event, player, msg, Type, lang)
- if(msg == command)then
- if(player:HasItem(roll_item_ID, cost) == false)then
- player:SendBroadcastMessage("You need "..cost.." of "..ItemName..".");
- end
- if(player:HasItem(roll_item_ID, cost))then
- local roll = math.random(1, 100);
- local chance = nil;
- local comp = 0;
- for comp = 1, #Item_Drops do
- if(roll <= Item_Drops[comp][1])then
- chance = comp;
- end
- end
- if(chance == nil)then
- ItemRoll(event, player, msg, Type, lang);
- end
- if(chance)then
- local item = math.random(1, #Item_Drops[chance][2]);
- if(player:AddItem(Item_Drops[chance][2][item], 1)==true)then
- player:RegisterEvent(RemoveItemRollItem, remove_roll_item_delay, 1, player);
- end
- end
- end
- return false;
- end
- end
- RegisterPlayerEvent (18, ItemRoll)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement