function onStepIn(cid, item, position, fromPosition)
local from, to, setX, setY, setZ, Pos = { x = 258, y = 1934 }, { x = 284, y = 1955 }, math.random(from.x,to.x), math.random(from.y,to.y), 8, {x = setX, y = setY, z = setZ}
function isWalkable(cid, pos)
pos.stackpos = 0
if getTileThingByPos(pos).uid ~= 0 then
local n = getTileInfo(pos)
if n.house == false and getTopCreature(pos).uid == 0 and doTileQueryAdd(cid, pos) == RETURNVALUE_NOERROR then
return true
end
end end
if isWalkable(cid, Pos) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
doTeleportThing(cid, Pos)
else
return doTeleportThing(cid, fromPosition, true) and doPlayerSendCancel(cid, "Try again.")
end
return true
end
<movevent type="StepIn" actionid="7070" event="script" value="yourname.lua"/>
function onStepIn(cid, item, position, fromPosition)
local from, to, setX, setY, setZ, Pos = { x = 1101, y = 992, z = 6}, { x = 1101, y = 992, z = 6 }, math.random(from.x,to.x), math.random(from.y,to.y), 8, {x = 1101 y = 996, z = set6}
function isWalkable(cid, pos)
pos.stackpos = 0
if getTileThingByPos(pos).uid ~= 0 then
local n = getTileInfo(pos)
if n.house == false and getTopCreature(pos).uid == 0 and doTileQueryAdd(cid, pos) == RETURNVALUE_NOERROR then
return true
end
end end
if isWalkable(cid, Pos) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
doTeleportThing(cid, Pos)
else
return doTeleportThing(cid, fromPosition, true) and doPlayerSendCancel(cid, "Try again.")
end
return true
end
<movevent type="StepIn" actionid="7070" event="script" value="przejsciestatek.lua"/>
<movevent type="StepIn" actionid="7070" event="script" value="przejsciestatek.lua"/>
<movevent event="StepIn" actionid="7070" script="przejsciestatek.lua"/>
[Warning - Event::checkScript] Can not load script: scripts/przejsciestatek.lua
data/movements/scripts/przejsciestatek.lua:5: '}' expected near 'y'
Change to:{x = 1101 y = 996, z = set6}
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return false
end
player:teleportTo(Position(32369, 32232, 7), false)
return true
end
Returning false won't negate the onStepIn. You'll need to teleport them back to fromPosition with walk movement and you have an unnecessary end that will cause error.Put this instead of the one you have and try.
Lua:function onStepIn(creature, item, position, fromPosition) local player = creature:getPlayer() if not player then return false end player:teleportTo(Position(1000, 1000, 7), false) end return true end
Yeah I edited that and tested it is working now, sorry I am still new to this. you can correct it but I tested in-game it works.Returning false won't negate the onStepIn. You'll need to teleport them back to fromPosition with walk movement and you have an unnecessary end that will cause error.
I'm sure it'll ignore the code that follows after you return false. I'm just saying it will still allow the monster to walk on the portal without teleporting it. Yours is good tho, I'm just pointing it out.Yeah I edited that and tested it is working now, sorry I am still new to this. you can correct it but I tested in-game it works.
local destination = Position(1101, 996, 6)
function onStepIn(creature, item, toPosition, fromPosition)
if creature:isPlayer() then
creature:teleportTo(destination)
destination:sendMagicEffect(CONST_ME_TELEPORT)
else
creature:teleportTo(fromPosition, true)
end
return true
end
Yeah I understood what you meant, Thanks he can use yours seems to be more specific.I'm sure it'll ignore the code that follows after you return false. I'm just saying it will still allow the monster to walk on the portal without teleporting it. Yours is good tho, I'm just pointing it out.
I would do like this:
Lua:local destination = Position(1101, 996, 6) function onStepIn(creature, item, toPosition, fromPosition) if creature:isPlayer() then creature:teleportTo(destination) destination:sendMagicEffect(CONST_ME_TELEPORT) else creature:teleportTo(fromPosition, true) end return true end
function onStepIn(cid, item, pos)
local tp = {x=1101, y=996, z=6}
if item.actionid == 50040 then
doTeleportThing(cid,tp)
doSendMagicEffect(getCreaturePosition(cid),10)
end
return 1
end
<movevent event="StepIn" actionid="50040" script="NAME.lua" />
For the sake of learning. This script is messed up in many ways.Ok guys, i didn't check script what you wrote Apollos but many thanks.I spoke with one of user our forum and he give me solution
Code:function onStepIn(cid, item, pos) local tp = {x=1101, y=996, z=6} if item.actionid == 50040 then doTeleportThing(cid,tp) doSendMagicEffect(getCreaturePosition(cid),10) end return 1 end
And movements
Code:<movevent event="StepIn" actionid="50040" script="NAME.lua" />
Thanks everybody who try help me!
Efficient & correct does not equal complicated.Guys why you make so complicated scripts ? XD you want to show off or smtin ? simple solutions are the best ones