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

[Talkaction] Make teleport with command

MiPo91

Member
Joined
Mar 30, 2010
Messages
299
Reaction score
18
Location
Finland
Hello, could someone make a script which makes teleport to specific coords and broadcasts msg at same time?

For example it makes teleport to thais depot which leads to some area, and it broadcast msg "Teleport to the event have been summoned to thais depot!"
 
Lua:
local cfg = {
	tp = {x= 995, y= 1024, z= 7}, -- where tp is created
	tpto = {x= 1356, y= 921, z= 13} -- where it tp's to
	messagecreate = 'Message Here' -- broadcast message on create
	messageremove = 'Messag remove here' -- broadcast message on remove
	minutes = 2(60*1000) -- amount of minutes to wait 
	}

function onSay(cid, words, param)
  doCreateTeleport(1387, cfg.tpto, cfg.tp)
  setGlobalStorageValue(3330, 0)
  doBroadcastMessage(cfg.message)
  addEvent(onRemove, cfg.minutes)
return true
end

function onRemove()
     doRemoveItem(getTileItemById(cfg.tp, 1387).uid)
         doSendMagicEffect(cfg.tp, CONST_ME_POFF)
         doBroadcastMessage(cfg.message)  
return true
end

+REP if I helped
 
Last edited:
I get this error on console

Code:
[10/05/2010 23:23:49] [Error - LuaScriptInterface::loadFile] data/talkactions/scripts/dice.lua:4: '}' expected (to close '{' at line 1) near 'messagecreate'
[10/05/2010 23:23:49] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/dice.lua)
[10/05/2010 23:23:49] data/talkactions/scripts/dice.lua:4: '}' expected (to close '{' at line 1) near 'messagecreate'

And what im supposed to write at talkactions.xml?
 
Lua:
  local cfg =  {
        tp = {x= 995, y= 1024, z= 7}, -- where tp is created
        tpto = {x= 1356, y= 921, z= 13}, -- where it tp's to
        messagecreate = 'Message Here', -- broadcast message on create
        messageremove = 'Messag remove here', -- broadcast message on remove
        minutes = 2(60*1000) -- amount of minutes to wait
        }

function onSay(cid, words, param)
	doCreateTeleport(1387, cfg.tpto, cfg.tp)
	setGlobalStorageValue(3330, 0)
	doBroadcastMessage(cfg.message)
	addEvent(onRemove, cfg.minutes)
return true
end

function onRemove()
    doRemoveItem(getTileItemById(cfg.tp, 1387).uid)
    doSendMagicEffect(cfg.tp, CONST_ME_POFF)
    doBroadcastMessage(cfg.message)  
return true
end

Fixed!
 
Lua:
  local cfg =  {
        tp = {x= 995, y= 1024, z= 7}, -- where tp is created
        tpto = {x= 1356, y= 921, z= 13}, -- where it tp's to
        messagecreate = 'Message Here', -- broadcast message on create
        messageremove = 'Messag remove here', -- broadcast message on remove
        minutes = 2(60*1000) -- amount of minutes to wait
        }

function onSay(cid, words, param)
	doCreateTeleport(1387, cfg.tpto, cfg.tp)
	setGlobalStorageValue(3330, 0)
	doBroadcastMessage(cfg.message)
	addEvent(onRemove, cfg.minutes)
return true
end

function onRemove()
    doRemoveItem(getTileItemById(cfg.tp, 1387).uid)
    doSendMagicEffect(cfg.tp, CONST_ME_POFF)
    doBroadcastMessage(cfg.message)  
return true
end

Fixed!

I tried that too before you even 'fixed' it but its not working.
Code:
[10/05/2010 23:38:06] [Error - LuaScriptInterface::loadFile] data/talkactions/scripts/dice.lua:6: '}' expected (to close '{' at line 1) near '('
[10/05/2010 23:38:06] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/dice.lua)
[10/05/2010 23:38:06] data/talkactions/scripts/dice.lua:6: '}' expected (to close '{' at line 1) near '('
 
