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

Script help

vegas

d(^.-)b
Joined
Dec 25, 2007
Messages
276
Reaction score
0
so i had this wish about my script was going to work but it didnt,
now i cant figerout the problem so basicly i want you to :

Use an item an when you use it, it creats an teleport that only vip players can accsess.


well heres my script and the error msg



[17:33:06.620] [Error - Action Interface]
[17:33:06.620] data/actions/scripts/Vip/Vip Teleport.lua
[17:33:06.620] Description:
[17:33:06.620] (luaGetThingPosition) Thing not found



local pid = cid
local config =
{
newPos = {x=1043, y=1043, z=7}, -- New player position
teleportPos = getCreaturePosition(pid), -- Teleport position
timeToRemove = 10 -- Seconds
}

function onUse(cid, item, frompos, item2, topos)
local teleport = getTileItemById(config.teleportPos, 1387)
local playerPos = getCreaturePosition(cid)
if item.itemid == 2361 then
doCreateTeleport(1387, config.newPos, config.teleportPos)
doSendMagicEffect(config.teleportPos, CONST_ME_TELEPORT)
doSendMagicEffect(playerPos, CONST_ME_GIFT_WRAPS)
doCreatureSay(cid, "The plant used its magical power to guide you to mainland!", TALKTYPE_ORANGE_1)
addEvent(doRemoveTeleport, config.timeToRemove * 1000)
elseif item.itemid == 2361 then
doPlayerSendCancel(cid, "The plant is temporarly to weak to guide you home.")
return TRUE
end
end

function doRemoveTeleport()
local teleport = getTileItemById(config.teleportPos, 1387)
if teleport.uid > 0 then
doRemoveItem(teleport.uid)
doSendMagicEffect(config.teleportPos, CONST_ME_POFF)
end
end

rep for helping ofc =)
 
Try to put that part in the function:
Code:
local pid = cid
local config =
{
newPos = {x=1043, y=1043, z=7}, -- New player position
teleportPos = getCreaturePosition(pid), -- Teleport position
timeToRemove = 10 -- Seconds
}

The script doesnt know pid and cid before the function is called..
 
Try this:

Lua:
function onUse(cid, item, frompos, item2, topos)
local pid = cid
local teleport = getTileItemById(getCreaturePosition(pid), 1387)
local playerPos = getCreaturePosition(cid)
if item.itemid == 2361 then
doCreateTeleport(1387, {x=1043, y=1043, z=7}, getCreaturePosition(pid))
doSendMagicEffect(getCreaturePosition(pid), CONST_ME_TELEPORT)
doSendMagicEffect(playerPos, CONST_ME_GIFT_WRAPS)
doCreatureSay(cid, "The plant used its magical power to guide you to mainland!", TALKTYPE_ORANGE_1)
addEvent(doRemoveTeleport, 10 * 1000)
elseif item.itemid == 2361 then
doPlayerSendCancel(cid, "The plant is temporarly to weak to guide you home.")
return TRUE
end
end

function doRemoveTeleport()
local teleport = getTileItemById(getCreaturePosition(pid), 1387)
if teleport.uid > 0 then
doRemoveItem(teleport.uid)
doSendMagicEffect(config.getCreaturePosition(pid), CONST_ME_POFF)
end
end
 
Lua:
[18:16:14.089] [Error - TalkAction Interface]
[18:16:14.089] data/talkactions/scripts/teleporttown.lua:onSay
[18:16:14.089] Description:
[18:16:14.089] data/talkactions/scripts/teleporttown.lua:33: attempt to concaten
ate field '?' (a nil value)
[18:16:14.089] stack traceback:
[18:16:14.089]  data/talkactions/scripts/teleporttown.lua:33: in function <data/
talkactions/scripts/teleporttown.lua:1>
[18:20:19.323] Black has logged out.
 
Post the script you are using now.
Noone of the scripts has a line 33..
 
Thast what I call weird, sure it is correct error message?

Lua:
function onUse(cid, item, frompos, item2, topos)

It is not a talkaction

And my script only contains 23 lines, your error message says something is wrong on line 33.
 
Lua:
function onSay(cid, words, param, channel)
	local master = false
	if(words == '/t') then
		master = true
	elseif(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
		return true
	end

	local tid, t = cid, string.explode(param, ",")
	if(t[(master and 1 or 2)]) then
		tid = getPlayerByNameWildcard(t[(master and 1 or 2)])
		if(not tid or (isPlayerGhost(tid) and getPlayerAccess(tid) > getPlayerAccess(cid))) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[(master and 1 or 2)] .. " not found.")
			return true
		end
	end

	local tmp = getPlayerTown(cid)
	if(not master) then
		tmp = t[1]
		if(not tonumber(tmp)) then
			tmp = getTownId(tmp)
			if(not tmp) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Town " .. t[1] .. " does not exists.")
				return true
			end
		end
	end

	local pos = getTownTemplePosition(tmp, false)
	if(type(pos) ~= 'table' or isInArray({pos.x, pos.y}, 0)) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Town " .. t[1] .. " does not exists or has invalid temple position.")
		return true
	end

	pos = getClosestFreeTile(tid, pos)
	if(type(pos) ~= 'table' or isInArray({pos.x, pos.y}, 0)) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Destination not reachable.")
		return true
	end

	tmp = getCreaturePosition(tid)
	if(doTeleportThing(tid, pos) and not isPlayerGhost(tid)) then
		doSendMagicEffect(tmp, CONST_ME_POFF)
		doSendMagicEffect(pos, CONST_ME_TELEPORT)
	end

	return true
end
 
You did /t but your map does not contain a town or something.

It is not relevant with topic.

So I guess it means my fix does not display any error, but it still does not work properly. :/

How does the actions.xml line look like?
 
This one should work but I don't get why you had
Code:
if item.itemid == 2361 then
     ...
elseif item.itemid == 2361 then
     ...
end
???

Code:
local function doRemoveTeleport(cid, pos, itemid)
local teleport = getTileItemById(pos, itemid)
	doRemoveItem(teleport.uid)
	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
return true
end 

function onUse(cid, item, frompos, item2, topos)
	local teleport = doCreateTeleport(1387, {x=1043, y=1043, z=7}, getThingPos(cid))
	doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
	doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
	doCreatureSay(cid, "The plant used its magical power to guide you to mainland!", TALKTYPE_ORANGE_1)
	addEvent(doRemoveTeleport, 10 * 1000, cid, getThingPos(teleport), getThing(teleport).itemid)
return true
end
 
Last edited:
Back
Top