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

Script Problem rep+++

Tibiamakers

yourolist.com
Joined
May 24, 2010
Messages
1,377
Reaction score
97
Location
España
Someone can fix this script? i want that using the item 2157 [token] have a 25% to win 1 cc [ item id 2160 ]

PHP:
function onUse(cid, item, frompos, item2, topos)
if item2.itemid == 8895 and
doPlayerRemoveItem (cid,2157,1) == 1 then
rand = math.random(1,2000)
if rand < 20 then
doPlayerRemoveItem (cid,2157,1)
doPlayerSendTextMessage(cid,9,"Maybe next time...")
doSendMagicEffect(topos,26)
doPlayerRemoveItem(cid,2160,4)
elseif rand >1100 and rand <1400 then
doPlayerRemoveItem(cid,2160,3)
doSendMagicEffect(topos,26)
doPlayerSendTextMessage(cid,9,"Maybe next time...")
elseif rand >300 and rand <600 then
doPlayerAddItem(cid,2160,4)
doSendMagicEffect(topos,26)
doPlayerSendTextMessage(cid,9,"You Win!.")
elseif rand >700 and rand <1000 then
doPlayerAddItem(cid,2160,3)
doSendMagicEffect(topos,26)
doPlayerSendTextMessage(cid,9,"You win!.")
end
else
doPlayerSendCancel(cid, "You need one token to play!.")
end
return 1
end

the problem is that the script stoles you 1 token but never gives you money.


Thanks for help rep++
 
Lua:
function onUse(cid, item, frompos, item2, topos) 
	if item.itemid == 2157 then
		if math.random(100) <= 25 then
			doPlayerAddItem(cid, 2160, 1)
			doPlayerSendTextMessage(cid, 9, "Congratulations!")
		else
			doPlayerSendTextMessage(cid,9,"Try again!") 
		end
	end
end

?
 
Code:
function onUse(cid, item, frompos, item2, topos) 
        if item.itemid == 2157 then
                if math.random(100) <= 25 then
                        doPlayerAddItem(cid, 2160, 1)
                        doPlayerSendTextMessage(cid, 9, "Congratulations!")
                        doPlayerRemoveItem(cid, 2157,1)
                else
                        doPlayerSendTextMessage(cid,9,"Try again!") 
                end
        end
end
 
Code:
function onUse(cid, item, frompos, item2, topos) 
	if math.random(100) <= 25 then
			doPlayerAddItem(cid, 2160, 1)
			doPlayerSendTextMessage(cid, 9, "Congratulations!")
			doRemoveItem(item.uid, 1)
	else
			doPlayerSendTextMessage(cid, 9, "Try again!") 
	end
end
 
Code:
function onUse(cid, item, frompos, item2, topos) 
	if math.random(100) <= 25 then
			doPlayerAddItem(cid, 2160, 1)
			doPlayerSendTextMessage(cid, 9, "Congratulations!")
			doRemoveItem(item.uid, 1)
	else
			doPlayerSendTextMessage(cid, 9, "Try again!") 
	end
end
With this players will always win after some uses :blink:

Lua:
function onUse(cid, item, frompos, item2, topos) 
	if math.random(100) <= 25 then
			doPlayerAddItem(cid, 2160, 1)
			doPlayerSendTextMessage(cid, 9, "Congratulations! You won 1 crystal coin.")
			doRemoveItem(item.uid, 1)
	else
			doPlayerSendTextMessage(cid, 9, "You lost!") 
			doRemoveItem(item.uid, 1)
	end
  return TRUE
end

Btw. Slawkens: Whats the difference if I put return true and if I don't?
 
With this players will always win after some uses :blink:

Lua:
function onUse(cid, item, frompos, item2, topos) 
	if math.random(100) <= 25 then
			doPlayerAddItem(cid, 2160, 1)
			doPlayerSendTextMessage(cid, 9, "Congratulations! You won 1 crystal coin.")
			doRemoveItem(item.uid, 1)
	else
			doPlayerSendTextMessage(cid, 9, "You lost!") 
			doRemoveItem(item.uid, 1)
	end
  return TRUE
end

Btw. Slawkens: Whats the difference if I put return true and if I don't?

heh, I wasn't thinking properly when modifying that code.

About returns: when you return false then player will receive "Sorry, not possible" message, thats the whole difference but it applies only to actions. In talkactions however when you return false player will see words he posted (without knowing if such command exist or not). In movements it doesn't matter, and creatureevents are more complicated. Basically you return true always to inform that your script succeed, otherwise you return false.
 
here try this:
Code:
function onUse(cid, item, frompos, item2, topos) 
        if item2.itemid == 8895 then
                if math.random(100) <= 25 then
                        doPlayerAddItem(cid, 2160, 1)
                        doPlayerSendTextMessage(cid, 9, "Congratulations!")
                else
                        doPlayerSendTextMessage(cid,9,"Try again!") 
                end
		doRemoveItem(item.uid, 1)
        end
end
if you use the 'token' on the 'machine' then it will remove the token and
if his chance is smaller or equal 25 then he will earn the money.

Edit:
Is the token a 'use with' item or a simply 'use' item?
 
Back
Top