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

Tp Medal

Maten

New Member
Joined
Mar 16, 2009
Messages
219
Reaction score
2
Hi it me again:$

do anyone know how to make a script to this:
lets say medal of honour tp you like a tp scroll BUT only if you stand here at [X: 89] [Y: 110] [Z: 7] to lets say this location [X: 59] [Y: 111] [Z: 7]

A script on this please guys and girls :)
 
LUA:
local medal = xxxxx
local temple = {x=xxx, y=xxx, z=x}
local level = xxxxx
local fromPosition = {x = 89, y = 110, z = 7}
local toPosition = {x = 59, y = 111, z = 7}

function onUse(cid, item, frompos, item2, topos)
    if item.itemid == medal and getPlayerLevel(cid) >= level and isInRange(getThingPosition(pid), fromPosition, toPosition) then
        doTeleportThing(cid, temple, TRUE)
        doSendMagicEffect(temple,10)
        doSendAnimatedText(temple, "You are in temple!", 5)
        doRemoveItem(cid, item.uid, 1)
    else
        doPlayerSendCancel(cid, "Sorry, your level must be higher than xxx and you must be on the OMFGANAME area!")
    end
return TRUE
end
 
Thats your teleport medal/scroll position, so just enter the position where you would like to travel to for example x=15 y=35 z=4
 
I'm geting this error :/
Code:
[Error - Action Interface]
data/actions/scripts/other/vip medal.lua:onUse
Description:
data/lib/032-position.lua:2: attempt to index local 'position' (a boolean value)

stack traceback:
        data/lib/032-position.lua:2: in function 'isInRange'
        data/actions/scripts/other/vip medal.lua:8: in function 
<data/actions/scripts/other/vip medal.lua:7>
 
Last edited:
how? im new with this stuff ;s


this is my 032-position.lua:
Code:
function isInRange(position, fromPosition, toPosition)
	return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end

function getDistanceBetween(fromPosition, toPosition)
	local x, y = math.abs(fromPosition.x - toPosition.x), math.abs(fromPosition.y - toPosition.y)
	local diff = math.max(x, y)
	if(fromPosition.z ~= toPosition.z) then
		diff = diff + 9 + 6
	end

	return diff
end

function getDirectionTo(pos1, pos2)
	local dir = NORTH
	if(pos1.x > pos2.x) then
		dir = WEST
		if(pos1.y > pos2.y) then
			dir = NORTHWEST
		elseif(pos1.y < pos2.y) then
			dir = SOUTHWEST
		end
	elseif(pos1.x < pos2.x) then
		dir = EAST
		if(pos1.y > pos2.y) then
			dir = NORTHEAST
		elseif(pos1.y < pos2.y) then
			dir = SOUTHEAST
		end
	else
		if(pos1.y > pos2.y) then
			dir = NORTH
		elseif(pos1.y < pos2.y) then
			dir = SOUTH
		end
	end

	return dir
end

function getCreatureLookPosition(cid)
	return getPosByDir(getThingPos(cid), getCreatureLookDirection(cid))
end

function getPositionByDirection(position, direction, size)
	local n = size or 1
	if(direction == NORTH) then
		position.y = position.y - n
	elseif(direction == SOUTH) then
		position.y = position.y + n
	elseif(direction == WEST) then
		position.x = position.x - n
	elseif(direction == EAST) then
		position.x = position.x + n
	elseif(direction == NORTHWEST) then
		position.y = position.y - n
		position.x = position.x - n
	elseif(direction == NORTHEAST) then
		position.y = position.y - n
		position.x = position.x + n
	elseif(direction == SOUTHWEST) then
		position.y = position.y + n
		position.x = position.x - n
	elseif(direction == SOUTHEAST) then
		position.y = position.y + n
		position.x = position.x + n
	end

	return position
end

function doComparePositions(position, positionEx)
	return position.x == positionEx.x and position.y == positionEx.y and position.z == positionEx.z
end

