• 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 Elseif/else, end [rep++]

Evan

A splendid one to behold
Senator
Premium User
Joined
May 6, 2009
Messages
7,018
Solutions
1
Reaction score
1,040
Location
United States
Why is this not working? I don't exactly know how ends are supposed to work with elseif, so I'm changing it all around a lot, then I've finally given up. Can someone help me out here?

Here is the error:
[13:5:29.901] [Error - LuaInterface::loadFile] data/actions/scripts/quests/poisonclean.lua:12: 'end' expected (to close 'function' at line 1) near 'elseif'
[13:5:29.902] [Error - Event::checkScript] Cannot load script (data/actions/scripts/quests/poisonclean.lua)
[13:5:29.903] data/actions/scripts/quests/poisonclean.lua:12: 'end' expected (to close 'function' at line 1) near 'elseif'

Here is the script:
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
store = getPlayerStorageValue(cid, 34903)
store2 = getPlayerStorageValue(cid, 34902)

	if item.actionid == 34903 and store == -1 and store2 == -1 then
		setPlayerStorageValue(34903, 1)
		doCreatureSay(cid, "You are cleansed from poison, now you must do the lava side.", TALKTYPE_ORANGE_1)
	else
		doSendMagicEffect(fromPosition, 2)
		doCreatureSay(cid, "You are already cleansed.", TALKTYPE_ORANGE_1)
	end
	elseif item.actionid == 34903 and store == -1 and store2 == 1 then
		setPlayerStorageValue(34904, 1)
		doCreatureSay(cid, "You have proven your ability to survive the most harsh conditions!", TALKTYPE_ORANGE_1)
	else
		doCreatureSay(cid, "You may now move on.", TALKTYPE_ORANGE_1)
	end
	end
	return true
end
 
Don't make such sloppy codes :|

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local store = getPlayerStorageValue(cid, 34903)
local store2 = getPlayerStorageValue(cid, 34902)
	if item.actionid == 34903 and store == -1 and store2 == -1 then
		setPlayerStorageValue(34903, 1) 
		doCreatureSay(cid, "You are cleansed from poison, now you must do the lava side.", TALKTYPE_ORANGE_1) 
	elseif item.actionid == 34903 and store == -1 and store2 == 1 then 
		setPlayerStorageValue(34904, 1) 
		doCreatureSay(cid, "You have proven your ability to survive the most harsh conditions!", TALKTYPE_ORANGE_1) 
	else 
		doSendMagicEffect(fromPosition, 2) 
		doCreatureSay(cid, "You are already cleansed.", TALKTYPE_ORANGE_1) 
	end
	return true
end
 
I'm not sure but lua doesnt supprot elseif probably, just make it
else
if...
else
end end
also delete end above elseif


thats what happens when I wanna help but I'm too lazy to start npp :D
 
Last edited:
Thanks unknown666, looking at your code, I'm guessing it is illegal to have an else before an elseif.
REP++
 
Back
Top