• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Problem with this script: Teleport Trap

Obsdark

Member
Joined
Sep 25, 2011
Messages
213
Reaction score
9
¡¡¡Hey Oh!!!

I have one script which function is, if you walk over a certain tile with certain action.id this one have a chance of 7/12 of teleport you, acording to the number is the place where it must teleport you

However right now is not working, because i't doesn't want to call the table "r", the problem says this:

Code:
"... :Attempt to call "r" (a table value)"

Now, this bring me to the question, how can i connect the randomization with the table and put it on some part of the script for been used?

I try this way, i leave it the code here, i need help with this one. ;)

LUA:
local min, max = 1, 12
math.random(min, max)
local r = {
[1] = {x = 3252, y = 3025, z = 7},
[2] = {x = 3252, y = 3026, z = 7},
[3] = {x = 3252, y = 3027, z = 7},
[4] = {x = 3252, y = 3028, z = 7},
[5] = {x = 3252, y = 3029, z = 7},
[6] = {x = 3252, y = 3030, z = 7},
[7] = {x = 3252, y = 3031, z = 7},
[8] = getPlayerPosition(cid),
[9] = getPlayerPosition(cid),
[10] = getPlayerPosition(cid),
[11] = getPlayerPosition(cid),
[12] = getPlayerPosition(cid)
}
local t = r(pos)
function onStepIn(cid, item, frompos, itemEx, topos)
if getPlayerPosition(cid) == (item.actionid) and t == [1 - 7] then
	doSendMagicEffect(t, 0)
	doSendMagicEffect(t, 17)
	doTeleportThing(cid, t)
elseif getPlayerPosition(cid) == (item.actionid) and t == [8 - 12] then
	doPlayerSendCancel(cid, Escuchas un ruido, pero nada sucede.)
end
return 1
end

¡¡¡Tnx a lot!!!
(Y)(Y)


¡Bless to all and Cheers up!

-Obsdark-
 
--¡Bump!--

New code modification & image with problem, ¡Bump Free!

bugfv.png


LUA:
local min, max = 1, 12
math.random(min, max)
local r = {
[1] = {x = 3252, y = 3025, z = 7},
[2] = {x = 3252, y = 3026, z = 7},
[3] = {x = 3252, y = 3027, z = 7},
[4] = {x = 3252, y = 3028, z = 7},
[5] = {x = 3252, y = 3029, z = 7},
[6] = {x = 3252, y = 3030, z = 7},
[7] = {x = 3252, y = 3031, z = 7},
[8] = getPlayerPosition(cid),
[9] = getPlayerPosition(cid),
[10] = getPlayerPosition(cid),
[11] = getPlayerPosition(cid),
[12] = getPlayerPosition(cid)
}
local t = r(pos)
function onStepIn(cid, item, frompos, itemEx, topos)
if getPlayerPosition(cid) == (item.actionid) and t == [1 - 7] then
	doSendMagicEffect(t, 0)
	doSendMagicEffect(t, 17)
	doTeleportThing(cid, t)
elseif getPlayerPosition(cid) == (item.actionid) and t == [8 - 12] then
	doPlayerSendCancel(cid, Escuchas un ruido, pero nada sucede.)
end
return 1
end

¡Tnx a lot For Everything, Since Now!
(Y)(Y)

-Obsdark-
 
try now

LUA:
local min, max = 1, 12
math.random(min, max)
local r = {
[1] = {x = 3252, y = 3025, z = 7},
[2] = {x = 3252, y = 3026, z = 7},
[3] = {x = 3252, y = 3027, z = 7},
[4] = {x = 3252, y = 3028, z = 7},
[5] = {x = 3252, y = 3029, z = 7},
[6] = {x = 3252, y = 3030, z = 7},
[7] = {x = 3252, y = 3031, z = 7},
[8] = getPlayerPosition(cid),
[9] = getPlayerPosition(cid),
[10] = getPlayerPosition(cid),
[11] = getPlayerPosition(cid),
[12] = getPlayerPosition(cid)
}
local t = r(pos) 
function onStepIn(cid, item, position, fromPosition)
if getPlayerPosition(cid) == (item.actionid) and t == [1 - 7] then
	doSendMagicEffect(t, 0)
	doSendMagicEffect(t, 17)
	doTeleportThing(cid, t)
elseif getPlayerPosition(cid) == (item.actionid) and t == [8 - 12] then
	doPlayerSendCancel(cid, Escuchas un ruido, pero nada sucede.)
end
return 1
end
 
edit this line not use ,t
LUA:
doTeleportThing(cid, t)

Script not found thing.. to teleport..
I looking use function local t
try.. changed..
 
i corrected that problem, but ¡a new one apparead!:

bugtelepottrap2.png


