Jump to content

Getting Data From MySQL


xXMADEXx

Recommended Posts

Hello all, im making VIP system, and im not sure how to get the data from my SQL when the player logs in....

Here is my code:

addEventHandler("onPlayerJoin", root, 
    function () 
        dbQuery(loadPlayersVIP, dbConnection, "SELECT * FROM Freeroam_VIP_Players", source) 
    end 
) 
  
function loadPlayersVIP(hand,who) 
    sql = dbPoll(hand, 0) 
    for i,v in ipairs (sql) do 
        if (v["account"]==getAccountName(getPlayerAccount(who))) then 
            setElementData(who, "VIP", v["level"], true) 
        end 
    end 
end 

and here is an image of the MySQL

77928145.png

Link to comment
addEventHandler ( "onPlayerLogin", root, 
    function ( _, account ) 
        dbQuery ( loadPlayersVIP, { source }, dbConnection, "SELECT level FROM Freeroam_VIP_Players WHERE account = ? LIMIT 1", getAccountName ( account ) ) 
    end 
) 
  
function loadPlayersVIP ( query, who ) 
    local sql, numrows, errmsg = dbPoll ( query, 0 ) 
    if ( type ( sql ) == "table" and numrows > 0 ) then 
        setElementData ( who, "VIP", sql [ 1 ] [ "level" ] ) 
    end 
end 

Link to comment
addEventHandler ( "onPlayerLogin", root, 
    function ( _, account ) 
        dbQuery ( loadPlayersVIP, { source }, dbConnection, "SELECT level FROM Freeroam_VIP_Players WHERE account = ? LIMIT 1", getAccountName ( account ) ) 
    end 
) 
  
function loadPlayersVIP ( query, who ) 
    local sql, numrows, errmsg = dbPoll ( query, 0 ) 
    if ( type ( sql ) == "table" and numrows > 0 ) then 
        setElementData ( who, "VIP", sql [ 1 ] [ "level" ] ) 
    end 
end 

Didn't work...

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