• 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 LUA DHQ Help

Cloow

Active Member
Joined
May 10, 2010
Messages
1,086
Reaction score
35
Hello, im practicing my Lua acknowledge, so i've tryed to make a simple DHQ quest.

So here it is, I just can't figure out how to add so the stone will get back in 10 seconds.

plix help?:eek:


Code:
local t = {
uid = 15126
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    doRemoveItem(t.uid)
	doPlayerSendTextMessage(cid,21,"You removed the stone! You got 10 seconds to enter before the stone appears again.")
	 doPlayerSetStorageValue(uid, 15127, 1)
	 return TRUE
end
  getPlayerStorageValue(uid, 15127, 1)
  doPlayerSendCancel(cid,"You already did this quest.")
end
end
 
first of all what do you have all those ends for?
what is this code for? i guess that is the uid of the stone? but you dont need a uid on it.
local t = {uid = 15126}

Code:
local stonepos = {x=535, y=1266, z=10, stackpos=1}
	
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, 15127) == -1 then
		doPlayerSendTextMessage(cid,21,"You removed the stone! You got 10 seconds to enter before the stone appears again.")
		doPlayerSetStorageValue(cid, 15127, 1)
		doRemoveItem(getThingfromPos(stonepos).uid, 1)
		addEvent(onTimer5, 60*1000) --1 minute
	else
		doPlayerSendCancel(cid,"You already did this quest.")
	end
	return true
end

function onTimer5() --creates wall back
	wallnewpos = {x=535, y=1266, z=10}
	doCreateItem(1304,1,wallnewpos)
end

i didnt test this but it seems a lot closer to what you want. yours was just random.
 
Lua:
local stone, id = 0, 1304
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getCreatureStorage(cid, 15127) < 0 then
		stone = getTileItemById({x = 100, y = 100, z = 7}, id)
		if stone.uid > 0 then
			doRemoveItem(stone.uid, 1)
			setPlayerStorageValue(cid, 15127, 1)
			doCreatureSay(cid, "You have 10 seconds before the stone appears!", TALKTYPE_MONSTER)
			addEvent(function() doCreateItem(id, 1, {x = 100, y = 100, z = 7}) end, 10 * 1000)
		end
	else
		doPlayerSendCancel(cid, "Sorry, not possible.")
	end
	
	return true
end
 
Alright, I think I got it with storages now. Here lemme try.


Code:
local t = {
pos = {x = 1388, y = 895, z =8}
}
function onStepIn(cid, item, frompos, itemEx, topos)
   if getPlayerStorageValue(cid, 74576) == -1 then
   doPlayerSendTextMessage(cid,21,"Careful, this is you only try to kill this monster.")
    doPlayerSetStorageValue(uid, 74576, 1)
  else
  getPlayerStorageValue(cid, 15127) == 1 then
  doTeleportThing(cid, t.pos)
  doPlayerSendCancel(cid,"You already did this quest.")
return TRUE
end
end



That would work right?

btw how do you make lua codes inserts ?
 
Last edited:
Alright, I think I got it with storages now. Here lemme try.


Code:
--no reason to sent the local like that for this little code but it will work.
[COLOR="red"]local t = {
	pos = {x = 1388, y = 895, z =8}
}[/COLOR]

function onStepIn(cid, item, frompos, itemEx, topos)
	if getPlayerStorageValue(cid, 74576) == -1 then
		doPlayerSendTextMessage(cid,21,"Careful, this is you only try to kill this monster.")
		--cid not uid
		doPlayerSetStorageValue([COLOR="red"]cid[/COLOR], 74576, 1)
	else
		--that code isnt needed the else condition happens anytime the if condition is false
		[COLOR="red"]getPlayerStorageValue(cid, 15127) == 1 then[/COLOR]
		doTeleportThing(cid, t.pos)
		doPlayerSendCancel(cid,"You already did this quest.")
	--return true goes outside the end of the if statement in this example
[COLOR="red"]	end
	return true[/COLOR]
end



That would work right?

btw how do you make lua codes inserts ?

also nothing really happens in this code. when the player steps on a tile they get a storage value and a message no monster is summoned
 
also nothing really happens in this code. when the player steps on a tile they get a storage value and a message no monster is summoned

Yeah, I wanted that script to work like that.
So you just can walk on the tile ONCE.


Alright here is my ending script.

Code:
local t = {
pos = {x = 1388, y = 895, z =8}
monster = "Demon"
posmonster = {x = 1380, y = 899, z =8}
}
function onStepIn(cid, item, frompos, itemEx, topos)
   if getPlayerStorageValue(cid, 74576) == -1 then
   doPlayerSendTextMessage(cid,21,"Careful, this is you only try to kill this monster.")
   doCreateMonster(t.monster, t.posmonster)
    doPlayerSetStorageValue(uid, 74576, 1)
  else
  getPlayerStorageValue(cid, 15127) == 1 then
  doTeleportThing(cid, t.pos)
  doPlayerSendCancel(cid,"You already did this quest.")
end
return TRUE
end

The reason I locals so often I can is because i trying to practice ;>

correct errors plox ? :)
 
Last edited:
Back
Top