FoxSnow Posted November 12, 2020 Share Posted November 12, 2020 Hi , i'm a newbie on MTA script and i don't know how make for save the position in MYSQL Database ... Please someone help me ? Link to comment
Hydra Posted November 12, 2020 Share Posted November 12, 2020 This example is with setAccountData & getAccountData, not what you requested but maybe you will use it function saveStuff() local theAcc = getPlayerAccount(source) if theAcc and not isGuestAccount(theAcc) then local x, y, z = getElementPosition(source) setAccountData(theAcc, "posX", x) setAccountData(theAcc, "posY", y) setAccountData(theAcc, "posZ", z) end end addEventHandler("onPlayerQuit", getRootElement(), saveStuff) function loadStuff(_,account) if account then local x, y, z = getAccountData(account, "posX"), getAccountData(account, "posY"), getAccountData(account, "posZ") setElementPosition(source, x, y, z) end end addEventHandler("onPlayerLogin", getRootElement(), loadStuff) Link to comment
FoxSnow Posted November 12, 2020 Author Share Posted November 12, 2020 3 hours ago, Hydra said: This example is with setAccountData & getAccountData, not what you requested but maybe you will use it function saveStuff() local theAcc = getPlayerAccount(source) if theAcc and not isGuestAccount(theAcc) then local x, y, z = getElementPosition(source) setAccountData(theAcc, "posX", x) setAccountData(theAcc, "posY", y) setAccountData(theAcc, "posZ", z) end end addEventHandler("onPlayerQuit", getRootElement(), saveStuff) function loadStuff(_,account) if account then local x, y, z = getAccountData(account, "posX"), getAccountData(account, "posY"), getAccountData(account, "posZ") setElementPosition(source, x, y, z) end end addEventHandler("onPlayerLogin", getRootElement(), loadStuff) Thanks for your answer but i don't want use setAccountData.. i need a example with dbExec for save the position in my DataBase 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