• 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 Function query[Solved]

Scrappy Coco

Member
Joined
Dec 27, 2014
Messages
95
Reaction score
17
when to click on the item . throws this error


script:
Code:
function getPlayerFrags(cid)
    local player = Player(cid)
    local resultId = db.storeQuery("SELECT `frags` FROM `players` WHERE `name` = " ..getCreatureName(cid) ..db.escapeString(frags))
    if resultId ~= false then
        local accountId = result.getDataInt(resultId, "frags")
        result.free(resultId)
        return accountId
    end
    return 0
end
function onUse(cid, item)
   local Player = Player(cid)
    Player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Frags:"..getplayerfrags()..".")
    Player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    return true
end

Tenks
 
Testing and not result the same error keeps coming.

EDIT: Sorry, same thing as whitevo said, we posted in like the same second. :p

Are you sure you changed the script? The original error was because you used lower cased letter and you didn't include (cid) inside the function.

It's impossible to have the SAME ERROR unless you didn't change the script.
 
Look @imkingran @whitevo


this is script:
Code:
function getPlayerFrags(cid)
    local player = Player(cid)
    local resultid = db.storeQuery("SELECT `frags` FROM `players` WHERE `name` = " ..getCreatureName(cid) ..db.escapeString(frags))
    if resultid ~= false then
        local accountid = result.getDataInt(resultid, "frags")
        result.free(resultid)
        return accountid
    end
    return 0
end

function onUse(cid, item)
   local Player = Player(cid)
    Player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Frags:"..getPlayerFrags(cid)".")
    Player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    return true
end
 
Code:
function getPlayerFrags(cid)
    local player = Player(cid)
    local resultid = db.storeQuery("SELECT `frags` FROM `players` WHERE `name` = " ..getCreatureName(cid) ..db.escapeString(frags))
    if resultid ~= false then
        local accountid = result.getDataInt(resultid, "frags")
        result.free(resultid)
        return accountid
    end
    return 0
end

function onUse(cid, item)
   local Player = Player(cid)
    Player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Frags:"..getPlayerFrags(cid)".")
    Player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    return true
end
 
Last edited:
change

Code:
local resultId = db.storeQuery("SELECT `frags` FROM `players` WHERE `name` = " ..getCreatureName(cid) ..db.escapeString(frags))
to
Code:
local resultId = db.storeQuery("SELECT `frags` FROM `players` WHERE `name` = " ..player:getName()")
 
You're using TFS 1.0 I presume?

Code:
function onSay(cid, words, param)
    local player = Player(cid)
    local resultId = db.storeQuery("SELECT `frags` FROM `players` WHERE `name` = '" .. player:getName() .."';")
    if (resultId ~= false) then
        fragCount =  tonumber(result.getDataInt(resultId, "frags"))
        result.free(resultId)
    else
        fragCount = 0
    end
   
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Frags: "..fragCount..".")
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    return false
end
 
Back
Top