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

Need simple script

leileililasian

New Member
Joined
Sep 27, 2009
Messages
50
Reaction score
0
To get me started, for some reason i keep messing up the simple scripts. I need a simple script to just remove a pink stone for 60 seconds and then have it reset. Also i need another script as a quest with an npc to give the player experience when they kill a certain number of creatures (example 50 rotworms they get 10,000 experience). Thank you.
 
Thank you the script works fine, how would i get the lever to move back and forth though? it kinda just sits there which is fine since im only running a beta version for now xD, hopefully i can learn from this script and build from it and not have to rely so much on others, TYVM
 
add this to when it removes the rock
Code:
doTransformItem(item.uid, item.itemid - 1)
and when it adds the rock
Code:
doTransformItem(item.uid, item.itemid + 1)
 
local t = {
timer = 60,
rockid = 1355, -- rock id
rockpos = {x= 1697,y= 1219,z= 8}, -- rock position
storage = 60050,
}

local function addRock(cid)
setGlobalStorageValue(cid, t.storage, -1)
doCreateItem(t.rockid, 1, t.rockpos)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
if getGlobalStorageValue(cid, t.storage) < 0 then
doRemoveItem(t.rockpos, t.rockid, 1)
doTransformItem(item.uid, item.itemid - 1)
setGlobalStorageValue(cid, t.storage, os.time() + t.timer * 1000)
addEvent(addRock, t.timer * 1000, cid)
doTransformItem(item.uid, item.itemid + 1)
else
doPlayerSendTextMessage(cid, 19, "The rock has already been removed.")
end
return true
end

can you show me what i am doing wrong in this, im not sure where i was supposed to plug those in. Yodots script quit working for me, it does not successfully reset

- - - Updated - - -

