Jump to content

[HELP] there was a problem in the script


Marald

Recommended Posts

Bad argument @ 'getPlayerAccount' [Expected element at argument 1,got boolean]

Bad argument @ 'getAccountName' [Expected element at argument 1,got boolean]

my code: 

db = dbConnect( "sqlite", "db.db" )

function checkFraction(player)
    local acc = getPlayerAccount(player)
    local playerName = getAccountName(acc)
    local result = dbPoll(dbQuery(db,"SELECT * FROM `fraction` WHERE login = ?",playerName),-1)
    if #result > 0 then 
        for i,v in ipairs(result) do
            outputChatBox('This fraction : '..v.fractionId,player)
        end
    else
        outputChatBox("Error",player)
    end
end

checkFraction()

 

please help me

Link to comment
db = dbConnect( "sqlite", "db.db" )

function checkFraction(player)
    local acc = getPlayerAccount(player)
    local playerName = getAccountName(acc)
    local result = dbPoll(dbQuery(db,"SELECT * FROM `fraction` WHERE login = ?",playerName),-1)
    if #result > 0 then 
        for i,v in ipairs(result) do
            outputChatBox('This fraction : '..v.fractionId,player)
        end
    else
        outputChatBox("Error",player)
    end
end

checkFraction() -- you need to add player argument

for example

for _,plrs in ipairs(getElementsByType("player")) do -- get all players on server
	checkFraction(plrs) --check their fraction
end

 

Edited by fxl
  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...