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

Another lever script not working, need help.

Shinobino

New Member
Joined
Jan 26, 2009
Messages
39
Reaction score
0
Hello again!
I'm newbie in scripting. I've tried to make a script to open 4 stones, 1 lever each 1 stone, I could've made it with 4 scripts but it'd take too much time and I want to learn some better scripting.

Error in console:
Code:
[15/04/2010 21:41:57] [Error - LuaScriptInterface::loadFile] data/actions/scripts/other/frostlever.lua:38: 'end' expected (to close 'function' at line 1) near 'else'
[15/04/2010 21:41:57] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/frostlever.lua)
[15/04/2010 21:41:57] data/actions/scripts/other/frostlever.lua:38: 'end' expected (to close 'function' at line 1) near 'else'


in actions.xml
Code:
<action itemid="6011-6014" event="script" value="other/frostlever.lua"/>


in frostlever.lua
Code:
function onUse(cid, item, frompos, item2, topos)
statuepos1 = {x=1151, y=1088, z=7, stackpos=1}
statuepos2 = {x=1151, y=1087, z=7, stackpos=1}
statuepos3 = {x=1151, y=1086, z=7, stackpos=1}
statuepos4 = {x=1151, y=1085, z=7, stackpos=1}
statue1 = getThingfromPos(statuepos1)
statue2 = getThingfromPos(statuepos2)
statue3 = getThingfromPos(statuepos3)
statue4 = getThingfromPos(statuepos4)
if item.itemid == 9825 and item.uid == 6011 then
doRemoveItem(statue1.uid,1028)
doPlayerSendTextMessage(cid,22,"You can hear that something has opened. It cant be so far.")
elseif(item.itemid == 9826 and item.uid == 6011) then
doCreateItem(statue1.uid,1028)
doPlayerSendTextMessage(cid,22,"You can hear that something has closed. It cant be so far.")
end
if item.itemid == 9825 and item.uid == 6012 then
doRemoveItem(statue2.uid,1028)
doPlayerSendTextMessage(cid,22,"You can hear that something has opened. It cant be so far.")
elseif(item.itemid == 9826 and item.uid == 6012) then
doCreateItem(statue2.uid,1028)
doPlayerSendTextMessage(cid,22,"You can hear that something has closed. It cant be so far.")
end
if item.itemid == 9825 and item.uid == 6013 then
doRemoveItem(statue3.uid,1028)
doPlayerSendTextMessage(cid,22,"You can hear that something has opened. It cant be so far.")
elseif(item.itemid == 9826 and item.uid == 6013) then
doCreateItem(statue3.uid,1028)
doPlayerSendTextMessage(cid,22,"You can hear that something has closed. It cant be so far.")
end
if item.itemid == 9825 and item.uid == 6014 then
doRemoveItem(statue4.uid,1028)
doPlayerSendTextMessage(cid,22,"You can hear that something has opened. It cant be so far.")
elseif(item.itemid == 9826 and item.uid == 6014) then
doCreateItem(statue4.uid,1028)
doPlayerSendTextMessage(cid,22,"You can hear that something has closed. It cant be so far.")
end
else
doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
end
end

I want some better scripter to tell me whats bad in this script, I guess I can use end in the middle of the script but dunno how to make it 1 lever each 1 stone.
Thanks ;)

One more thing, why my NPC arent loading into OT? I can see them in RME, but not on the serv.
Console error:
Code:
[15/04/2010 21:41:58] [Warning - Npc::loadFromXml] Cannot load npc file (data/npc/Backpacker.xml).
[15/04/2010 21:41:58] Info: failed to load external entity "data/npc/Backpacker.xml"


[15/04/2010 21:41:58] [Warning - Npc::loadFromXml] Cannot load npc file (data/npc/Captain Yoe.xml).
[15/04/2010 21:41:58] Info: failed to load external entity "data/npc/Captain Yoe.xml"


+
Why aint this exp rune working?
exprune.lua
Code:
function onUse(cid, item, frompos, item2, topos)
if getPlayerLevel(cid) <= 200 then
doPlayerAddExp(cid, 2500000)
 doSendMagicEffect(getPlayerPosition(cid),1)
 else
 doSendMagicEffect(getPlayerPosition(cid), 2)
 doPlayerSendCancel(cid, "Sorry, Your level is too high!")
 end

actions.xml
Code:
<action itemid="2275" even="script" value="other/exprune.lua"/>
 
Last edited:
Code:
<action [B][COLOR="Red"]unique[/COLOR]id[/B]="6011-6014" event="script" value="other/frostlever.lua"/>
Code:
local t = {
	[6011] = {x=1151, y=1088, z=7},
	[6012] = {x=1151, y=1087, z=7},
	[6013] = {x=1151, y=1086, z=7},
	[6014] = {x=1151, y=1085, z=7}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = t[item.uid]
	if item.itemid == 9825 then
		doRemoveItem(getTileItemById(v, 1028).uid)
	else
		doCreateItem(1028, 1, v)
	end
	doCreatureSay(cid, "You heard that something has " .. (item.itemid == 9825 and "open" or "clos") .. "ed. It can't be that far.", TALKTYPE_ORANGE_1, false, cid, getThingPos(cid))
	return doTransformItem(item.uid, item.itemid == 9825 and 9826 or 9825)
end
#NPC's, you don't have them in your data/npc folder.

#EXP rune
Code:
<action itemid="2275" even[B][COLOR="Red"]t[/COLOR][/B]="script" value="other/exprune.lua"/>
 
Dunno why, but stones arent dissapearing, I can see the orange text but no action =/
+ could you please help me improve this script like rl tibia banuta entrance? i mean the player have 5 mins to open those 4 levers, if he wont do it all reset and he has to start again


+ one more thing if u got time

I got an exp potion script, its working like I wanted it to work, but what codeline should I add to make it dissapear after 1 use?

Code:
function onUse(cid, item, frompos, item2, topos)
local exp = 2500000
local msg = "You have gained 2500000 exp!"
if getPlayerLevel(cid) <= 220 then
		doPlayerAddExperience(cid, exp)
		doPlayerSendTextMessage(cid,22, msg)
		doSendMagicEffect(getPlayerPosition(cid),1)
else
		doSendMagicEffect(getPlayerPosition(cid), 2)
    doPlayerSendCancel(cid,"You don't have the required skills or vocation to use this rune.")
end
		end


sorry for disturbing
 
Code:
local exp = 2500000
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) <= 220 then
		doPlayerAddExperience(cid, exp)
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have gained " .. exp .. " exp!")
		doSendMagicEffect(getThingPos(cid), CONST_ME_LOSEENERGY)
		doRemoveItem(item.uid)
	else
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		doPlayerSendCancel(cid, "Your level is too high.")
	end
	return true
end
What itemids are you using for the levers?
 
Code:
local exp = 2500000
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) <= 220 then
		doPlayerAddExperience(cid, exp)
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have gained " .. exp .. " exp!")
		doSendMagicEffect(getThingPos(cid), CONST_ME_LOSEENERGY)
		doRemoveItem(item.uid)
	else
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		doPlayerSendCancel(cid, "Your level is too high.")
	end
	return true
end
What itemids are you using for the levers?

lever:9825/9826,
lever.jpg
 
Back
Top