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

How would you script This!

Tymofek

New Member
Joined
May 12, 2011
Messages
86
Reaction score
3
Location
Santiago - CHILE
the room is like annih

XXXXXX
X0000X
XXXXXX

this is a word script so you can get it!

local totalplayers = all the players in the room
local centerplayers = only the players in the center of the room

doTeleportThing(centerplayers, nextroom)

local restoftheplayers = totalplayers - centerplayers

doTeleportThing(restoftheplayers, anotherroom)

thats all!


Ok now the thing is that i got a lot of rooms like this one so i need this script to be NOT using the coorditanes of every SQM, just the "fromx fromy tox toy"

so i can only introduce 8 coordinates by room not 18.

Thx, if you post here is couse you are a LUA pro xD
 
Just explain what the script should do properly, because I didn't understand too much of what you just wrote.. :(
 
XXXXXX
XXXXXX
XXXXXX
Code:
local t = {
	a = {
		[B][1] = {[COLOR="#0000FF"]{x="x", y="y", z="z"}[/COLOR], [COLOR="#FF0000"]{x="x", y="y", z="z"}[/COLOR]},
		[2] = {[COLOR="#0000FF"]{x="x", y="y", z="z"}[/COLOR], [COLOR="#FF0000"]{x="x", y="y", z="z"}[/COLOR]},
		[3] = {[COLOR="#0000FF"]{x="x", y="y", z="z"[/COLOR]}, [COLOR="#FF0000"]{x="x", y="y", z="z"}[/COLOR]},
		[4] = {[COLOR="#0000FF"]{x="x", y="y", z="z"}[/COLOR], [COLOR="#FF0000"]{x="x", y="y", z="z"}[/COLOR]},
		[5] = {[COLOR="#0000FF"]{x="x", y="y", z="z"}[/COLOR], [COLOR="#FF0000"]{x="x", y="y", z="z"}[/COLOR]}[/B]
	},
	b = {x="x", y="y", z="z"}, -- center players room
	c = {x="x", y="y", z="z"} -- rest of the players room
	}
function doTeleportRestOfThePlayers()
for v = t.a[1], #t.a do
	local a = {
		a = { -- total players
		fromPosition = v[1],
		toPosition = v[2]
		},
		b = { -- center players
		fromPosition = {x="a.a.fromPosition.x+1", y="a.a.fromPosition.y+1", z="a.a.fromPosition.z"},
		toPosition = {x="a.a.fromPosition.x-1", y="a.a.fromPosition.y-1", z="a.a.fromPosition.z"}
		}
	}
	for _, pid in ipairs(getPlayersOnline()) do
		if isInRange(pid, a.a.fromPosition, a.a.toPosition) then
			doTeleportThing(pid, t.c)
		end
	end
end
return TRUE
end

function onSay(cid, words, param, channel)
for v = t.a[1], #t.a do
	local a = {
		a = { -- total players
		fromPosition = v[1],
		toPosition = v[2]
		},
		b = { -- center players
		fromPosition = {x="a.a.fromPosition.x+1", y="a.a.fromPosition.y+1", z="a.a.fromPosition.z"},
		toPosition = {x="a.a.fromPosition.x-1", y="a.a.fromPosition.y-1", z="a.a.fromPosition.z"}
		}
	}
	for _, pid in ipairs(getPlayersOnline()) do
		if isInRange(pid, a.b.fromPosition, a.b.toPosition) then
			doTeleportThing(pid, t.b)
			addEvent(doTeleportRestOfThePlayers(), 10)
		end
	end
end
return TRUE
end
I doubt it will work >.<
 
