So how would I exactly save my money using tmysql4.
Are you using DarkRP? If so, it already has built-in tmysql4 support. All you have to do is make sure you do not have the MySQLoo module installed as well, and of course update the config to match your database's credentials.
Something like this
[code]
function SetMoney(pl, amount, callback)
db:Query('UPDATE player_data SET Money=' .. amount .. ' WHERE SteamID=' .. pl:SteamID64(), callback)
end
[/code]
Here's an example currency system that's only missing the load / save feature: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/simple_currency_system/simple_currency_system.zip[/url]
The reason I'm providing this is to serve as an example because it calls the load / save in appropriate places. StonedPenguin is correct in terms of the query although I'd use SQLStr to ensure the amount value isn't a string to delete the database ( although if someone got to things like that assuming you don't trust user input, then it wouldn't matter anyways )..
I'd recommend loading on join, and saving on DC or map change with an intermittent save ( 5 minutes if the data has changed ) to ensure the data is saved even in the event of a crash...
Example queries / structures: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/database/basic_queries_and_query_formats_used_to_check_for_existing_row.lua.html[/url]
Sorry, you need to Log In to post a reply to this thread.