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

Lua doSetUniqueID?

ziggy46802

Active Member
Joined
Aug 19, 2012
Messages
418
Reaction score
27
If I create an object, what is the script line for setting its unique ID?

Is it like doCreateItem(4144,1,cid)
dosetUniqueID(cid, 4144,10000)

Or how do I do this?

And yes I know I asked this in another thread but everyone acted stupid and wouldnt give me the right answer so I'm asking it AGAIN, this time straight forward so there is no confusion.
 
object.uid = XXXX

Remember, object has to be found/declared.
For example, object = getThingFromPos(pos)

I'm pretty sure that's how it works.
 
Well that makes sense, but how exactly do I script it? This is my script, as you see I want a large crystal to turn into a small crystal, then respawn as a "bigrock" with unique id of 4001.

Thank you so much though, we are one step closer to figuring this out.

Code:
function onUse(cid, item, frompos, item2, topos)

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


function goto(cid)
	addEvent(restore, 1000,5000, cid) --in 1 to 5 seconds go to "restore"
		return true
end



function restore(cid, storage)
		doRemoveItem(getTileItemById(posa, smallrock).uid)           --remove smallrock 
		doCreateItem(bigrock,posa)	                                 --create bigrock                          PROBLEM
object = getThingFromPos(posa)
		object.uid = 4001
			return true
end	




if item.itemid == bigrock then	                                    --if the rock is big then...
			doRemoveItem(getTileItemById(posa, bigrock).uid)        --remove the bigrock
			doCreateItem(smallrock,1,posa)                          --create smallrock
			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
 
i'm assuming you're trying to make this as some sort of mining script?
then it would be a bad idea to change the items unique id, as there is going to be more than one of them you should use:
LUA:
doSetItemActionId(uid, actionid)
to solve that problem.

another solution, instead of removing the big stone and creating a new little one you can use
LUA:
doTransformItem(uid, toitemid)
to transform the big rock into the little one without removing the items action id (again do not use unique id). of course then you would need another if statement in the onUse function to make sure item.id ~= smallrock.

hope this helps ^^
 
Alright, that sounds like a much better idea, but I'm having problems getting it to respawn.

Here is my script again:
Code:
function 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)


function goto(cid)
	addEvent(restore, 1000,5000, cid) --in 1 to 5 seconds go to "restore"
		return true
end



function restore(cid, storage)
		doTransformItem(item.uid, bigrock)
			return true
end	




if item.itemid == bigrock then	                                    --if the rock is big then...
			doTransformItem(item.uid, smallrock)
			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

I added doTransformItem(item.uid, bigrock) since (uid, bigrock) would not transform it, but now with item.uid, it goes into the small rock and does not respawn! Even if I put the transform into smallrock as item.uid and transform back as just doTrans(uid, bigrock) so how do I get it to go from small to big after using it?
 
Back
Top