LUA:
local min, max = 1, 12
math.random(min, max)
local r = {
[1] = {x = 3252, y = 3025, z = 7},
[2] = {x = 3252, y = 3026, z = 7},
[3] = {x = 3252, y = 3027, z = 7},
[4] = {x = 3252, y = 3028, z = 7},
[5] = {x = 3252, y = 3029, z = 7},
[6] = {x = 3252, y = 3030, z = 7},
[7] = {x = 3252, y = 3031, z = 7},
[8] = doSendMagicEffect(yoursi, 17),
[9] = doSendMagicEffect(yoursi, 17),
[10] = doSendMagicEffect(yoursi, 17),
[11] = doSendMagicEffect(yoursi, 17),
[12] = doSendMagicEffect(yoursi, 17)
}
yoursi = {x = 3252, y = 3032, z = 7}
local t = r(pos) 
function onStepIn(cid, item, position, fromPosition)
if getPlayerPosition(cid) == (item.actionid) and t == 1 or 2 or 3 or 4 or 5 or 6 or 7 then
	doSendMagicEffect(t, 0)
	doSendMagicEffect(t, 17)
	doTeleportThing(cid, t)
elseif getPlayerPosition(cid) == (item.actionid) and t == 8 or 9 or 10 or 11 or 12 then
	doPlayerSendCancel(cid, "Escuchas un ruido, pero nada sucede.")
end
return 1
end

As you can see, that problem in the console was part of the "getPlayerPosition(cid)" in the 8 - 12 random options, after that this new problem apparead, i leave to you the "new" code to see if you can help me with that... :)

¡Bless, Cheers up and Tnx for everything!
(Y)(Y)

-Obsdark-
 
LUA:
local min, max = 1, 12
math.random(min, max)
local r = {
[1] = {x = 3252, y = 3025, z = 7},
[2] = {x = 3252, y = 3026, z = 7},
[3] = {x = 3252, y = 3027, z = 7},
[4] = {x = 3252, y = 3028, z = 7},
[5] = {x = 3252, y = 3029, z = 7},
[6] = {x = 3252, y = 3030, z = 7},
[7] = {x = 3252, y = 3031, z = 7},
[8] = doSendMagicEffect(yoursi, 17),
[9] = doSendMagicEffect(yoursi, 17),
[10] = doSendMagicEffect(yoursi, 17),
[11] = doSendMagicEffect(yoursi, 17),
[12] = doSendMagicEffect(yoursi, 17)
}
yoursi = {x = 3252, y = 3032, z = 7}
local t = r(pos) 
function onStepIn(cid, item, position, fromPosition)
if getPlayerPosition(cid) == (item.actionid) and t == 1 or 2 or 3 or 4 or 5 or 6 or 7 then
	doSendMagicEffect(t, 0)
	doSendMagicEffect(t, 17)
	doTeleportThing(cid, t)
else
if getPlayerPosition(cid) == (item.actionid) and t == 8 or 9 or 10 or 11 or 12 then
	doPlayerSendCancel(cid, "Escuchas un ruido, pero nada sucede.")
end
return 1
end
 
well, tnx but doesn't work, however i figured out some modification who can help to fix it our main problem, ¡let me update you about it!. ;)

this are the codes of this script right now:

TeleportTrapUndead2.lua

LUA:
local r = {
[1] = {x = 3252, y = 3025, z = 7},
[2] = {x = 3252, y = 3026, z = 7},
[3] = {x = 3252, y = 3027, z = 7},
[4] = {x = 3252, y = 3028, z = 7},
[5] = {x = 3252, y = 3029, z = 7},
[6] = {x = 3252, y = 3030, z = 7},
[7] = {x = 3252, y = 3031, z = 7},
[8] = 17,
[9] = 17,
[10] = 17,
[11] = 17,
[12] = 17
}
yoursi = {x = 3252, y = 3032, z = 7}
pos = getPlayerStorageValue(cid, 9895)
local t = r[pos] 
function onStepIn(cid, item, position, fromPosition, Toposition)
if t == 1 or 2 or 3 or 4 or 5 or 6 or 7 then
	doSendMagicEffect(t, 1, cid)
	doSendMagicEffect(t, 17, cid)
	doTeleportThing(cid, t)
elseif t == 8 or 9 or 10 or 11 or 12 then
	doSendMagicEffect(yoursi, t)
	doPlayerSendCancel(cid, "Escuchas un ruido, pero nada sucede.")
end
return 1
end

And for set the random i try with another external script:

TeleportTrapSetter.lua

LUA:
min, max = 1, 12
local t = {
math.random(min, max)
}
pos = getPlayerStorageValue(cid, 9895)
function onStepIn(cid, item, position, fromPosition)
	if pos == 0 or -1 then
		setPlayerStorageValue(cid, 9895, t)
	end
return 1
end

This is how i load them to the movement thing:

Code:
<movement type="StepIn" actionid="6100" event="script" value="TeleportTrapUndead2.lua"/>
<movement type="StepIn" actionid="6100" event="script" value="TeleportTrapSetter.lua"/>

However this are the new console problems about it, when it starts:

bugteleporttrappart1.png


And this ones when i trigger it:

bugteleporttrappart2.png


¡I hope you can help me, Tnx a lot from now!
(Y)(Y)

-Obsdark-
 

Similar threads

Back
Top