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

tfs 1.2 error scripts

rogersenchou

New Member
Joined
Nov 27, 2016
Messages
36
Reaction score
3
can some one help me with 2 scripts ?

this is the script lotery system:
Code:
local config = {
    rewards = {[24774] = 2, [2160] = 100}
}
 
function onTime(interval)
    if Game.getPlayerCount() == 0 then
        return true
    end
 
    local players = Game.getPlayers()
    local winner  = players[math.random(1, #players)]
 
    local items = {}
    for itemid, count in pairs(config.rewards) do
        items[#items + 1] = itemid
    end
 
    local itemid = items[math.random(1, #items)]
    local amount = config.rewards[itemid]
    winner:addItem(itemid, amount)
 
    local it   = ItemType(itemid)
    local name = ""
    if amount == 1 then
        name = it:getArticle() .. " " .. it:getName()
    else
        name = amount .. " " .. it:getPluralName()
    end
 
    Game.broadcastMessage("" .. winner:getName() .. " won " .. name .. "! Congratulations.", MESSAGE_STATUS_WARNING)
    return true
end

and this is the error:
Code:
[Warning - Event::checkScript] Can not load script: scripts/loteria.lua
data/globalevents/scripts/loteria.lua:2: '}' expected (to close '{' at line 1) near ' '

this is the script addon talkaction mount:
Code:
local config =
{
   --["mount"] = {id = x},
   ["widow queen"] = {id = 1},
   ["racing bird"] = {id = 2},
   ["war bear"] = {id = 3},
   ["black Sheep"] = {id = 4},
   ["midnight panther"] = {id = 5},
   ["draptor"] = {id = 6},
   ["titanica"] = {id = 7},
   ["tin lizzard"] = {id = 8},
   ["blazebringer"] = {id = 9},
   ["rapid boar"] = {id = 10},
   ["Stampor"] = {id = 11},
   ["undead cavebear"] = {id = 12},
   ["donkey"] = {id = 13},
   ["tiger slug"] = {id = 14},
   ["Uniwheel"] = {id = 15},
   ["crystal wolf"] = {id = 16},
   ["brown war horse"] = {id = 17},
   ["kingly deer"] = {id = 18},
   ["tamed panda"] = {id = 19},
   ["dromedary"] = {id = 20},
   ["king scorpion"] = {id = 21},
   ["rented horse"] = {id = 22},
   ["armoured war horse"] = {id = 23},
   ["shadow draptor"] = {id = 24},
   ["rented horse"] = {id = 25},
   ["rented horse"] = {id = 26},
   ["ladybug"] = {id = 27},
   ["manta"] = {id = 28},
   ["ironblight"] = {id = 29},
   ["magma Crawler"] = {id = 30},
   ["dragonling"] = {id = 31},
   ["gnarlhound"] = {id = 32},
   ["crimson ray"] = {id = 33},
   ["Steelbeak"] = {id = 34},
   ["water buffalo"] = {id = 35},
   ["armoured scorpion"] = {id = 36},
   ["armoured dragonling"] = {id = 37},
   ["armoured cavebear"] = {id = 38},
   ["the Hellgrip"] = {id = 39},
   ["lion"] = {id = 40},
   ["golden lion"] = {id = 41},
   ["shock head"] = {id = 42}
}

function onSay(cid, words, param)

   local player, t, mountdoll_id = Player(cid), config[string.lower(param)], 9019 -- id do mount doll
  
   if (player:getItemCount(mountdoll_id) > 0) then
        if (param ~= "" and t) then
         if(t and not player:hasMount(t.id)) then 
            player:removeItem(mountdoll_id, 1)
                player:sendTextMessage(MESSAGE_INFO_DESCR, "Sua mount foi adicionada!")
            player:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS)
            player:addMount(t.id)
            else
            player:sendCancelMessage("Voce ja tem esta mount.")
            end
        else
         player:sendCancelMessage("Digite novamente, algo está errado!")
        end
    else
      player:sendCancelMessage("Voce não tem um mount doll!")
    end

   return true

ant this is the error:
Code:
[Warning - Event::checkScript] Can not load script: scripts/mount.lua
data/talkactions/scripts/mount.lua:69: 'end' expected (to close 'function' at line 48) near '<eof>'
 
can some one help me with 2 scripts ?

this is the script lotery system:
Code:
local config = {
    rewards = {[24774] = 2, [2160] = 100}
}
 
function onTime(interval)
    if Game.getPlayerCount() == 0 then
        return true
    end
 
    local players = Game.getPlayers()
    local winner  = players[math.random(1, #players)]
 
    local items = {}
    for itemid, count in pairs(config.rewards) do
        items[#items + 1] = itemid
    end
 
    local itemid = items[math.random(1, #items)]
    local amount = config.rewards[itemid]
    winner:addItem(itemid, amount)
 
    local it   = ItemType(itemid)
    local name = ""
    if amount == 1 then
        name = it:getArticle() .. " " .. it:getName()
    else
        name = amount .. " " .. it:getPluralName()
    end
 
    Game.broadcastMessage("" .. winner:getName() .. " won " .. name .. "! Congratulations.", MESSAGE_STATUS_WARNING)
    return true
end

and this is the error:
Code:
[Warning - Event::checkScript] Can not load script: scripts/loteria.lua
data/globalevents/scripts/loteria.lua:2: '}' expected (to close '{' at line 1) near ' '

this is the script addon talkaction mount:
Code:
local config =
{
   --["mount"] = {id = x},
   ["widow queen"] = {id = 1},
   ["racing bird"] = {id = 2},
   ["war bear"] = {id = 3},
   ["black Sheep"] = {id = 4},
   ["midnight panther"] = {id = 5},
   ["draptor"] = {id = 6},
   ["titanica"] = {id = 7},
   ["tin lizzard"] = {id = 8},
   ["blazebringer"] = {id = 9},
   ["rapid boar"] = {id = 10},
   ["Stampor"] = {id = 11},
   ["undead cavebear"] = {id = 12},
   ["donkey"] = {id = 13},
   ["tiger slug"] = {id = 14},
   ["Uniwheel"] = {id = 15},
   ["crystal wolf"] = {id = 16},
   ["brown war horse"] = {id = 17},
   ["kingly deer"] = {id = 18},
   ["tamed panda"] = {id = 19},
   ["dromedary"] = {id = 20},
   ["king scorpion"] = {id = 21},
   ["rented horse"] = {id = 22},
   ["armoured war horse"] = {id = 23},
   ["shadow draptor"] = {id = 24},
   ["rented horse"] = {id = 25},
   ["rented horse"] = {id = 26},
   ["ladybug"] = {id = 27},
   ["manta"] = {id = 28},
   ["ironblight"] = {id = 29},
   ["magma Crawler"] = {id = 30},
   ["dragonling"] = {id = 31},
   ["gnarlhound"] = {id = 32},
   ["crimson ray"] = {id = 33},
   ["Steelbeak"] = {id = 34},
   ["water buffalo"] = {id = 35},
   ["armoured scorpion"] = {id = 36},
   ["armoured dragonling"] = {id = 37},
   ["armoured cavebear"] = {id = 38},
   ["the Hellgrip"] = {id = 39},
   ["lion"] = {id = 40},
   ["golden lion"] = {id = 41},
   ["shock head"] = {id = 42}
}

function onSay(cid, words, param)

   local player, t, mountdoll_id = Player(cid), config[string.lower(param)], 9019 -- id do mount doll
 
   if (player:getItemCount(mountdoll_id) > 0) then
        if (param ~= "" and t) then
         if(t and not player:hasMount(t.id)) then
            player:removeItem(mountdoll_id, 1)
                player:sendTextMessage(MESSAGE_INFO_DESCR, "Sua mount foi adicionada!")
            player:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS)
            player:addMount(t.id)
            else
            player:sendCancelMessage("Voce ja tem esta mount.")
            end
        else
         player:sendCancelMessage("Digite novamente, algo está errado!")
        end
    else
      player:sendCancelMessage("Voce não tem um mount doll!")
    end

   return true

ant this is the error:
Code:
[Warning - Event::checkScript] Can not load script: scripts/mount.lua
data/talkactions/scripts/mount.lua:69: 'end' expected (to close 'function' at line 48) near '<eof>'
the errors are pretty straightforward and tell you the exact problem but
1. there should not be any errors since all brackets are closed, what text editor are you using? (asking because of this weird character
' ')
2. add another end after return true
 
Back
Top