MySQL PData is a simple and effecient way to save strings using MySQL without the need of creating multiple, scattered out scripts relying on different databases and tables. The installation process is extremely straightforward, simply drag 'n' drop the repository contents and insert your database details in lua/mysql_pdata/sv_config.lua. Please keep in mind that this is supposed to be used as a MySQL wrapper for your scripts, you should only add this to your addons once and after that simply use the functions explained below.
Similarily to PData this only allows saving strings, that being said you're able to save data types that can be converted to string using tostring, for example integers. You can also, in theory, store tables using util.TableToJSON. This has not been intensively tested, which means there could be some errors or sub-optimal solutions - I encourage everyone to submit issues/pull requests.
PLAYER:SetData(strKey, strData)
PLAYER:GetData(strKey, funcCallback(strData))Example:
hook.Add("PlayerInitialSpawn", "MySQLPDataTest", function(pPlayer)
pPlayer:SetData("money", 1500)
end)
hook.Add("PlayerSay", "MySQLPDataTest", function(pPlayer, strText, bTeam)
pPlayer:GetData("money", function(strData)
pPlayer:ChatPrint("You currently have $"..strData.." in your wallet!")
end)
end)- fesh (Help)
- GlorifiedPig (Idea & Help)
- FredyH (MySQLOO)