Basewars money capping, Something to do with strings?


if ( !sql.TableExists( "rpdmmoney" ) ) then
	
	sql.Query( "CREATE TABLE IF NOT EXISTS rpdmmoney (Money TEXT, SteamID TEXT)" )
end

local sql		=	sql
local Format	=	Format
local SQLStr	=	SQLStr

local meta = FindMetaTable( "Player" )

local function FormatID( str )
	
	return str:lower():gsub( ":", "_" )
end

function UpdateMoney( self, value )
	
	umsg.Start( "MoneyChange", self )
		
		umsg.Short( 0 )
		umsg.Long( value )
		
	umsg.End( )
end

function SetMoney( self )
	local id
	
	id = self:SteamID()
	id = FormatID( id )
	
	if ( tonumber( self.Money ) ~= nil ) then
		local str = Format( "UPDATE rpdmmoney SET Money = %s WHERE SteamID = %s", self.Money, SQLStr( id ) )
		
		sql.Query( str )
	end
end

function GetMoney( self )
	local id, money
	
	id = self:SteamID()
	id = FormatID( id )
	
	money = sql.QueryValue( Format( "SELECT Money FROM rpdmmoney WHERE SteamID = %s", SQLStr( id ) ) )
	money = tonumber( money ) || sql.Query( Format( "INSERT INTO rpdmmoney (SteamID, Money) VALUES (%s, 5000)", SQLStr( id ) ) ) || 5000
	
	self.Money = math.min( math.ceil( money ), 214748364799 )
	
	UpdateMoney( self, self.Money )
end

// aliases for nigtits
setMoney = SetMoney
getMoney = GetMoney

/*function getMoney(player)
	
	local IDSteam = string.lower(string.gsub(player:SteamID(), ":", ""))
	
	local money = sql.QueryValue("SELECT Money FROM rpdmmoney WHERE SteamID='"..IDSteam.."'")
	//PrintTable(table)

	local plmoney = 25000
	if money != nil then
		plmoney = math.ceil(tonumber(money))
	else
		Msg("Adding new user: " ..IDSteam.."
")
		sql.Query("INSERT INTO rpdmmoney (Money, SteamID) VALUES ('"..IDSteam.."', 5000)")
	end
	player:GetTable().Money = plmoney
	// if its more than a long, just basically say A LOT
	if (player:GetTable().Money>10000000000000) then
		plmoney = 10000000000000
	end
	umsg.Start("MoneyChange", player)
		umsg.Short(0)
		umsg.Long(plmoney)
	umsg.End()
end*/

/*function setMoney(player, amount)
	local IDSteam = string.lower(string.gsub(player:SteamID(), ":", ""))
	//player:GetTable().Money = player:GetTable().Money+amount
	if tonumber(player:GetTable().Money)!=nil then
		sql.Query("UPDATE rpdmmoney SET Money = ".. tostring(player:GetTable().Money .. "WHERE SteamID='"..IDSteam.."'"))
	end
end*/

The money wont go past 2.1 billion dollars for some reason, Is it something to do with how it is layed out?

This line:


self.Money = math.min( math.ceil( money ), 214748364799 )

Is saying that if your money is greater than 214748364799 then it will return 214748364799.

I will try and edit that

[editline]25th January 2014[/editline]

It is still capped, i edited the numbers and tried removing it all together

Try this:


self.Money = math.min( math.ceil( money ), 21474836479900 )

If that doesn’t work, I will take another look.

Still does not work, But thanks for the continuous help i appreciate it

Try this:


self.Money =  math.ceil( money )

If that doesn’t work then the issue is somewhere else, or it is too large for usermessages.

Still broken, I was wondering if it is the way that it is formatted in sql or something?

This is due to MySQL and the maximum number for a 32 bit storage system is 2^31 − 1. Change the data type in your MySQL columns, should fix it.

There is no visible files anywhere for this, And im new to lua, Let alone SQL :confused:

[editline]25th January 2014[/editline]

Would you edit the money.lua?

No, You would edit the MySQL column data type. Open up your preferred MySQL database managing tool, select the database you are using, right click on the appropriate table and select ‘modify table’. Change the data data to something like ‘BIG INT’.

The thing is, the rpdmoney file appears no where on my servers drive :L

Do you even know how a MySQL server works?

No, thats why i came here for help D:
Well i know it stores data in columns something like

STEAMID MONEY

And then it selects the row where steamid is = to your own and selects the money data, that about all

just execute this sql



ALTER TABLE rpdmmoney MODIFY Money BIGINT


How would you go about doing that?

im going to asume that you use the database in garrysmod/garrysmod/sv.db
open that file with any sqllite manger such as this one
now click the tab that says “execute sql” and execute the code above

How do you use that addon, im completely lost on how to execute it or even open that extension

[editline]25th January 2014[/editline]

Just cant find the way to open the extension

open firefox, press the firefox icon, press webdevloper, press sqllite manger at the very bottom OR
open firefox, press alt, press tools, press sqllite manger

thats strange but you can also just select your table in the left side then click structure, right click money, click “Edit column” and then change the new column type to bigint