try now

Lua:
  local cfg =  
{
        tp = {x= 995, y= 1024, z= 7}, -- where tp is created
        tpto = {x= 1356, y= 921, z= 13}, -- where it tp's to
        messagecreate = 'Message Here', -- broadcast message on create
        messageremove = 'Messag remove here', -- broadcast message on remove
        minutes = 2(60*1000) -- amount of minutes to wait
};

function onSay(cid, words, param)
  doCreateTeleport(1387, cfg.tpto, cfg.tp)
  setGlobalStorageValue(3330, 0)
  doBroadcastMessage(cfg.message)
  addEvent(onRemove, cfg.minutes)
return true
end

function onRemove()
     doRemoveItem(getTileItemById(cfg.tp, 1387).uid)
         doSendMagicEffect(cfg.tp, CONST_ME_POFF)
         doBroadcastMessage(cfg.message)  
return true
end
 
Still got an error, and oh btw.. im using TFS 0.3.6

Code:
[10/05/2010 23:55:04] [Error - LuaScriptInterface::loadFile] data/talkactions/scripts/dice.lua:7: '}' expected (to close '{' at line 2) near '('
[10/05/2010 23:55:04] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/dice.lua)
[10/05/2010 23:55:04] data/talkactions/scripts/dice.lua:7: '}' expected (to close '{' at line 2) near '('
 
Lua:
  local cfg =  
{
        tp = {x= 995, y= 1024, z= 7}, -- where tp is created
        tpto = {x= 1356, y= 921, z= 13}, -- where it tp's to
        messagecreate = 'Message Here', -- broadcast message on create
        messageremove = 'Messag remove here', -- broadcast message on remove
        minutes = 2*(60*1000) -- amount of minutes to wait
};

function onSay(cid, words, param)
  doCreateTeleport(1387, cfg.tpto, cfg.tp)
  setGlobalStorageValue(3330, 0)
  doBroadcastMessage(cfg.messagecreate)
  addEvent(onRemove, cfg.minutes)
return true
end

function onRemove()
     doRemoveItem(getTileItemById(cfg.tp, 1387).uid)
         doSendMagicEffect(cfg.tp, CONST_ME_POFF)
         doBroadcastMessage(cfg.messageremove)  
return true
end

works 100% now, tested 0.3.6pl1
 
Added some stuff so you can't spam create the teleports :p
Code:
local cfg =  {
        tp = {x= 995, y= 1024, z= 7}, -- where tp is created
        tpto = {x= 1356, y= 921, z= 13}, -- where it tp's to
        messagecreate = 'Message Here', -- broadcast message on create
        messageremove = 'Messag remove here', -- broadcast message on remove
        minutes = 2 -- amount of minutes to wait
        }

function onSay(cid, words, param)
    if getGlobalStorageValue(3330) ~= 1 then
        doCreateTeleport(1387, cfg.tpto, cfg.tp)
        doBroadcastMessage(cfg.messagecreate)
        addEvent(onRemove, cfg.minutes * 60 * 1000)
        setGlobalStorageValue(3330, 1)
    else
        doPlayerSendCancel(cid, "The teleport is already created! You have to wait " .. minutes .. " minutes to create it again!")
    end
return true
end

function onRemove()
    doRemoveItem(getTileItemById(cfg.tp, 1387).uid)
    doSendMagicEffect(cfg.tp, CONST_ME_POFF)
    doBroadcastMessage(cfg.messageremove)  
    setGlobalStorageValue(3330, 0)
return true
end
 
Last edited:
Yep its working now,but what i need to say to remove the portal?

Code:
<talkaction words="/dice" access="4" event="script" value="dice.lua"/>
 
Oh btw... I edited the code little bit and it works fine, but I'm wondering how to check tile/items first before doing the next step, because console is getting error msg if the tp isnt there.

