• 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 Table problem (i guess)

Santi

Theres no way im stopping
Joined
Aug 29, 2010
Messages
1,975
Reaction score
152
Location
00
So, I made this script, so when you step in a tile you get a color and effects.
I made it to work in a long script, but when I tried to put it in a table it didn't work.

Old script:
Lua:
function onStepIn(cid, item, pos)
ppos = getPlayerPosition(cid)
if item.uid == 3890 then
doSetCreatureLight(cid, 10, 5, 60*100)  
doSendMagicEffect(ppos, 12)
doSendAnimatedText(ppos,"Ea ea", 5)
doSendMagicEffect(ppos, 23)
elseif item.uid == 3891 then
doSetCreatureLight(cid, 10, 18, 60*100) 
doSendMagicEffect(ppos, 14)
doSendAnimatedText(ppos,"Wooho", 18)
doSendMagicEffect(ppos, 27)
elseif item.uid == 3892 then
doSetCreatureLight(cid, 10, 180, 60*100) 
doSendMagicEffect(ppos, 13)
doSendAnimatedText(ppos,"Ea ea", 180)
doSendMagicEffect(ppos, 18)
elseif item.uid == 3893 then
doSetCreatureLight(cid, 10, 210, 60*100) 
doSendMagicEffect(ppos, 7)
doSendAnimatedText(ppos,"Disco!", 210)
doSendMagicEffect(ppos, 21)
elseif item.uid == 3894 then
doSetCreatureLight(cid, 10, 190, 60*100) 
doSendMagicEffect(ppos, 35)
doSendAnimatedText(ppos,"Fiesta", 180)
doSendMagicEffect(ppos, 24)
elseif item.uid == 3895 then
doSetCreatureLight(cid, 10, 192, 60*100) 
doSendMagicEffect(ppos, 10)
doSendAnimatedText(ppos,"Ea ea", 180)
doSendMagicEffect(ppos, 22)
return true
end
end

Tabled:
Lua:
local uids = {
["3890"] = {5,12,"Ea ea"},
["3891"] = {18,14,"Wooho"},
["3892"] = {180,13,"Ea ea"},
["3893"] = {210,7,"Disco!"},
["3894"] = {190,35,"Fiesta"},
["3895"] = {193,10,"Ea ea"},
}

function onStepIn(cid, item, pos)
ppos = getPlayerPosition(cid)
for txt, v in pairs(uids) do
    if item.uid == txt then
    doSetCreatureLight(cid,10,v[1],60*100)
    doSendMagicEffect(ppos,v[2])
    doSendAnimatedText(ppos,v[3],v[1])
return true
end
end
end

Im still learning so, any help is welcome :D
No errors displayed in console.
 
Last edited:
Lua:
local t = {
	[3890] = {5,12,'Ea ea'},
	[3891] = {18,14,'Wooho'},
	[3892] = {180,13,'Ea ea'},
	[3893] = {210,7,'Disco!'},
	[3894] = {190,35,'Fiesta'},
	[3895] = {193,10,'Ea ea'}
}

function onStepIn(cid, item, pos, fromPos)
	if isPlayer(cid) then
		local v = t[item.uid]
		doSetCreatureLight(cid, 10, v[1], 60 * 1000)
		doSendMagicEffect(pos, v[2])
		doSendAnimatedText(pos, v[3], v[1])
	end
end
 
Back
Top