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

Lua Talkaction: "Let's go"

januszek89

Scripter
Joined
Apr 11, 2009
Messages
22
Reaction score
0
Location
Poland
Hello everyone!
I have problem with script. Here it is scrpit:
Code:
function onSay(cid, words, param, channel)
	local t = {}
	if(param ~= '') then
		t = string.explode(param, ",")
	end

	local n = 5
	if(not n) then
		n = 5
	end
	local pid = cid
	local pos = getClosestFreeTile(pid, getPosByDir(getCreaturePosition(pid), getCreatureLookDirection(pid), n), false, false)
	if(not pos or isInArray({pos.x, pos.y}, 0)) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Destination not reachable.")
		return true
	end
	local tmp = getCreaturePosition(pid)
	if(doTeleportThing(pid, pos, true) and not isPlayerGhost(pid)) then
		doSendMagicEffect(tmp, CONST_ME_POFF)
		doSendMagicEffect(pos, CONST_ME_TELEPORT)
	end
	return true
end
This is a script to jump 5 tiles.
And I'm searching someone which can change in this script:

  • User this talkaction can't penetrate the walls
  • User this talkaction have exhaustion for 4-5min

Thanks for help :). And sorry for my not good English :(.
 
Code:
function onSay(cid, words, param, channel)
	local t = string.explode(param, ",")
	local pos = getThingPos(cid)
	local dir = getCreatureLookDirection(cid)
	if t[1] then
		local newPos = {x=(dir == 1 and  pos.x+1 or dir == 3 and pos.x-1 or pos.x), y=(dir ==  0 and pos.y-1 or dir == 2 and  pos.y+1 or pos.y), z=pos.z}
		local wallIds = {1000, 10002} -- put your wall ids etc
		for i, wall in ipairs(wallIds) do
			local it = getTileItemById(newPos[i], wall).uid
			if it > 0 then
				return doPlayerSendTextMessage(cid, 27, "_what?")
			else
				return doTeleportThing(cid, newPos, true) and doSendMagicEffect(getThingPos(cid), isPlayerGhost(cid) and CONST_ME_NONE or CONST_ME_TELEPORT)
			end
		end
	else
		return doPlayerSendTextMessage(cid, 27, "_what?")
	end
end
 
Last edited:
Code:
function onSay(cid, words, param, channel)
	local t = string.explode(param, ",")
	local pos = getThingPos(cid)
	local dir = getCreatureLookDirection(cid)
	if t[1] then
		local newPos = {x=(dir == 1 and  pos.x+1 or dir == 3 and pos.x-1 or pos.x), y=(dir ==  0 and pos.y-1 or dir == 2 and  pos.y+1 or pos.y), z=pos.z}
		local wallIds = {1000, 10002} -- put your wall ids etc
		for i, wall in ipairs(wallIds) do
			local it = getTileItemById(newPos[i], wall).uid
			if it > 0 then
				return doPlayerSendTextMessage(cid, 27, "_what?")
			else
				return doTeleportThing(cid, newPos, true) and doSendMagicEffect(getThingPos(cid), isPlayerGhost(cid)) and CONST_ME_NONE or CONST_ME_TELEPORT)
			end
		end
	else
		return doPlayerSendTextMessage(cid, 27, "_what?")
	
	local pos = getClosestFreeTile(pid, getPosByDir(getCreaturePosition(pid), getCreatureLookDirection(pid), n), false, false)
if(not pos or isInArray({pos.x, pos.y}, 0)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Destination not reachable.")
return true
end

function onSay(cid, words, param)
local nextPos = getNextXPosByDir(getCreaturePosition(pid), getPlayerLookDir(pid), 5)
if(getTilePzInfo(nextPos) == false and getTileHouseInfo(nextPos) == false) then
doTeleportThing(cid, nextPos)
else
doPlayerSendCancel(cid,"You cannot teleport to protection zone or house.")
end

return true

end

local tmp = getCreaturePosition(pid)
if(doTeleportThing(pid, pos, true) and not isPlayerGhost(pid)) then
doSendMagicEffect(tmp, CONST_ME_TELEPORT)
doSendMagicEffect(pos, CONST_ME_FIRE)

end

end


This script has got bugs..
 
Last edited:
This script doesn't work for me.

Code:
[19/05/2010 14:47:27] [Error - LuaScriptInterface::loadFile] data/talkactions/scripts/teleported.lua:13: 'end' expected (to close 'if' at line 10) near ')'
[19/05/2010 14:47:27] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/teleported.lua)
[19/05/2010 14:47:27] data/talkactions/scripts/teleported.lua:13: 'end' expected (to close 'if' at line 10) near ')'

I'm using TFS 0.3.6 :)
 
give storages like this;
Code:
setPlayerStorageValue(cid, storageid, os.time() + time)
then when you want to make a check if they are exhausted, then like this;
Code:
if getPlayerStorageValue(cid, storageid) <= os.time() then
etc
 
??? how did you use it?
use it like this;
/talkactionname 1
or something
:S
maybe theres a wall???? change the wall ids in the table...........
 
When i use it like you say "/talkactionname 1" in TFS log apear this
Code:
[19/05/2010 15:27:32] [Error - TalkAction Interface] 
[19/05/2010 15:27:32] data/talkactions/scripts/teleported.lua:onSay
[19/05/2010 15:27:32] Description: 
[19/05/2010 15:27:32] attempt to index a nil value
[19/05/2010 15:27:32] stack traceback:
[19/05/2010 15:27:32] 	[C]: in function 'getTileItemById'
[19/05/2010 15:27:32] 	data/talkactions/scripts/teleported.lua:12: in function <data/talkactions/scripts/teleported.lua:1>

Can anyone help me?
 
Last edited:
Back
Top