and now niether script is working =(
 
it would be like this
Lua:
local t = {
timer = 60,
rockid = 1355, -- rock id
rockpos = {x= 1697,y= 1219,z= 8}, -- rock position
storage = 60050,
}

local function addRock(cid)
	setGlobalStorageValue(cid, t.storage, -1)
	doTransformItem(item.uid, item.itemid + 1)
        doCreateItem(t.rockid, 1, t.rockpos)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getGlobalStorageValue(cid, t.storage) < 0 then
		doRemoveItem(t.rockpos, t.rockid, 1)
		doTransformItem(item.uid, item.itemid - 1)
		setGlobalStorageValue(cid, t.storage, os.time() + t.timer * 1000)
		addEvent(addRock, t.timer * 1000, cid)
	else
		doPlayerSendTextMessage(cid, 19, "The rock has already been removed.")
	end
return true
end
 
Lua:
local t = {
timer = 60,
rockid = 1355, -- rock id
rockpos = {x= 1697,y= 1219,z= 8}, -- rock position
storage = 60050,
}
 
local function addRock(item, cid)
	setGlobalStorageValue(cid, t.storage, -1)
	doTransformItem(item.uid, item.itemid + 1)
        doCreateItem(t.rockid, 1, t.rockpos)
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getGlobalStorageValue(cid, t.storage) < 0 then
		doRemoveItem(t.rockpos, t.rockid, 1)
		doTransformItem(item.uid, item.itemid - 1)
		setGlobalStorageValue(cid, t.storage, os.time() + t.timer * 1000)
		addEvent(addRock, t.timer * 1000, item, cid)
	else
		doPlayerSendTextMessage(cid, 19, "The rock has already been removed.")
	end
return true
end

@UpInSmoke,
Your script attempted to index "item" in the "addRock()" function, which was not available. I simply added it in the function's peripherals.
 
Last edited:
okay try this
Lua:
local t = {
timer = 60,
rockid = 1355, -- rock id
rockpos = {x= 1697,y= 1219,z= 8}, -- rock position
storage = 60050,
event = 0,
}

local function addRock(cid)
	doTransformItem(item.uid, item.itemid - 1)	
	doCreateItem(t.rockid, 1, t.rockpos)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(not isPlayer(cid)) then
		return true
	end
	if t.event <= 0 then
		doRemoveItem(getTileItemById(t.rockpos,t.rockid).uid)
		doPlayerSendTextMessage(cid,21,"You have removed the rock!")
		doTransformItem(item.uid, item.itemid + 1)
		t.event = addEvent(addRock, t.timer * 1000, getThingPos(item.uid), cid)
	else
		doPlayerSendTextMessage(cid, 19, "The rock has already been removed.")
	end
return true
end

@Zuma master ahh yes i didnt notice that, dont have my server on this computer to test anything just scripting from memory xD

@OP try the script zuma posted there and if it doesnt work then give the one here a try
 
Last edited:
Ok now, it initially works, when i pull the lever it tells me the rock has been removed, and it does remove the rock. When i wait for the rock to re-appear, it does not, after the 60 seconds i go over to use the lever again and it turns into a blank piece of paper lol.

- - - Updated - - -

Seems that the reset is not working, which is what failed on the last working script after a while =(

- - - Updated - - -

it says error action interface, and then the next time i pull on the lever it turns to a blank piece of paper

- - - Updated - - -

I know what is going on, it is adding+1 to the lever, and continues to add +1 instead of going back down 1
 
try this
Lua:
local t = {
timer = 60,
rockid = 1355, -- rock id
rockpos = {x= 1697,y= 1219,z= 8}, -- rock position
storage = 60050,
}

local function addRock(cid)
	doTransformItem(item.uid, item.itemid - 1)	
	doCreateItem(t.rockid, 1, t.rockpos)
	setGlobalStorageValue(cid, t.storage, -1)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(not isPlayer(cid)) then
		return true
	end
	if getGlobalStorageValue(cid, t.storage) ~= 1 then
		doRemoveItem(getTileItemById(t.rockpos,t.rockid).uid)
		doPlayerSendTextMessage(cid,21,"You have removed the rock!")
		doTransformItem(item.uid, item.itemid + 1)
		addEvent(addRock, t.timer * 1000, getThingPos(item.uid), cid)
		setGlobalStorageValue(cid, t.storage, 1)
	else
		doPlayerSendTextMessage(cid, 19, "The rock has already been removed.")
	end
return true
end
 
the lever does not work with that script =(

- - - Updated - - -

the script before this one worked just fine until you waited for the rock to return, or tried to use the lever again

- - - Updated - - -

[23/06/2013 16:16:28] [Error - Action Interface]
[23/06/2013 16:16:28] In a timer event called from:
[23/06/2013 16:16:28] data/actions/scripts/quests/lever4.lua: onUse
[23/06/2013 16:16:28] Description:
[23/06/2013 16:16:28] data/actions/scripts/quests/lever4.lua:10: attempt to index global 'item' (a nil value)
[23/06/2013 16:16:28] stack traceback:
[23/06/2013 16:16:28] data/actions/scripts/quests/lever4.lua:10: in function <data/actions/scripts/quests/lever4.lua:9>

this is the error i get with the previous script, not the last one you put up, that one didnt really work at all
 
Last edited:
sorry this took so long, just got to my computer that has my server to test, tested and it works:
Lua:
local t = {
timer = 60,
rockid = 1355, -- rock id
rockpos = {x= 1697,y= 1219,z= 8}, -- rock position
event = 0,
}
 
local function addRock(cid)
	doCreateItem(t.rockid, 1, t.rockpos)
	t.event = 0
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(not isPlayer(cid)) then
		return true
	end
	if t.event <= 0 then
		doRemoveItem(getTileItemById(t.rockpos,t.rockid).uid)
		doPlayerSendTextMessage(cid,21,"You have removed the rock!")
		if(itemEx.itemid == 1945) then
			doTransformItem(item.uid, item.itemid + 1)
		else
			doTransformItem(item.uid, item.itemid - 1)
		end
		t.event = addEvent(addRock, t.timer * 1000, getThingPos(item.uid), cid)
	else
		doPlayerSendTextMessage(cid, 19, "The rock has already been removed.")
	end
return true
end
 
Back
Top