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

Solved Chance to receive an item by clicking and then teleport?

Progenosis

Member
Joined
Sep 6, 2011
Messages
131
Reaction score
18
What I want is to put at the end of a quest a fountine (or any other non moveable item) and if you give click to it there's a chance to receive one item or not, wheter you get it or the player teleports to temple after doing click on it. How can I make this?
Anyone could help me?
 
This is a request mate, this is the wrong section

but i will do this for you... fine, i will make this "a script that when player have some storage value and uses certain object it will have a 50% chance to receive an item, if the player receive it will teleport to temple, if not will get teleported to but with a failure message

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
  
 local storage = xxxx --Storage value of the quest done
 local object = xxxx --Itemid of the object
 local uni = xxxx --uniqueId of the object
 local temple = {x=429, y=368, z=7} --Temple position
 local success = "You got the reward" --Got the item message
 local fail = "You was unlucky and don't got anything" --fail message
 local chance = 50 --Chance percentage, now 50%
 local reward = xxxx --Itemid of the reward
 local ammount = 1 --Numbers of items to get, in case that is stackable
 local done = "You already try to get this prize" --Message if you try to take again the prize
 local doquest = "You need first finish the quest" --Message if you havent finish the preview quest
 
 if getPlayerStorageValue(cid, storage) == 1 and item.uid == uni and itemEx.itemid == object then
	local chance1 = math.random(1,100)
	if chance1 > chance then
		doPlayerSendTextMessage(cid, 22, fail)
		doTeleportThing(cid, temple)
		doSetPlayerStorageValue(cid, storage, 2)
	else
		doPlayerSendTextMessage(cid, 22, success)
		doTeleportThing(cid, temple)
		doSetPlayerStorageValue(cid, storage, 2)
		doPlayerAddItem(cid, reward, ammount)
		end
	else
	if getPlayerStorageValue(cid, storage) < 1 then
		doPlayerSendCancel(cid, doquest)
		end
	else
	if getPlayerStorageValue(cid, storage) > 1 then
		doPlayerSendCancel(cid, done)
		end
end
return true
end

thats the lua file, and then put this on actions

Code:
<action uniqueid="xxxx" event="script" value="quests/quest.lua"/>

on xxxx put the uniqueid code that you select and in value put the .lua file name, also read carefully the instructions of the script, and remember to put the uniqueid too in the map editor
 
Raiden, its seems like there'sa sintaxis error at the end of the script but I don't know where exactly, could you or someone please help me?

Here's the script I'm using

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
  
 local storage = 2625 --Storage value of the quest done
 local object = 2626 --Itemid of the object
 local uni = 1999 --uniqueId of the object
 local temple = {x=1000, y=1000, z=7} --Temple position
 local success = "Has logrado obtener la reliquia del gran mago!" --Got the item message
 local fail = "Al parecer la fortuna no está de tu lado, intenta en otra ocasión!" --fail message
 local chance = 5 --Chance percentage, now 5%
 local reward = 2625 --Itemid of the reward
 local ammount = 1 --Numbers of items to get, in case that is stackable
 local done = "Tu ya has obtenido la reliquia del mago" --Message if you try to take again the prize
 local doquest = "You need first finish the quest" --Message if you havent finish the preview quest
 
 if getPlayerStorageValue(cid, storage) == 1 and item.uid == uni and itemEx.itemid == object then
	local chance1 = math.random(1,100)
	if chance1 > chance then
		doPlayerSendTextMessage(cid, 22, fail)
		doTeleportThing(cid, temple)
		doSetPlayerStorageValue(cid, storage, 2)
	else
		doPlayerSendTextMessage(cid, 22, success)
		doTeleportThing(cid, temple)
		doSetPlayerStorageValue(cid, storage, 2)
		doPlayerAddItem(cid, reward, ammount)
		end
	else
	if getPlayerStorageValue(cid, storage) < 1 then
		doPlayerSendCancel(cid, doquest)
		end
	else
	if getPlayerStorageValue(cid, storage) > 1 then
		doPlayerSendCancel(cid, done)
		end
end
return true
end

- - - Updated - - -

Solved, "end" was missing at the end of the script to close a function

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
  
 local storage = 2625 --Storage value of the quest done
 local object = 2626 --Itemid of the object
 local uni = 1999 --uniqueId of the object
 local temple = {x=1000, y=1000, z=7} --Temple position
 local success = "Has logrado obtener la reliquia del gran mago!" --Got the item message
 local fail = "Al parecer la fortuna no está de tu lado, intenta en otra ocasión!" --fail message
 local chance = 5 --Chance percentage, now 5%
 local reward = 2625 --Itemid of the reward
 local ammount = 1 --Numbers of items to get, in case that is stackable
 local done = "Tu ya has obtenido la reliquia del mago" --Message if you try to take again the prize
 local doquest = "You need first finish the quest" --Message if you havent finish the preview quest
 
 if getPlayerStorageValue(cid, storage) == 1 and item.uid == uni and itemEx.itemid == object then
	local chance1 = math.random(1,100)
	if chance1 > chance then
		doPlayerSendTextMessage(cid, 22, fail)
		doTeleportThing(cid, temple)
		doSetPlayerStorageValue(cid, storage, 2)
		else
		doPlayerSendTextMessage(cid, 22, success)
		doTeleportThing(cid, temple)
		doSetPlayerStorageValue(cid, storage, 2)
		doPlayerAddItem(cid, reward, ammount)
	end
else
	if getPlayerStorageValue(cid, storage) < 1 then
		doPlayerSendCancel(cid, doquest)
		else
	if getPlayerStorageValue(cid, storage) > 1 then
		doPlayerSendCancel(cid, done)
	end
end
return true
end
end
 
Back
Top