• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua 8.6 ambiguous syntax (function call x new statement) near '('

Hernest

New Member
Joined
Jul 26, 2010
Messages
152
Reaction score
3
Location
poland
Code:
    if (str >= 10 and t1 == -1) then
    npcHandler:say("Awesome! I gave you 5 premium points for your 10 tasks.")
    local update = db.executeQuery("UPDATE `accounts` SET `premium_points`= "..(points + nagroda).." WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")
    (getPlayerStorageValue(cid, 35001) + 1)

Code:
[09/07/2014 01:56:46] [Error - LuaScriptInterface::loadFile] data/npc/scripts/taski.lua:39: ambiguous syntax (function call x new statement) near '('
[09/07/2014 01:56:46] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/taski.lua
[09/07/2014 01:56:46] data/npc/scripts/taski.lua:39: ambiguous syntax (function call x new statement) near '('

Without ' ( ) ' error is still here but another.
 
What I posted already checks all storage numbers in that range.
So x will be 3543062 till 3543105.

It uses cid, so make sure to add it under: function creatureSayCallback(cid, type, msg)
 
00:11 Cris: [Error - LuaInterface::loadFile] data/npc/scripts/tescik.lua:27: 'do' expected near ',' [0:11:39.941] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/tescik.lua [0:11:39.941] data/npc/scripts/tescik.lua:27: 'do' expected near ','
00:13 Cris: [Error - LuaInterface::loadFile] data/npc/scripts/tescik.lua:47: 'do' expected near ',' [0:13:00.322] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/tescik.lua [0:13:00.322] data/npc/scripts/tescik.lua:47: 'do' expected near ','


Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                          npcHandler:onCreatureAppear(cid)                        end
function onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid)                     end
function onCreatureSay(cid, type, msg)                  npcHandler:onCreatureSay(cid, type, msg)                end
function onThink()                                      npcHandler:onThink()                                    end
    
    local storageKey = 343 -- // storage z taskow
    local taski = 10 -- // ilosc taskow
    local config = {
    points=5,
    storage=2500,

}

    function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
    return false
    end
   
   
   
   
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    local str = getPlayerStorageValue(cid, 2364234)
    local storageKey = 2364234
    local hard = getPlayerStorageValue(cid, storageKey)
    local t1 = getPlayerStorageValue(cid, 35001)
    local t2 = getPlayerStorageValue(cid, 35002)
    local t3 = getPlayerStorageValue(cid, 35003)
    local t4 = getPlayerStorageValue(cid, 35004)
    local t5 = getPlayerStorageValue(cid, 35005)
    local t6 = getPlayerStorageValue(cid, 35006)
   


   
   
   
   
    if(msgcontains(msg, 'tasks')) then
    npcHandler:say("You have done " .. hard .. " tasks. If you want to get premium points, you need to do 10 task first. For every 10 tasks I can give you {premium points}.", cid)
        local n = 0 -- liczba tasków
        for x = 3543105,3543103,3543104,3543102,3543101,3543100,3543099,3543098,3543097,3543096,3543094,3543095,3543093,3543092,3543091,3543090,3543089,3543086,3543087,3543088,3543085,3543084,3543083,3543081,3543082,3543080,3543077,3543078,3543079,3543075,3543076,3543074,3543070,3543071,3543072,3543073,3543069,3543068,3543067,3543066,3543064,3543065,3543035,3543036,3543037,3543038,3543039,3543040,3543041,3543042,3543043,3543044,3543045,3543047,3543046,3543048,3543049,3543050,3543059,3543056,3543053,3543052,3543063,3543062 do
            if getPlayerStorageValue(cid, x) >= 1 then
         n = n + 1
        end
    end
   
    elseif(msgcontains(msg, 'premium points')) then
    if (n >= 10 and t1 == -1) then
    --local result_plr = db.getResult("SELECT * FROM accounts WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
    --local money = tonumber(result_plr:getDataInt("premium_points"))
       -- money = money+config.points
    npcHandler:say("Awesome! I gave you " .. config.points .. " for your 10 tasks.", cid)
        --db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. money .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
    setPlayerStorageValue(cid, 35001, 1)
    elseif (t1 == 1 and t2 == -1) then
    npcHandler:say("You have already claimed reward for 10 tasks!", cid)
    elseif (str <= 9) then
    npcHandler:say("U do not have enough tasks to claim reward for 20 tasks!", cid)
    end
    -- // 20 taskow
    if (n >= 20 and t2 == -1 and t1 == 1) then
    npcHandler:say("Awesome! I gave you " .. config.points .. " for your 20 tasks.", cid)
        --db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. money .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
    setPlayerStorageValue(cid, 35002, 1)
    elseif (t2 == 1 and t3 == -1) then
    npcHandler:say("You have already claimed reward!", cid)
    elseif (t1 == 1 and str <= 19) then
    npcHandler:say("U do not have enough tasks to claim reward!", cid)
    end
    -- // 30 taskow
    if (n >= 30 and t3 == -1 and t2 == 1) then
    npcHandler:say("Awesome! I gave you " .. config.points .. " for your 30 tasks.", cid)
        --db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. money .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
    setPlayerStorageValue(cid, 35003, 1)
    elseif (t3 == 1) then
    npcHandler:say("You have already claimed reward!", cid)
    elseif (t1 == 1 and t2 == 1 and str <= 29) then
    npcHandler:say("U do not have enough tasks to claim reward!", cid)
    end
    -- // 40 taskow
    if (n >= 40 and t4 == -1 and t3 == 1) then
    npcHandler:say("Awesome! I gave you " .. config.points .. " for your 40 tasks.", cid)
        --db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. money .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
    setPlayerStorageValue(cid, 35004, 1)
    elseif (t4 == 1) then
    npcHandler:say("You have already claimed reward!", cid)
    elseif (t1 == 1 and t2 == 1 and t3 == 1 and str <= 39) then
    npcHandler:say("U do not have enough tasks to claim reward!", cid)
    end
    -- // 50 tasks
    if (n >= 50 and t5 == -1 and t4 == 1) then
    npcHandler:say("Awesome! I gave you " .. config.points .. " for your 40 tasks.", cid)
        --db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. money .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
    setPlayerStorageValue(cid, 35005, 1)
    elseif (t5 == 1) then
    npcHandler:say("You have already claimed reward!", cid)
    elseif (t1 == 1 and t2 == 1 and t3 == 1 and t4 == 1 and str <= 39) then
    npcHandler:say("U do not have enough tasks to claim reward!", cid)
    end
    -- // 60 tasks
    if (n >= 60 and t6 == -1 and t5 == 1) then
    npcHandler:say("Awesome! I gave you " .. config.points .. " for your 40 tasks.", cid)
        --db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. money .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
    setPlayerStorageValue(cid, 35006, 1)
    elseif (t6 == 1) then
    npcHandler:say("You have already claimed reward!", cid)
    elseif (t1 == 1 and t2 == 1 and t3 == 1 and t4 == 1 and t5 == 1 and str <= 39) then
    npcHandler:say("U do not have enough tasks to claim reward!", cid)
    end
    -- // kurwa
   
    if(t1 == 10) then
    talkState[talkUser] = 1
    end
    elseif(msgcontains(msg, 'yes')) then
    if(talkState[talkUser] == 1) then
    else
    end
    end
    return true
    end
    
    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:addModule(FocusModule:new())
 
Change this
Code:
local n = 0 -- liczba tasków
for x = 3543105,3543103,3543104,3543102,3543101,3543100,3543099,3543098,3543097,3543096,3543094,3543095,3543093,3543092,3543091,3543090,3543089,3543086,3543087,3543088,3543085,3543084,3543083,3543081,3543082,3543080,3543077,3543078,3543079,3543075,3543076,3543074,3543070,3543071,3543072,3543073,3543069,3543068,3543067,3543066,3543064,3543065,3543035,3543036,3543037,3543038,3543039,3543040,3543041,3543042,3543043,3543044,3543045,3543047,3543046,3543048,3543049,3543050,3543059,3543056,3543053,3543052,3543063,3543062 do
       if getPlayerStorageValue(cid, x) >= 1 then
         n = n + 1
     end
end

To this
Code:
local n = 0 -- liczba tasków
for x = 3543062, 3543105 do
     if getPlayerStorageValue(cid, x) >= 1 then
         n = n + 1
     end
end

The for loop works like this
Code:
for x = from number, to number do
The x will be these numbers and all numbers between them.
For example:
Code:
for x = 1, 4 do
Then x will be: 1, 2, 3 and 4.
It repeats everything inside it, first time x will be 1, second time it will be 2, third time 3 and fourth time 4.

Same goes for the storage numbers, first time x will be 3543062, second time 3543063 etc.
That's why you can count the storage values with n = n + 1, because every time when the storage value is 1 or more, it will add +1 to the variable n.
 
Code:
55.     if (n >= 10 and t1 == -1) then
Code:
data/npc/scripts/taski.lua:55: attempt to compare number with nil

stack traceback:
data/npc/scripts/taski.lua:55: in function 'callback'
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                          npcHandler:onCreatureAppear(cid)                        end
function onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid)                     end
function onCreatureSay(cid, type, msg)                  npcHandler:onCreatureSay(cid, type, msg)                end
function onThink()                                      npcHandler:onThink()                                    end
    
    local storageKey = 343 -- // storage z taskow
    local taski = 10 -- // ilosc taskow
    local config = {
    points=5,
    storage=2500,

}

    function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
    return false
    end
   
   
   
   
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    local str = getPlayerStorageValue(cid, 2364234)
    local storageKey = 2364234
    local hard = getPlayerStorageValue(cid, storageKey)
    local t1 = getPlayerStorageValue(cid, 35001)
    local t2 = getPlayerStorageValue(cid, 35002)
    local t3 = getPlayerStorageValue(cid, 35003)
    local t4 = getPlayerStorageValue(cid, 35004)
    local t5 = getPlayerStorageValue(cid, 35005)
    local t6 = getPlayerStorageValue(cid, 35006)
   


   
   
   
   
    if(msgcontains(msg, 'tasks')) then
        local n = 0 -- liczba tasków
    for x = 3543062, 3543105 do
     if getPlayerStorageValue(cid, x) >= 1 then
         n = n + 1
     end
