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

Solved adding math.random

ziggy46802

Active Member
Joined
Aug 19, 2012
Messages
418
Reaction score
27
Here is my script
Code:
unction onUse(cid, item, frompos, item2, topos)

bigrock = 8634
smallrock = 8638
rock = 4001
posa = {x=1094,y=1060,z=6}
object = getThingFromPos(posa)
rand = math.random(0,10000)
rando = math.random(1,2)


function goto(cid)
	addEvent(restore, rand,rand , cid) --in 1 to 5 seconds go to "restore"
	if rando >= 1 then
		doRemoveItem(cid, 2553)
			doCreatureSay(cid, "Uh oh, your pick broke!", TALKTYPE_ORANGE_1) --5% pick breaks
			return false
		end	
		return true
end



function restore(cid, item1, item2)
		doRemoveItem(getTileItemById(posa, smallrock).uid)           --remove smallrock 
		doCreateItem(bigrock,posa)	                                 --create bigrock                          PROBLEM
		doSetItemActionId(getTileItemById(posa, bigrock).uid, 4001)
			return true
end	




if item.itemid == bigrock and getPlayerItemCount(cid,2553) >= 1 and getPlayerSkill(cid, SKILL_FIST) >= 1
then                                   
			doPlayerAddSkillTry(cid, SKILL_FIST, 10)
			doRemoveItem(getTileItemById(posa, bigrock).uid)
			doCreateItem(smallrock,posa)
			addEvent(goto, 1, 5, cid)                               --jump to "goto"
			doSendMagicEffect(getPlayerPosition(cid), 13)	        --send magic effect
			doCreatureSay(cid, "You mined it!", TALKTYPE_ORANGE_1)	--say "You mined it!"
	
			
				return true
			end
				return true
			end

Now why does the random time work but my pick never breaks, I can spam mining for 20 times and it wont break but its 100% chance to break, it dont make sense!
 
Last edited:
LUA:
if rando >= 1 then
	doRemoveItem(item.uid, 1)
	doCreatureSay(cid, "Uh oh, your pick broke!", TALKTYPE_ORANGE_1) --5% pick breaks
	return false
end
 
It seems like that would work but here is my script

Code:
function goto(cid, item)
	addEvent(restore, rand,rand , cid) --in 1 to 5 seconds go to "restore"
if chance >= 1 then
	doPlayerRemoveItem(cid, 2553, 1)
doCreatureSay(cid, "Uh oh, your pick broke!", TALKTYPE_ORANGE_1) --5% pick breaks
		return false
end
	return true
end
I know its not item.uid, but anyway, I was just testing it so 100% it would remove but it does not remove it, I get funky errors in the console saying player not found.


I got it to work no worries
 
Last edited:
Back
Top