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

rune

Sir Islam

Never Give Up
Joined
Jun 6, 2008
Messages
504
Solutions
1
Reaction score
116
Location
Suez , Egypt
i need rune make 30 % chance to on or fail to take this Storage xxxx

and when on player say on when fail player say fail

reb ++
 
I've made it like an action, to use on other players or on yourself.

local config = {storage = 123, chance = 30}

function onUse(cid, item, frompos, item2, topos)
if isPlayer(item2.uid) then
if getPlayerStorageValue(item2.uid, config.storage) == 1 then
doPlayerSendCancel(cid, "This player is already on.")
elseif math.random(1, 100) <= config.chance then
setPlayerStorageValue(item2.uid, config.storage, 1)
doSendAnimatedText(topos, "On!", COLOR_GREEN)
else
doSendAnimatedText(topos, "Fail!", COLOR_RED)
end
else
doPlayerSendCancel(cid, "You must use it on a player.")
end
return true
end
 
Code:
local config = {storages = {[1]=123,[2]=124}, chance = 30, time = os.time()}

 function onUse(cid, item, frompos, item2, topos)
		 if getPlayerStorageValue(cid, config.storages[1]) == 1 then 
			 doPlayerSendCancel(cid, "You're already on.")
		 elseif math.random(1, 100) <= config.chance then
			 setPlayerStorageValue(cid, config.storages[1], 1)
			 setPlayerStorageValue(cid, config.storages[2], time + 60)
			 doSendAnimatedText(topos, "On!", COLOR_GREEN)
			 addEvent(function()
				 if cid and isCreature(cid) then
					 setPlayerStorageValue(cid, config.storages[1], -1)
				 end
			 end, 60 * 1000)
		 else
			doSendAnimatedText(topos, "Fail!", COLOR_RED)
		 end
	 doRemoveItem(item.uid, 1) -- <-- if it doesnt work, try doChangeTypeItem(item.uid, item.type - 1)
	 return true
 end
 
 -----------------------------------------------------------------------------
 
 local config = {storages = {[1]=123,[2]=124}, time = os.time()}
 
 function onLogin(cid)
		if getPlayerStorageValue(cid, config.storages[2]) - time <= 0 then
			setPlayerStorageValue(cid, config.storages[1], -1)
		end
	return true
 end
 
Back
Top