end
    npcHandler:say("You have done " .. n .. " tasks. If you want to get premium points, you need to do 10 task first. For every 10 tasks I can give you {premium points}.", cid)

   
    elseif(msgcontains(msg, 'premium points')) then
    if (n >= 10 and t1 == -1) then
    local result_plr = db.getResult("SELECT * FROM accounts WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
    local money = tonumber(result_plr:getDataInt("premium_points"))
       money = money+config.points
    npcHandler:say("Awesome! I gave you " .. config.points .. " for your 10 tasks.", cid)
        --db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. money .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
    setPlayerStorageValue(cid, 35001, 1)
    elseif (t1 == 1 and t2 == -1) then
    npcHandler:say("You have already claimed reward for 10 tasks!", cid)
    elseif (str <= 9) then
    npcHandler:say("U do not have enough tasks to claim reward for 20 tasks!", cid)
    end
    -- // 20 taskow
    if (n >= 20 and t2 == -1 and t1 == 1) then
    npcHandler:say("Awesome! I gave you " .. config.points .. " for your 20 tasks.", cid)
        --db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. money .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
    setPlayerStorageValue(cid, 35002, 1)
    elseif (t2 == 1 and t3 == -1) then
    npcHandler:say("You have already claimed reward!", cid)
    elseif (t1 == 1 and str <= 19) then
    npcHandler:say("U do not have enough tasks to claim reward!", cid)
    end
    -- // 30 taskow
    if (n >= 30 and t3 == -1 and t2 == 1) then
    npcHandler:say("Awesome! I gave you " .. config.points .. " for your 30 tasks.", cid)
        --db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. money .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
    setPlayerStorageValue(cid, 35003, 1)
    elseif (t3 == 1) then
    npcHandler:say("You have already claimed reward!", cid)
    elseif (t1 == 1 and t2 == 1 and str <= 29) then
    npcHandler:say("U do not have enough tasks to claim reward!", cid)
    end
    -- // 40 taskow
    if (n >= 40 and t4 == -1 and t3 == 1) then
    npcHandler:say("Awesome! I gave you " .. config.points .. " for your 40 tasks.", cid)
        --db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. money .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
    setPlayerStorageValue(cid, 35004, 1)
    elseif (t4 == 1) then
    npcHandler:say("You have already claimed reward!", cid)
    elseif (t1 == 1 and t2 == 1 and t3 == 1 and str <= 39) then
    npcHandler:say("U do not have enough tasks to claim reward!", cid)
    end
    -- // 50 tasks
    if (n >= 50 and t5 == -1 and t4 == 1) then
    npcHandler:say("Awesome! I gave you " .. config.points .. " for your 40 tasks.", cid)
        --db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. money .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
    setPlayerStorageValue(cid, 35005, 1)
    elseif (t5 == 1) then
    npcHandler:say("You have already claimed reward!", cid)
    elseif (t1 == 1 and t2 == 1 and t3 == 1 and t4 == 1 and str <= 39) then
    npcHandler:say("U do not have enough tasks to claim reward!", cid)
    end
    -- // 60 tasks
    if (n >= 60 and t6 == -1 and t5 == 1) then
    npcHandler:say("Awesome! I gave you " .. config.points .. " for your 40 tasks.", cid)
        --db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. money .. " WHERE id = " .. getPlayerAccountId(cid) .. ";")
    setPlayerStorageValue(cid, 35006, 1)
    elseif (t6 == 1) then
    npcHandler:say("You have already claimed reward!", cid)
    elseif (t1 == 1 and t2 == 1 and t3 == 1 and t4 == 1 and t5 == 1 and str <= 39) then
    npcHandler:say("U do not have enough tasks to claim reward!", cid)
    end
    -- // kurwa
   
    if(t1 == 10) then
    talkState[talkUser] = 1
    end
    elseif(msgcontains(msg, 'changelog')) then
    npcHandler:say("12-07-2014 Ostateczna, wolna od bledow wersja skryptu zostaje wydana oraz udostepniona na serwerze.", cid)
    if(talkState[talkUser] == 1) then
    else
    end
    end
    return true
    end
    
    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:addModule(FocusModule:new())
 
Back
Top