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

Gambling Script

Deisherooo

Server Creator
Joined
Jul 8, 2009
Messages
24
Reaction score
0
Location
USA
I would like a script for gambling~ Like you click a machine and it would take 10cc from your pocket and if you get lucky or w.e give you some good items, or money


Please help with this
 
Try this
Code:
local wins = {3515, 2897, 2893, 4018, 2371} -- Change to item ids of items you can win
local chance = 5 -- 20% chance to win
local cost = 10000
function onUse(cid, item, fromPosition, itemEx, toPosition)
local i = wins[math.random(1, #wins)]
	if doPlayerRemoveMoney(cid, cost) then
		if math.random(1, chance) == 1 then
			doPlayerAddItem(cid, i)
			doPlayerSendTextMessage(cid, 22, "You won a " .. getItemNameById(i) .. "!")
		else
			doPlayerSendTextMessage(cid, "You didn't win anything.")
		end
	else
		doPlayerSendCancel(cid, "You don't have enough money to gamble.")
	end
return true
end
 
The item can be whatever you want, just add an action id on the item in the mapeditor and register it in actions.xml with the same action

EDIT;
isn't it better to do the chance like this? Much better I in my opinion
Code:
local wins = {3515, 2897, 2893, 4018, 2371} -- Change to item ids of items you can win
local chance = 20 -- 20% chance to win
local cost = 10000
function onUse(cid, item, fromPosition, itemEx, toPosition)
local i = wins[math.random(1, #wins)]
	if doPlayerRemoveMoney(cid, cost) then
		if math.random(1, 100) <= chance then
			doPlayerAddItem(cid, i)
			doPlayerSendTextMessage(cid, 22, "You won a " .. getItemNameById(i) .. "!")
		else
			doPlayerSendTextMessage(cid, "You didn't win anything.")
		end
	else
		doPlayerSendCancel(cid, "You don't have enough money to gamble.")
	end
return true
end
 
just add doSendMagicEffect(getThingPos(cid), effect_number) below/after each doPlayerSendTextMessage

uhh but when i use the item with the action id it sends no effect i just see the money dissapears and the items i get so cant you make a script for me that makes a cool effect and says "Bad luck , you lost!" when you loose and "Awesome, you won!" when you win?:)

Thanks in advance Yours Tobbe
 
Back
Top