• 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 Tables problem

Santi

Theres no way im stopping
Joined
Aug 29, 2010
Messages
1,975
Reaction score
152
Location
00
So, I learned how to make tables, and I made some this days and everything worked fine.
But today I tried making 2 different scripts with tables and Im getting always an error, which I cannot fix!
For example, this 2 scripts, Im getting the same error
Switch system
LUA:
local uids = {
[35000] = {1},
[35001] = {2},
[35002] = {3},
[35003] = {4},
[35004] = {5},
[35005] = {6},
[35006] = {7},
[35007] = {8},
[35008] = {9},
[35009] = {10}
}

local s = setPlayerStorageValue
local storage = 45001
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = uids[item.uid]
      setPlayerStorageValue(cid,storage,v[1])
elseif getPlayerStorageValue(cid,storage) == 10 then
	doPlayerSendTextMessage(cid, "You have already pulled all switches")
return true
end

And here a summoning script
LUA:
local t = {
[1] = {'dragon'},
[2] = {'rat'},
[3] = {'fire elemental'},
[4] = {'vampire'} ,
[5] = {'dragon lord'},
[6] = {'cave rat'}
}


function onSay(cid, words, param, channel)
local v = t[vocations]
if vocations then
      doSummonCreature(cid,v[1])
      doSummonCreature(cid,v[1])
      doSummonCreature(cid,v[1])
      setPlayerStorageValue(cid,5000,1)
      end
      elseif getPlayerStorageValue(cid,5000) and word == 'summon' then
             doPlayerSendCancel(cid, "You can only summon 3 monsters")
      return true
end

And the error I'm getting (Of course in diff lines since they don't have the same line..)
Is this:
Code:
ERROR: untitled.lua:19: 'end' expected (to close 'function' at line 11) near 'elseif'

Rep+ for the one who tries to help :)
 
LUA:
local uids = {
	[35000] = 1,
	[35001] = 2,
	[35002] = 3,
	[35003] = 4,
	[35004] = 5,
	[35005] = 6,
	[35006] = 7,
	[35007] = 8,
	[35008] = 9,
	[35009] = 10
}

local storage = 45001

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v, k = uids[item.uid], math.max(0, getPlayerStorageValue(cid, storage))
	if k == 10 then
		doPlayerSendTextMessage(cid, 'You have already pulled all switches.')
	elseif v-1 ~= k then
		doPlayerSendTextMessage(cid, 'You must pull the switches in correct order.')
	else
		setPlayerStorageValue(cid, storage, v)
	end
	return true
end
LUA:
local t = {
	[1] = 'dragon',
	[2] = 'rat',
	[3] = 'fire elemental',
	[4] = 'vampire',
	[5] = 'dragon lord',
	[6] = 'cave rat'
}

function onSay(cid, words, param, channel)
	local v = t[getPlayerVocation(cid)]
	if v then
		local n = #getCreatureSummons(cid)
		if n < 3 then
			for i = 1, 3 - n do
				doSummonCreature(cid, v)
			end
		else
			doPlayerSendCancel(cid, 'You can only summon 3 monsters.')
		end
		return true
	end
end
 
Gosh, <33, btw
LUA:
 math.max(0, getPlayerStorageValue(cid, storage))
if k == 10 then
same as:
LUA:
if getPlayerStorageValue(cid,storage) == 10 then
?
 
Back
Top