Teleports

Teleports are what they sound like; they move you (or your vehicle) (nearly) instantaneously from one point in a map to another. The only complication arises from the fact that you are indeed moved to and not just placed in the new spot, making it possible to have collision issues in the middle of the teleport. Teleports are created using regions placed in Zeroeditor and with some .lua coding.

Setting up a Teleport

1: Open ZeroEditor and create the region that one will teleport from when one enters it, in this example, it's named TeleporterRegion

2: Create a new path and just place 1 node and name it something that you can remember, in this example, it's named TelporterNode

3: Open the .lua for the mode the teleport works in and add this piece of code inside the "function ScriptPostLoad()" just before "End"

OnEnterRegion(
function(regIn,character)
MoveEntityToNode(character,"TeleportNode")
end,
"TeleportRegion"
)
ActivateRegion("TeleportRegion")

4: Scroll down to the bottom of the .lua, and add this piece of code (should be last thing in the .lua script) after the last "End"

function MoveEntityToNode(entIn,pathIn,nodeIn)
if not entIn then
print("Warning!: Entity not specified for move")
return false
elseif not pathIn then
print("Warning!: Path not specified for Entity " .. entIn .. " move")
return false
end

local node
if nodeIn then
node = nodeIn
else
node = 0
end

local locDest = GetPathPoint(pathIn,node)
local charUnit = GetCharacterUnit(entIn)
local charVeh = GetCharacterVehicle(entIn)
if charVeh then
SetEntityMatrix(charVeh,locDest)
elseif charUnit then
SetEntityMatrix(charUnit,locDest)
return true
end
return false
end

5: Munge and test, If it works, have a cookie! (no chocolate ones)

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License