Last edited:
XXXXXX
XXXXXX
XXXXXX
Code:
local t = {
    a = {
        [B][1] = {[COLOR=#0000FF]{x="x", y="y", z="z"}[/COLOR], [COLOR=#FF0000]{x="x", y="y", z="z"}[/COLOR]},
        [2] = {[COLOR=#0000FF]{x="x", y="y", z="z"}[/COLOR], [COLOR=#FF0000]{x="x", y="y", z="z"}[/COLOR]},
        [3] = {[COLOR=#0000FF]{x="x", y="y", z="z"[/COLOR]}, [COLOR=#FF0000]{x="x", y="y", z="z"}[/COLOR]},
        [4] = {[COLOR=#0000FF]{x="x", y="y", z="z"}[/COLOR], [COLOR=#FF0000]{x="x", y="y", z="z"}[/COLOR]},
        [5] = {[COLOR=#0000FF]{x="x", y="y", z="z"}[/COLOR], [COLOR=#FF0000]{x="x", y="y", z="z"}[/COLOR]}[/B]
    },
    b = {x="x", y="y", z="z"}, -- center players room
    c = {x="x", y="y", z="z"} -- rest of the players room
    }
function doTeleportRestOfThePlayers()
for v = 1, #t do
    local a = {
        a = { -- total players
        fromPosition = v[1],
        toPosition = v[2]
        },
        b = { -- center players
        fromPosition = {x="a.a.fromPosition.x+1", y="a.a.fromPosition.y+1", z="a.a.fromPosition.z"},
        toPosition = {x="a.a.fromPosition.x-1", y="a.a.fromPosition.y-1", z="a.a.fromPosition.z"}
        }
    }
    for _, pid in ipairs(getPlayersOnline()) do
        if isInRange(pid, a.a.fromPosition, a.a.toPosition) then
            doTeleportThing(pid, t.c)
        end
    end
end
return TRUE
end

function onSay(cid, words, param, channel)
for v = 1, #t do
    local a = {
        a = { -- total players
        fromPosition = v[1],
        toPosition = v[2]
        },
        b = { -- center players
        fromPosition = {x="a.a.fromPosition.x+1", y="a.a.fromPosition.y+1", z="a.a.fromPosition.z"},
        toPosition = {x="a.a.fromPosition.x-1", y="a.a.fromPosition.y-1", z="a.a.fromPosition.z"}
        }
    }
    for _, pid in ipairs(getPlayersOnline()) do
        if isInRange(pid, a.b.fromPosition, a.b.toPosition) then
            doTeleportThing(pid, t.b)
            addEvent(doTeleportRestOfThePlayers(), 10)
        end
    end
end
return TRUE
end
I doubt it will work >.<

Of course it will not work :p.
 
if the shape of the room is like what u posted this should work

frompos<--XXXXXX
-----------XXXXXX
-----------XXXXXX-->topos
Lua:
local rooms = {  -- diffenet room from and to pos (starting sqm to ending sqm)
				[1] = { frompos = {x=217, y= 468, z= 12}, topos = {x=222, y= 470, z= 12} } ,
				[2] = { frompos = {x=217, y= 468, z= 12}, topos = {x=222, y= 470, z= 12} } ,
				[3] = { frompos = {x=217, y= 468, z= 12}, topos = {x=222, y= 470, z= 12} } ,


}

local center_pos_tp_place = {x=217, y= 468, z= 12}   -- place where player in center will be tped to
local other_tp_place = {x=222, y= 470, z= 12}		-- place where players left will be tped to

function doTeleport(cid,xTable,yPos,zPos)
	if isInCenter(getThingPos(cid),xTable,yPos,zPos) then
		doTeleportThing(cid,center_pos_tp_place,false)
	else
		doTeleportThing(cid,other_tp_place,false)
	end
	doSendMagicEffect(getThingPos(cid),10)
end

function isInCenter(curPos,xTable,yPos,zPos)
	for _,x in ipairs(xTable) do
		if doComparePositions(curPos, {x=x,y=yPos,z=zPos}) then
			return true
		end
	end
	return false
end
			
function onSay(cid,param)
	for _, room in ipairs(rooms) do 
		local f,t = room.frompos, room.topos
		local centerXPositions = {f.x+1,f.x+2,f.x+3,f.x+4}
		for _,cid in ipairs(getPlayersOnline()) do
			if isInRange(getThingPos(cid),f,t) then
				doTeleport(cid,centerXPositions,f.y+1,f.z)
			end
		end
	end
	return true
end
 
Last edited:
if the shape of the room is like what u posted this should work

frompos<--XXXXXX
-----------XXXXXX
-----------XXXXXX-->topos
Lua:
local rooms = {  -- diffenet room from and to pos (starting sqm to ending sqm)
				[1] = { frompos = {x=217, y= 468, z= 12}, topos = {x=222, y= 470, z= 12} } ,
				[2] = { frompos = {x=217, y= 468, z= 12}, topos = {x=222, y= 470, z= 12} } ,
				[3] = { frompos = {x=217, y= 468, z= 12}, topos = {x=222, y= 470, z= 12} } ,


}

local center_pos_tp_place = {x=217, y= 468, z= 12}   -- place where player in center will be tped to
local other_tp_place = {x=222, y= 470, z= 12}		-- place where players left will be tped to

function doTeleport(cid,xTable,yPos,zPos)
	if isInCenter(getThingPos(cid),xTable,yPos,zPos) then
		doTeleportThing(cid,center_pos_tp_place,false)
	else
		doTeleportThing(cid,other_tp_place,false)
	end
	doSendMagicEffect(getThingPos(cid),10)
end

function isInCenter(curPos,xTable,yPos,zPos)
	for _,x in ipairs(xTable) do
		if doComparePositions(curPos, {x=x,y=yPos,z=zPos}) then
			return true
		end
	end
	return false
end
			
function onSay(cid,param)
	for _, room in ipairs(rooms) do 
		local f,t = room.frompos, room.topos
		local centerXPositions = {f.x+1,f.x+2,f.x+3,f.x+4}
		for _,cid in ipairs(getPlayersOnline()) do
			if isInRange(getThingPos(cid),f,t) then
				doTeleport(cid,centerXPositions,f.y+1,f.z)
			end
		end
	end
	return true
end


As i read, i guess it will work, but already made a shorter version of a similar script and its working!!!

the base of the script i made is teleporting the people in the center first and then with "addEvent(TP,1, cid, location)" tp the rest so it gives enought time to get the players out of the center of the room and then TAKE ALL THE REST and send them to another place :)

very simple and working.

I would like to Thank EVERYONE BUT "Santi"


Special Thank to Bogart thx for the effort

and

Doggynub for bringing such a PRO solution.

 

Similar threads

Back
Top