drk Posted February 13, 2012 Share Posted February 13, 2012 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 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
Castillo Posted February 13, 2012 Share Posted February 13, 2012 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
drk Posted February 13, 2012 Author Share Posted February 13, 2012 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 Link to comment
Castillo Posted February 13, 2012 Share Posted February 13, 2012 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
drk Posted February 13, 2012 Author Share Posted February 13, 2012 Something I will send you the whole code via PM. Edit: Level system is working now. Only top hunter, I get false in all values Link to comment
Castillo Posted February 13, 2012 Share Posted February 13, 2012 I wasn't talking about the second script, I meant the first one. Link to comment
drk Posted February 14, 2012 Author Share Posted February 14, 2012 Top hunter... My bad, I forget that when all players quit server element data is deleted... Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now