• 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] convert script

SUMEKAZEKI

ADM Custom Rook
Joined
Sep 10, 2016
Messages
39
Reaction score
4
hello, anyone help me convert this script from tfs 0.4 to 1.3?
Lua:
function onSay(cid, words, param)
    if (getCreatureCondition(cid, CONDITION_INFIGHT) == false) then
        if (tonumber(param) ~= nil and tonumber(param) > 0 and tonumber(param) < 8) then
            doTeleportThing(cid, getTownTemplePosition(param))
            return true
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bad parameter. E.g.: !town 1 (1-7)")
            return true
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You are in fight!!! Arrgg....")
    end
    return true
end
 
Lua:
function onSay(cid, words, param)
    local player = Player(cid)
    
    local toNumber = tonumber(param)
    if not toNumber then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Bad parameter. E.g.: !town 1 (1-7)")
        return false
    end
    
    local inFight = getCreatureCondition(cid, CONDITION_INFIGHT)
    if inFight then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You are in fight!!! Arrgg....")
    else
        player:teleportTo(Town(toNumber):getTemplePosition())       
    end
    
    return false
end
 
Lua:
function onSay(cid, words, param)
    local player = Player(cid)
  
    local toNumber = tonumber(param)
    if not toNumber then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Bad parameter. E.g.: !town 1 (1-7)")
        return false
    end
  
    local inFight = getCreatureCondition(cid, CONDITION_INFIGHT)
    if inFight then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You are in fight!!! Arrgg....")
    else
        player:teleportTo(Town(toNumber):getTemplePosition())     
    end
  
    return false
end

Lua:
function onSay(player, words, param, channel)  
    local toNumber = tonumber(param)
    if not toNumber then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Bad parameter. E.g.: !town 1 (1-2)")
        return false
    end
   
    local inFight = getCreatureCondition(player, CONDITION_INFIGHT)
    if inFight then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You are in fight!!! Arrgg....")
    else
        player:teleportTo(Town(toNumber):getTemplePosition())      
    end
   
    return false
end
i small edit and if i use example: !t 3 i got error:
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/t1.lua:onSay
data/talkactions/scripts/t1.lua:12: attempt to index a nil value
stack traceback:
         [C]: in function '__index'
         data/talkactions/scripts/t1.lua:12: in function <data/talkactions/scripts/t1.lua:1>

edit. if i use too you script i receive the same error
 
How are you calling it in "talkactions.xml"?

if you use a revscript version
Lua:
local talk = TalkAction("!town")

function Player.isBattle(self)
    if (self:getCondition(CONDITION_INFIGHT,CONDITIONID_DEFAULT) or self:isPzLocked()) then
        return true
    end   
    return false
end   

function talk.onSay(player, words, param)

    local toNumber = tonumber(param)
    if not toNumber then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Bad parameter. E.g.: !town 1 (1-2)")
        return false
    end

    local inFight = player:isBattle()
    if inFight then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You are in fight!!! Arrgg....")
    else
        player:teleportTo(Town(toNumber):getTemplePosition())     
    end
    return false
end

talk:separator(" ")
talk:register()
 
How are you calling it in "talkactions.xml"?

if you use a revscript version
Lua:
local talk = TalkAction("!town")

function Player.isBattle(self)
    if (self:getCondition(CONDITION_INFIGHT,CONDITIONID_DEFAULT) or self:isPzLocked()) then
        return true
    end  
    return false
end  

function talk.onSay(player, words, param)

    local toNumber = tonumber(param)
    if not toNumber then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Bad parameter. E.g.: !town 1 (1-2)")
        return false
    end

    local inFight = player:isBattle()
    if inFight then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You are in fight!!! Arrgg....")
    else
        player:teleportTo(Town(toNumber):getTemplePosition())    
    end
    return false
end

talk:separator(" ")
talk:register()
Code:
 Lua Script Error: [Test Interface]
 data/talkactions/scripts/t1.lua
 data/talkactions/scripts/t1.lua:10: attempt to index local 'talk' (a nil value)
 stack traceback:
         [C]: in function '__newindex'
         data/talkactions/scripts/t1.lua:10: in main chunk
 
Code:
Lua Script Error: [Test Interface]
data/talkactions/scripts/t1.lua
data/talkactions/scripts/t1.lua:10: attempt to index local 'talk' (a nil value)
stack traceback:
         [C]: in function '__newindex'
         data/talkactions/scripts/t1.lua:10: in main chunk

It seems you're not using tfs 1.3
 
tfs 1.3 downgrade to 8.6 ...
You are not using a revscript version.
how are you calling it in the talkactions.xml? I asked this in my last post, as most likely you aren't calling it correctly.

Lua:
function Player.isBattle(self)
    if (self:getCondition(CONDITION_INFIGHT,CONDITIONID_DEFAULT) or self:isPzLocked()) then
        return true
    end   
    return false
end   

function onSay(player, words, param, channel) 
    local toNumber = tonumber(param)
    if not toNumber then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Bad parameter. E.g.: !town 1 (1-2)")
        return false
    end

    local inFight = player:isBattle()
    if inFight then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You are in fight!!! Arrgg....")
    else
        player:teleportTo(Town(toNumber):getTemplePosition())     
    end
    return false
end
 
Code:
Lua Script Error: [Test Interface]
data/talkactions/scripts/t1.lua
data/talkactions/scripts/t1.lua:10: attempt to index local 'talk' (a nil value)
stack traceback:
         [C]: in function '__newindex'
         data/talkactions/scripts/t1.lua:10: in main chunk
put it inside data/scripts
not data/talkactions/scripts
 
Back
Top