Prever77 Posted May 27, 2023 Share Posted May 27, 2023 (edited) Hi. I wanted to make timer on server side that will updating players money. Cause my money in the corner are based on custom dxText that download money status from getPlayerMoney. And here i have a problem. When i want to setPlayerMoney ,from database i still receive only playername. For sure i did something wrong. I checked PHP code in my SQL tab (XAMPP) and it worked as intended. Here is the code. Please Help. I'll be thankfull local dbc = dbConnect("") setTimer("onClientRender",function(nick) local pn = getPlayerName local dbq = dbQuery(dbc,"SELECT money FROM users WHERE nickname='pn'") setPlayerMoney(pn,dbq)1000,0) in dbc is defined utf8, same as my sql database Edit1 and variable coming from database should be INT Edited May 27, 2023 by Prever77 Link to comment
βurak Posted May 27, 2023 Share Posted May 27, 2023 (edited) I haven't tested it but it could be something like this you will need to call the loadPlayerMoney function local db_name = "your db name" --fill your info local db_host = "localhost" local db_user = "your username" --fill your info local db_pass = "your password" --fill your info local DbConnection = dbConnect("mysql", "dbname="..db_name..";host="..db_host..";charset=utf8", db_user, db_pass, "share=1") function loadPlayerMoney(player) local _player = player local playerNick = getPlayerName(_player) dbQuery( function(query, player) local result = dbPoll(query, 0) if(#result <= 0) then return end --if result table 0 dont go for _,data in pairs(result) do setPlayerMoney(player, data["money"]) --set money break end end,{_player}, DbConnection, "SELECT money FROM users WHERE nickname=? LIMIT 1", playerNick) end Edited May 27, 2023 by Burak5312 Link to comment
Prever77 Posted May 28, 2023 Author Share Posted May 28, 2023 After few modification code works fine. Your PHP line helped a lot. Thanks I think topic can be closed Link to comment
βurak Posted May 28, 2023 Share Posted May 28, 2023 (edited) You're welcome. if you open more threads i will help you as much as i can Edited May 28, 2023 by Burak5312 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now