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

[request] I need help with this script!

mikkas70

Owner and Developer of omegaservers.org
Joined
Jan 6, 2009
Messages
42
Reaction score
8
I'm going to use this script (not made by me) to teleport players to my arena...
Here it is:



local arenas = {
[7667] = {
fromPos ={
{x = 1005, y = 995, z = 10}, --player 1 start pos
{x = 1006, y = 995, z = 10} --player 2 start pos
},
toPos = {
{x = 1008, y = 995, z = 10}, --player 1 teleport position
{x = 1009, y = 995, z = 10} --player 2 teleport position
}
}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(item.itemid == 1946) then
doTransformItem(item.uid, 1945)
return TRUE
end

local arena = arenas[item.uid]
if(not arena) then
return FALSE
end

local players = {}
for _, pos in pairs(arena.fromPos) do
pos.stackpos = STACKPOS_TOP_CREATURE
local tmp = getThingfromPos(pos).uid
if(tmp > 0 and isCreature(tmp) == TRUE) then
table.insert(players, tmp)
end
end

if(table.maxn(players) < table.maxn(arena.fromPos)) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need more creatures for duel.")
return TRUE
end

for i, pid in pairs(players) do
doSendMagicEffect(arena.fromPos, CONST_ME_POFF)
doTeleportThing(pid, arena.toPos)
doSendMagicEffect(arena.toPos, CONST_ME_TELEPORT)
doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "FIGHT!")
end

return TRUE
end


]Unfortunately there's something wrong with this script... It works when it is configured to teleport two players (whe I pull the lever they will be teleported to the desired location) But if I configure this script to teleport more than 2 players it won't work for some reason[

When I edit this to teleport more than 2 players :
Example:
local arenas = {
[7667] = {
fromPos ={
{x = 1005, y = 995, z = 10}, --player 1 start pos
{x = 1006, y = 995, z = 10} --player 2 start pos
{x = 1007, y = 995, z = 10} --player 3 start pos
},
toPos = {
{x = 1008, y = 995, z = 10}, --player 1 teleport position
{x = 1009, y = 995, z = 10} --player 2 teleport position
{x = 1010, y = 995, z = 10} --player 3 teleport position
}
}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(item.itemid == 1946) then
doTransformItem(item.uid, 1945)
return TRUE
end

local arena = arenas[item.uid]
if(not arena) then
return FALSE
end

local players = {}
for _, pos in pairs(arena.fromPos) do
pos.stackpos = STACKPOS_TOP_CREATURE
local tmp = getThingfromPos(pos).uid
if(tmp > 0 and isCreature(tmp) == TRUE) then
table.insert(players, tmp)
end
end

if(table.maxn(players) < table.maxn(arena.fromPos)) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need more creatures for duel.")
return TRUE
end

for i, pid in pairs(players) do
doSendMagicEffect(arena.fromPos, CONST_ME_POFF)
doTeleportThing(pid, arena.toPos)
doSendMagicEffect(arena.toPos, CONST_ME_TELEPORT)
doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "FIGHT!")
end

return TRUE
end


It won't work... What's wrong with this?
 
You missed a " , " at the beginning

Lua:
local arenas = {
	[7667] = {
		fromPos ={
			{x = 1005, y = 995, z = 10}, --player 1 start pos
			{x = 1006, y = 995, z = 10}, --player 2 start pos
			{x = 1007, y = 995, z = 10} --player 3 start pos
			},
		toPos = {
			{x = 1008, y = 995, z = 10}, --player 1 teleport position
			{x = 1009, y = 995, z = 10}, --player 2 teleport position
			{x = 1010, y = 995, z = 10} --player 3 teleport position
			}
		}
	}

Use this, it will work.


*Note* Download notepadd++ (google it) better program for scripting.
 
Back
Top