Search code examples
sqlsqlitegarrys-mod

Set floor/round value sql value


I'm developing a bank system for Garry's Mod (GLua) using sql for it. I want to create a "profit" that adds a percentage to every player every minute: The sql query is this one:

UPDATE 
     darkrp_player 
SET 
     bank = bank * "..multiplier

This is what it returns when running that query on DBBrowser:

no such function: floor: UPDATE darkrp_player SET bank = floor(bank * 1.25)

multiplier var is (profit/100) + 1 profit is another var

So my problem is that everytime I run that query, every bank row is full of decimals, example:

profit = 25
--before query:
'bank' = 2
--after query:
'bank' = 2.5

My question is: How can I set floor to the value I'm setting to 'bank'? I could get everybody's 'bank' value and set it one by one, but that would be really really complicated... So, i'm looking something like

UPDATE 
     darkrp_player 
SET 
     bank = floor(bank * "..multiplier..")"

I'm sorry if you haven't understood something, you can ask me whatever related to my problem, I'll be glad to answer you. THANKS!


Solution

  • If there is no FLOOR function on that built-in server, try this:

    SELECT CAST('67.896' AS int),  CAST('5.57' AS int)