Jump to content

Solved..


1LoL1

Recommended Posts

Hello, can anyone help me why i have this error? :(

ERROR: attempt to index local 'q' (a userdata value)

function whenPlayerChangeNick(_, newNick) 
    local newNick = removeHexColorCode(newNick) 
    local serial = getPlayerSerial(source) 
    local q = dbQuery(database,"SELECT * FROM Nick WHERE Serial = ?", serial) 
    local poll, rows = dbPoll(q, -1) 
    if (rows == 1) then 
        local actualNicks = q["Nicks"].nicks 
        if string.find(actualNicks, newNick) then 
        else 
            local addNewNick = actualNicks .. ", " .. newNick 
            dbExec(database, "UPDATE Nick SET Nicks = ? WHERE Serial = ?", addNewNick, serial) 
        end 
    end 
end 
addEventHandler("onPlayerChangeNick", getRootElement(), whenPlayerChangeNick) 

Edited by Guest
Link to comment

Try that,

function whenPlayerChangeNick(_, newNick) 
    local newNick = removeHexColorCode(newNick) 
    local serial = getPlayerSerial(source) 
    local q = dbQuery(database,"SELECT * FROM Nick WHERE Serial = ?", serial) 
    local result = dbPoll(q, -1) 
    if (result) then 
        local actualNicks = q["Nicks"].nicks 
        if string.find(actualNicks, newNick) then 
        else 
            local addNewNick = actualNicks .. ", " .. newNick 
            dbExec(database, "UPDATE Nick SET Nicks = ? WHERE Serial = ?", addNewNick, serial) 
        end 
    else  
        dbExec(database, "INSERT INTO Nick VALUES(?,?)", addNewNick, serial) 
    end 
end 
addEventHandler("onPlayerChangeNick", getRootElement(), whenPlayerChangeNick) 

Link to comment
function whenPlayerChangeNick(_, newNick) 
    local newNick = removeHexColorCode(newNick) 
    local serial = getPlayerSerial(source) 
    local q = dbQuery(database,"SELECT * FROM Nick WHERE Serial = ?", serial) 
    local result = dbPoll(q, -1) 
    if (result) then 
        local actualNicks = poll["Nicks"] 
        if string.find(actualNicks, newNick) then 
        else 
            local addNewNick = actualNicks .. ", " .. newNick 
            dbExec(database, "UPDATE Nick SET Nicks = ? WHERE Serial = ?", addNewNick, serial) 
        end 
    else 
        dbExec(database, "INSERT INTO Nick VALUES(?,?)", addNewNick, serial) 
    end 
end 
addEventHandler("onPlayerChangeNick", getRootElement(), whenPlayerChangeNick) 

Link to comment
function whenPlayerChangeNick(_, newNick) 
    local newNick = removeHexColorCode(newNick) 
    local serial = getPlayerSerial(source) 
    local q = dbQuery(database,"SELECT * FROM Nick WHERE Serial = ?", serial) 
    local result = dbPoll(q, -1) 
    if (result) then 
        local actualNicks = poll["Nicks"] 
        if string.find(actualNicks, newNick) then 
        else 
            local addNewNick = actualNicks .. ", " .. newNick 
            dbExec(database, "UPDATE Nick SET Nicks = ? WHERE Serial = ?", addNewNick, serial) 
        end 
    else 
        dbExec(database, "INSERT INTO Nick VALUES(?,?)", addNewNick, serial) 
    end 
end 
addEventHandler("onPlayerChangeNick", getRootElement(), whenPlayerChangeNick) 

It's fixed.. and poll["Nicks"] ? where is poll?

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...