Edited code
Code:
  local cfg =  
{
        tp = {x= 32345, y= 32226, z= 7}, -- where tp is created
        tpto = {x= 32345, y= 32223, z= 6}, -- where it tp's to
        messagecreate = 'Message Here', -- broadcast message on create
        messageremove = 'Messag remove here', -- broadcast message on remove
};

function onSay(cid, words, param)
	if words == "/diceon" then
			 doCreateTeleport(1387, cfg.tpto, cfg.tp)
			 setGlobalStorageValue(3330, 0)
			 doBroadcastMessage(cfg.messagecreate)
	return true
	end
	if words == "/diceoff" then
			doRemoveItem(getTileItemById(cfg.tp, 1387).uid)
			doSendMagicEffect(cfg.tp, CONST_ME_POFF)
			doBroadcastMessage(cfg.messageremove)  
	return true
	end
	
end

The error msg
Code:
[11/05/2010 00:49:07] [Error - TalkAction Interface] 
[11/05/2010 00:49:07] data/talkactions/scripts/dice.lua:onSay
[11/05/2010 00:49:07] Description: 
[11/05/2010 00:49:07] (luaDoRemoveItem) Item not found
[11/05/2010 00:49:07] > Broadcasted message: "Messag remove here".
 
Code:
function onSay(cid, words, param, channel)
	local tp, tpto, msg, msg2 = {x= 32345, y= 32226, z= 7}, {x= 32345, y= 32223, z= 6}, 'Message Here', 'Message remove here'
	if words == "/diceon" then
		doCreateTeleport(1387, tpto, tp)
		doBroadcastMessage(msg)
	elseif words =="/diceoff" then
		local this = getTileItemById(1387, tp).uid
		if this > 0 then
			doRemoveItem(this)
			doSendMagicEffect(tp, CONST_ME_POFF)
			doBroadcastMessage(msg2)
		end
	end
	return true
end
 
Code:
function onSay(cid, words, param, channel)
	local tp, tpto, msg, msg2 = {x= 32345, y= 32226, z= 7}, {x= 32345, y= 32223, z= 6}, 'Message Here', 'Message remove here'
	if words == "/diceon" then
		doCreateTeleport(1387, tpto, tp)
		doBroadcastMessage(msg)
	elseif words =="/diceoff" then
		local this = getTileItemById(1387, tp).uid
		if this > 0 then
			doRemoveItem(this)
			doSendMagicEffect(tp, CONST_ME_POFF)
			doBroadcastMessage(msg2)
		end
	end
	return true
end

This error comes up, and now it doesnt even delete the tp.
Code:
[11/05/2010 01:02:27] [Error - TalkAction Interface] 
[11/05/2010 01:02:27] data/talkactions/scripts/dice.lua:onSay
[11/05/2010 01:02:27] Description: 
[11/05/2010 01:02:27] attempt to index a number value
[11/05/2010 01:02:27] stack traceback:
[11/05/2010 01:02:27] 	[C]: in function 'getTileItemById'
[11/05/2010 01:02:27] 	data/talkactions/scripts/dice.lua:7: in function <data/talkactions/scripts/dice.lua:1>
 
a fuck;
Code:
function onSay(cid, words, param, channel)
	local tp, tpto, msg, msg2 = {x= 32345, y= 32226, z= 7}, {x= 32345, y= 32223, z= 6}, 'Message Here', 'Message remove here'
	if words == "/diceon" then
		doCreateTeleport(1387, tpto, tp)
		doBroadcastMessage(msg)
	elseif words =="/diceoff" then
		local this = getTileItemById(tp, 1387).uid
		if this > 0 then
			doRemoveItem(this)
			doSendMagicEffect(tp, CONST_ME_POFF)
			doBroadcastMessage(msg2)
		end
	end
	return true
end
 
Back
Top