Jump to content

Bolean values and SQL


drk

Recommended Posts

Can someone heelp me with SQL and boolean values?

I'm trying to make a level system but I get: bad argument @ getPlayerName and attempt to concatenate a bolean value

addEventHandler( 'onPlayerLogin',root, 
    function( ) 
      local level = getAccountData(getPlayerAccount(source),'My Level') 
        timer[ source ] = setTimer( 
            function() 
                local account = getPlayerAccount( source ) 
                if not isGuestAccount( account ) then 
                    local result = executeSQLQuery("SELECT money FROM Money WHERE player= '"..getPlayerName(source).."'") - ERROR in this line 
                    local money = tonumber(result[1]['money']) 
                    if money <= tonumber(50000) and getElementData(source,'Race Wins') < 10 then 
                        setAccountData( account,'My Level','Newbie' ) 
                        setElementData( source,'Level','Newbie' ) 
                    elseif money <= tonumber(250000) and money > tonumber(50000) and getElementData(source,'Race Wins') < 50 and getElementData(source,'Race Wins') > 10 then 
                        setAccountData( account,'My Level','Regular' ).... 

And I get False on my top hunter return values :S

addEventHandler( 'onGamemodeMapStart',root, 
    function() 
        local result = executeSQLQuery ( "SELECT * FROM Top WHERE map = '" ..map.. "'" ) 
         if not result or #result == 0 then 
            executeSQLQuery( "INSERT INTO Top VALUES ('"..map.."','No one', '"..tonumber(100)..":"..tonumber(100).."')" ) 
            local resultt = executeSQLQuery ( "SELECT * FROM Top WHERE map = '" ..map.. "'" ) 
              setElementData( root,'playerName',tostring( resultt[1]['player'] ) ) 
              setElementData( root,'timeMT',tostring( resultt[1]['time'] ) ) 
              triggerClientEvent('clientStart',root) 
         else 
              setElementData( root,'playerName',tostring( result[1]['player'] ) ) 
              setElementData( root,'timeMT',tostring( result[1]['time'] ) ) 
              triggerClientEvent('clientStart',root) 
        end 
    end 
) 

Isn't my whole code.

Link to comment

You must add 'source' at the end of the timer function.

addEventHandler( 'onPlayerLogin',root, 
    function( ) 
      local level = getAccountData(getPlayerAccount(source),'My Level') 
        timer[ source ] = setTimer( 
            function (player) 
                local account = getPlayerAccount( player ) 
                if not isGuestAccount( account ) then 
                    local result = executeSQLQuery("SELECT money FROM Money WHERE player= '"..getPlayerName(player).."'") 
                    local money = tonumber(result[1]['money']) 
                    if money <= tonumber(50000) and getElementData( - ERROR in this line,'Race Wins') < 10 then 
                        setAccountData( account,'My Level','Newbie' ) 
                        setElementData(  - ERROR in this line,'Level','Newbie' ) 
                    elseif money <= tonumber(250000) and money > tonumber(50000) and getElementData(player,'Race Wins') < 50 and getElementData(player,'Race Wins') > 10 then 
                        setAccountData( account,'My Level','Regular' ).... 

Link to comment
addEventHandler( 'onPlayerLogin',root, 
    function( ) 
      local level = getAccountData(getPlayerAccount(source),'My Level') 
        timer[ source ] = setTimer( 
            function (player) 
                local account = getPlayerAccount( player ) 
                if not isGuestAccount( account ) then 
                    local result = executeSQLQuery("SELECT money FROM Money WHERE player= '"..getPlayerName(player).."'") 
                    local money = tonumber(result[1]['money']) 
                    if money <= tonumber(50000) and getElementData( - ERROR in this line,'Race Wins') < 10 then 
                        setAccountData( account,'My Level','Newbie' ) 
                        setElementData(  - ERROR in this line,'Level','Newbie' ) 
                    elseif money <= tonumber(250000) and money > tonumber(50000) and getElementData(player,'Race Wins') < 50 and getElementData(player,'Race Wins') > 10 then 
                        setAccountData( account,'My Level','Regular' ).... 

You must add 'source' at the end of the timer function.

Its what I did before and don't work :S

Link to comment
addEventHandler( 'onGamemodeMapStart',root, 
    function (map) 
        local map = getResourceName(map) 
        local result = executeSQLQuery ( "SELECT * FROM Top WHERE map = '" ..map.. "'" ) 
         if (not result or #result == 0) then 
            executeSQLQuery( "INSERT INTO Top VALUES ('"..map.."','No one', '"..tonumber(100)..":"..tonumber(100).."')" ) 
            local resultt = executeSQLQuery ( "SELECT * FROM Top WHERE map = '" ..map.. "'" ) 
              setElementData( root,'playerName',tostring( resultt[1]['player'] ) ) 
              setElementData( root,'timeMT',tostring( resultt[1]['time'] ) ) 
              triggerClientEvent('clientStart',root) 
         else 
              setElementData( root,'playerName',tostring( result[1]['player'] ) ) 
              setElementData( root,'timeMT',tostring( result[1]['time'] ) ) 
              triggerClientEvent('clientStart',root) 
        end 
    end 
) 

If it didn't work, then post your whole script.

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