Hi i get the error:
Timer Error: gamemode\playerdata.lua:XX: attempt to compare number with string
XX being the line where in the code below, I do curpay > 0
These are the SQL queries ran to create and read the tables/values. as far as I can see, they are Integers not strings.
sql.Query ( “CREATE TABLE player_info ( unique_id varchar(255), money int, wage int)” )
sql.Query( “INSERT INTO player_info (unique_id
, money
, wage
)VALUES (’”…steamID…"’, ‘1000’, ‘45’)" ) --set default values
[lua]
for k,v in pairs( player.GetAll() ) do
local steamID = v:SteamID()
local curmoney = sql.QueryValue( "SELECT money FROM player_info WHERE unique_id = '"..steamID.."'" )
local curpay = sql.QueryValue( "SELECT wage FROM player_info WHERE unique_id = '"..steamID.."'" )
local newamt = curmoney + curpay
sql.Query("UPDATE player_info SET money = "..newamt.." WHERE unique_id = '"..steamID.."'")
v:SetNWInt("money", newamt)
if curpay > 0 then
v:PrintMessage( HUD_PRINTTALK, "You received: $"..curpay..".
" )
else
v:PrintMessage( HUD_PRINTTALK, "You did not receive a salary because your wage is 0.
" )
end
end
[/lua]