SkatCh Posted January 19, 2015 Share Posted January 19, 2015 Hi guys please i have a question , how can i save vehicle handling , (Property , Value) , i think i need to use "getVehicleHandling" but i don't know how to extract the value from this table , can anyone help me . Link to comment
Enkanet Posted January 20, 2015 Share Posted January 20, 2015 You should use SQL for this. Make a structure and the functions that you need, setVehicleHandling() getVehicleHandling() onPlayerJoin() onPlayerQuit() Also I suggest you to use mta_mysql.dll for sql... https://wiki.multitheftauto.com/wiki/Modules/MTA-MySQL Link to comment
Enkanet Posted January 20, 2015 Share Posted January 20, 2015 You should use SQL for this. Make a structure and the functions that you need, setVehicleHandling() getVehicleHandling() onPlayerJoin onPlayerQuit Also I suggest you to use mta_mysql.dll for sql... https://wiki.multitheftauto.com/wiki/Modules/MTA-MySQL Link to comment
SkatCh Posted January 20, 2015 Author Share Posted January 20, 2015 Bro i know those function but i'm asking how to store vehicle handling data inside table. i tried this but i don't know if it's working or not because i didn't test it yet: for i, hand in ipairs (getVehicleHandling(theVehicle)) do if handling == "" then handling = hand else handling = handling..","..hand end end Link to comment
SkatCh Posted January 21, 2015 Author Share Posted January 21, 2015 thx bro for your help but i need it with sql and i know how to do it ; but tell me is this correct , -- when the player destroy the car local handling == "" for i, hand in ipairs (getVehicleHandling(theVehicle)) do if handling == "" then handling = hand else handling = handling..","..hand end end Link to comment
TAPL Posted January 21, 2015 Share Posted January 21, 2015 At first line you have two == but you suppose to have one only. Also the table isn't numeric index therefore you should use pairs instead of ipairs. Moreover the property centerOfMass is returned in table so you have table inside table. Link to comment
SkatCh Posted January 21, 2015 Author Share Posted January 21, 2015 Yeh exactly that's why i want as you said i need to use to two table but the problem i don't which the proprety , wich is the value. can you help me make it ; this is my try you mean like this local handling = "" for i, hand in pairs (getVehicleHandling(theVehicle)) do for i, v in pairs (hand) do end end Link to comment
TAPL Posted January 21, 2015 Share Posted January 21, 2015 I just wonder what wrong with JSON? You don't need any kind of variable to make the string. JSON will convert the table to string already all you have to do is to store the string into account data or file or xml or even db. Link to comment
SkatCh Posted January 21, 2015 Author Share Posted January 21, 2015 ok bro i will follow ur advice but how can i do it with JSON and how to sotre it insde db Link to comment
TAPL Posted January 21, 2015 Share Posted January 21, 2015 Create a db table with two columns one for the account name and another for the table string. toJSON -- convert table to string. fromJSON -- convert string to table again. toJSON -- > from table to string fromJSON -- > from string to table Link to comment
SkatCh Posted January 22, 2015 Author Share Posted January 22, 2015 example you mean like this: toJSON(getVehicleHandling(veh)) -- Handling ------------------------------ for k, i in ipairs( fromJSON( Handling )) do setVehicleHandling(veh,k,i) end Link to comment
TAPL Posted January 22, 2015 Share Posted January 22, 2015 At first line you have two == but you suppose to have one only. Also the table isn't numeric index therefore you should use pairs instead of ipairs. Moreover the property centerOfMass is returned in table so you have table inside table. Link to comment
SkatCh Posted January 22, 2015 Author Share Posted January 22, 2015 Sorry bro really i need your help can you give me an example. Link to comment
TAPL Posted January 23, 2015 Share Posted January 23, 2015 local hTable = getVehicleHandling(vehicle) local hString = toJSON(hTable) setAccountData(account, "Handling", hString) ------------------------------ local hString = getAccountData(account, "Handling") local hTable = fromJSON(hString) for property, value in pairs(hTable) do setVehicleHandling(vehicle, property, value) end 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