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

Lua Create Item problem

ziggy46802

Active Member
Joined
Aug 19, 2012
Messages
418
Reaction score
27
Heres my actions.xml

Code:
	<!-- Light Blue Crystals -->
	<action actionid="4001" script="lightblue1.lua"/>
	<action actionid="4002" script="lightblue2.lua"/>

Here is lightblue1.lua
Code:
function onUse(cid, item, frompos, item2, topos)

local bigrock = 8634
local smallrock = 8638
pos4001 = {x=999,y=998,z=7}                                                                                        	--set position	
local chance = math.random(0,100000)
local brake = math.random(0,100)
mining = (getPlayerSkill(cid, FIST_SKILL) * 3)

function goto(cid, item)
	--addEvent(restore, (1000 * 60 * 54),(1000 * 60 * 131) , cid) 
	addEvent(restore, 5000,10000, cid) --test mode
end

function restore(cid, item1, item2)
	doRemoveItem(getTileItemById(pos4001, smallrock).uid)         
		addEvent(create, 1, cid)
end

function create(cid, item)
	doCreateItem(bigrock,pos4001)
		addEvent(set, 1, cid)
	end
	
function set(cid, item)
	doItemSetAttribute(getTileItemById(pos4001, bigrock).uid, "aid", 4001)
end

if item.itemid == bigrock and getPlayerItemCount(cid,2553) >= 1 then                               
			doPlayerAddSkillTry(cid, SKILL_FIST, 10)
			doRemoveItem(getTileItemById(pos4001, bigrock).uid)
			doCreateItem(smallrock,pos4001)	
			addEvent(goto, 1, cid)                               
			doSendMagicEffect(getPlayerPosition(cid), 13)
			
if brake > mining then
	doPlayerRemoveItem(cid, 2553, 1)
	doCreatureSay(cid, "Well shit, your fuckin pick broke man.", TALKTYPE_ORANGE_1)
		return false
	end	

if chance >= 0 and chance <= 50000 then
	doPlayerAddItem(cid, 2255,1)
	doCreatureSay(cid, "You found some trashy copper.", TALKTYPE_ORANGE_1)	
		return false
	end

if chance >= 50001 and chance <= 80000 then
	doPlayerAddItem(cid, 2254,1)
	doCreatureSay(cid, "You found some dirty copper.", TALKTYPE_ORANGE_1) 
		return false
	end

if chance >= 80001 and chance <= 95000 then
	doPlayerAddItem(cid, 2253,1)
	doCreatureSay(cid, "You found some dull copper.", TALKTYPE_ORANGE_1) 
		return false
	end
	
if chance >= 95001 and chance <= 100000 then
	doPlayerAddItem(cid, 2252,1)
	doCreatureSay(cid, "You found some decent copper.", TALKTYPE_ORANGE_1) 	
		return false
	end	
		return true
	end
		return true
	end

and here is lightblue2.lua

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

local bigrock = 8634
local smallrock = 8638
pos4002 = {x=1003,y=997,z=7}                                                                                        	--set position	
local chance = math.random(0,100000)
local brake = math.random(0,100)
mining = (getPlayerSkill(cid, FIST_SKILL) * 3)

function goto(cid, item)
	--addEvent(restore, (1000 * 60 * 54),(1000 * 60 * 131) , cid) 
	addEvent(restore, 5000,10000, cid) --test mode
end

function restore(cid, item1, item2)
	doRemoveItem(getTileItemById(pos4002, smallrock).uid)         
		addEvent(create, 1, cid)
end

function create(cid, item)
	doCreateItem(bigrock,pos4002)
		addEvent(set, 1, cid)
	end
	
function set(cid, item)
	doItemSetAttribute(getTileItemById(pos4002, bigrock).uid, "aid", 4002)
end

if item.itemid == bigrock and getPlayerItemCount(cid,2553) >= 1 then                                   
			doPlayerAddSkillTry(cid, SKILL_FIST, 10)
			doRemoveItem(getTileItemById(pos4002, bigrock).uid)
			doCreateItem(smallrock,pos4002)	
			addEvent(goto, 1, cid)                               
			doSendMagicEffect(getPlayerPosition(cid), 13)	        
			
if brake > mining then
	doPlayerRemoveItem(cid, 2553, 1)
	doCreatureSay(cid, "Well shit, your fuckin pick broke man.", TALKTYPE_ORANGE_1)
		return false
	end	

if chance >= 0 and chance <= 50000 then
	doPlayerAddItem(cid, 2255,1)
	doCreatureSay(cid, "You found some trashy copper.", TALKTYPE_ORANGE_1)	
		return false
	end

if chance >= 50001 and chance <= 80000 then
	doPlayerAddItem(cid, 2254,1)
	doCreatureSay(cid, "You found some dirty copper.", TALKTYPE_ORANGE_1) 
		return false
	end

if chance >= 80001 and chance <= 95000 then
	doPlayerAddItem(cid, 2253,1)
	doCreatureSay(cid, "You found some dull copper.", TALKTYPE_ORANGE_1) 
		return false
	end
	
if chance >= 95001 and chance <= 100000 then
	doPlayerAddItem(cid, 2252,1)
	doCreatureSay(cid, "You found some decent copper.", TALKTYPE_ORANGE_1) 	
		return false
	end	
		return true
	end
		return true
	end

Now, when I mine them, they both go down to the small rock, but whichever I mined second, both respawn at that same spot and you can see the small crystal under the big one and then the second one respawns with the action id of the second one.

How are these two files communicating together?
 
Back
Top