Add this directly under function onUseYou can add a option to remove item 1444 when use the machine?
Like a price to use the Machine
if getPlayerItemCount(cid, 1444) < 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You require 1 xxxxxxxxxx to use this slot machine.")
return true
end
doPlayerRemoveItem(cid, 1444, 1)
local winnable_items = {
-- {item_id, item_count, % chance}
{2148, 10, 90},
{2152, 5, 40},
{2160, 1, 10}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
for i = 1, #winnable_items do
local rand = math.random(100)
if rand <= winnable_items[i][3] then
doPlayerAddItem(cid, winnable_items[i][1], winnable_items[i][2], true)
end
end
return true
end
There's like 20+ different ways to create the slot machine based on the info you gave.
Here's the easiest version.
Lua:local winnable_items = { -- {item_id, item_count, % chance} {2148, 10, 90}, {2152, 5, 40}, {2160, 1, 10} } function onUse(cid, item, fromPosition, itemEx, toPosition) for i = 1, #winnable_items do local rand = math.random(100) if rand <= winnable_items[i][3] then doPlayerAddItem(cid, winnable_items[i][1], winnable_items[i][2], true) end end return true end
Add this directly under function onUseYou can add a option to remove item 1444 when use the machine?
Like a price to use the Machine
if getPlayerItemCount(cid, 1444) < 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You require 1 xxxxxxxxxx to use this slot machine.")
return true
end
doPlayerRemoveItem(cid, 1444, 1)
How put a message when player receive one item and how do chance to receive nothing ?Add this directly under function onUse
Lua:if getPlayerItemCount(cid, 1444) < 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You require 1 xxxxxxxxxx to use this slot machine.") return true end doPlayerRemoveItem(cid, 1444, 1)
How put a message when player receive one item and how do chance to receive nothing ?
I already said this previously.There's like 20+ different ways to create the slot machine based on the info you gave.
local config = {
chance_for_nothing = 50,
required_item = 1444,
winnable_items = {
{2148, 10, "gold coins"},
{2152, 5, "platinum coins"},
{2160, 1, "crystal coin"}
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerItemCount(cid, 1444) < 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You require 1 xxxxxxxxxx to use the slot machine.")
return true
end
doPlayerRemoveItem(cid, 1444, 1)
local rand = math.random(100)
if rand > config.chance_for_nothing then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Ding ding. Result: Nothing! :C")
return true
end
local reward = config.winnable_items
rand = math.random(#reward)
doPlayerAddItem(cid, reward[rand][1], reward[rand][2], true)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Ding ding. Result: " .. reward[rand][2] .. " " .. reward[rand][3] .. "! :D")
return true
end
Thanks man, sorry for the work(-‸ლ)
I remember why I stopped helping people now.
It's like you just refuse to even help yourself.
Me: Hey! Tell me what you want, and I'll make it.
You: I want words added to the script.
Me: Well.. that's not really explaining to me anything.. but uh.. just copy this line and change what you want.
Me: Anything else? Just explain what you want to happen.
You: Yeah.. I want some other words added to the script in another spot.
Me: ???? (-‸ლ) Seriously?
Anyways.. enough ranting.
Here's what I assume you want. Since you refuse to actually explain it.
Lua:local config = { chance_for_nothing = 50, required_item = 1444, winnable_items = { {2148, 10, "gold coins"}, {2152, 5, "platinum coins"}, {2160, 1, "crystal coin"} } } function onUse(cid, item, fromPosition, itemEx, toPosition) if getPlayerItemCount(cid, 1444) < 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You require 1 xxxxxxxxxx to use the slot machine.") return true end doPlayerRemoveItem(cid, 1444, 1) local rand = math.random(100) if rand > config.chance_for_nothing then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Ding ding. Result: Nothing! :C") return true end local reward = config.winnable_items rand = math.random(#reward) doPlayerAddItem(cid, reward[rand][1], reward[rand][2], true) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Ding ding. Result: " .. reward[rand][2] .. " " .. reward[rand][3] .. "! :D") return true end