function getArea(position, x, y)
	local t = {}
	for i = (position.x - x), (position.x + x) do
		for j = (position.y - y), (position.y + y) do
			table.insert(t, {x = i, y = j, z = position.z})
		end
	end

	return t
end
 
replace the whole isInRange with this
LUA:
function isInRange(position, fromPosition, toPosition)
	return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end
 
replace the whole isInRange with this
LUA:
function isInRange(position, fromPosition, toPosition)
	return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end

what? I dont get it, like this in vip medal .lua?
Code:
local medal = 5785
local temple = {x=26, y=181, z=7}
local level = 50
local fromPosition = {x = 28, y = 181, z = 7}
local toPosition = {x = 26, y = 111, z = 7}
 
function isInRange(position, fromPosition, toPosition)
	return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end
return TRUE
end
 
Nvm with the Inrange stuff i said , just use this script

as i said ..
himm thou the problem is in Bogart script

It is
LUA:
getThingPos(cid)
not
LUA:
 getThingPos(pid)



LUA:
local temple = {x=xxx, y=xxx, z=x}
local level = xxxxx
local fromPosition = {x = 89, y = 110, z = 7}
local toPosition = {x = 59, y = 111, z = 7}
 
function onUse(cid, item, frompos, item2, topos)
    if getPlayerLevel(cid) >= level and isInRange(getThingPosition(cid), fromPosition, toPosition) then
        doTeleportThing(cid, temple, TRUE)
        doSendMagicEffect(temple,10)
        doSendAnimatedText(temple, "You are in temple!", 5)
        doRemoveItem(cid, item.uid, 1)
    else
        doPlayerSendCancel(cid, "Sorry, your level must be higher than xxx and you must be on the OMFGANAME area!")
    end
return TRUE
 
Nvm with the Inrange stuff i said , just use this script

as i said ..




LUA:
local temple = {x=xxx, y=xxx, z=x}
local level = xxxxx
local fromPosition = {x = 89, y = 110, z = 7}
local toPosition = {x = 59, y = 111, z = 7}
 
function onUse(cid, item, frompos, item2, topos)
    if getPlayerLevel(cid) >= level and isInRange(getThingPosition(cid), fromPosition, toPosition) then
        doTeleportThing(cid, temple, TRUE)
        doSendMagicEffect(temple,10)
        doSendAnimatedText(temple, "You are in temple!", 5)
        doRemoveItem(cid, item.uid, 1)
    else
        doPlayerSendCancel(cid, "Sorry, your level must be higher than xxx and you must be on the OMFGANAME area!")
    end
return TRUE

didnt work :/
Code:
[Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/vip
 medal.lua)
data/actions/scripts/other/vip medal.lua:16: 'end' expected (to close 'function'
 at line 7) near '<eof>'
[Error - LuaScriptInterface::loadFile] data/actions/scripts/other/vip medal.lua:
16: 'end' expected (to close 'function' at line 7) near '<eof>'
[Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/vip
 medal.lua)
data/actions/scripts/other/vip medal.lua:16: 'end' expected (to close 'function'
 at line 7) near '<eof>'
 
well the good thing is that im not geting any errors the bad new is that am not being tped :D
it just says
"Sorry, your level must be higher than xxx and you must be on the OMFGANAME area!"
 
no i am at the right place and I am lvl 400 look here

Code:
local medal = 5785
local temple = {x=28, y=181, z=7}
local level = 50
local fromPosition = {x = 28, y = 181, z = 7}
local toPosition = {x = 26, y = 181, z = 7}
 
function onUse(cid, item, frompos, item2, topos)
    if getPlayerLevel(cid) >= level and isInRange(getThingPosition(cid), fromPosition, toPosition) then
        doTeleportThing(cid, temple, TRUE)
        doSendMagicEffect(temple,10)
        doSendAnimatedText(temple, "You are in temple!", 5)
        doRemoveItem(cid, item.uid, 1)
    else
        doPlayerSendCancel(cid, "Sorry, your level must be higher than 50 and you must be on the OMFGANAME area!")
    end
	
return TRUE
end
 
Back
Top