Headshot4Fun Posted August 25, 2011 Share Posted August 25, 2011 (edited) Well. Im trying to figure out why every script i did with setAccountData failed. By the way. Now im here to ask for help Here it is the code -------------------------------------------------------- -- Salvar informações no LOGIN/EXIT ------------------ function onPlayerQuit ( ) local conta = getPlayerAccount ( source ) if ( conta ) then armas = {} for i = 0,12 do local arma = getPedweapon(source,i) local ammu = getPedTotalAmmo(source,i) if ammu > 0 then table.insert(armas, {arma,ammu}) end end local x,y,z = getElementPosition(source) local rx,ry,rz = getElementRotation(source) local salvarConta = { ["dinheiro"] = getPlayerMoney ( source ); ["skin"] = getElementModel(source); ["posX"] = x; ["posY"] = y; ["posZ"] = z; ["rot"] = rx; ["dim"] = getElementDimension(source); ["int"] = getElementInterior(source) } setAccountData(conta,"char.armas",armas) for i,v in ipairs(salvarConta) do setAccountData(conta,"char."..i,tostring(v)) end end end function onPlayerJoin ( ) local conta = getPlayerAccount ( source ) local din = getAccountData(conta,"char.dinheiro") setPlayerMoney(source,din) end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerJoin ) -------------------------------------------------------- -------------------------------------------------------- When i log in nothing happens. And no errors in /debugscript 3 and in the server console. Edit: Yes, the script is in the ACL as admin Edited August 25, 2011 by Guest Link to comment
Fabio(GNR) Posted August 25, 2011 Share Posted August 25, 2011 I dont see setPlayerData in your script... If you want to write to account use setAccountData, writing to element is setElementData ( will be destroyed when player leaves ) EDIT: You already have setAccountData, sorry. I cant really help you with this ( my LUA is bad ) Good luck tough! Link to comment
Headshot4Fun Posted August 25, 2011 Author Share Posted August 25, 2011 I dont see setPlayerData in your script... If you want to write to account use setAccountData, writing to element is setElementData ( will be destroyed when player leaves )EDIT: You already have setAccountData, sorry. I cant really help you with this ( my LUA is bad ) Good luck tough! Yeah. I misspelled it again. My head can't just think right when im confused >__<But thanks for your help bro Link to comment
JR10 Posted August 25, 2011 Share Posted August 25, 2011 Here is the thing, how do you expect the player to have an account, (which is not guest) when he joins? use onPlayerLogin. Link to comment
Headshot4Fun Posted August 25, 2011 Author Share Posted August 25, 2011 Here is the thing, how do you expect the player to have an account, (which is not guest) when he joins?use onPlayerLogin. Take a look at the script. Look the 2 last lines. Look the event handlers, i did this just to see who would try this without reading it all But i still need help after all Link to comment
JR10 Posted August 25, 2011 Share Posted August 25, 2011 Oh. Try: function onPlayerJoin ( _ , conta ) local din = getAccountData(conta,"char.dinheiro") setPlayerMoney(source,din) end Link to comment
Headshot4Fun Posted August 26, 2011 Author Share Posted August 26, 2011 Oh.Try: function onPlayerJoin ( _ , conta ) local din = getAccountData(conta,"char.dinheiro") setPlayerMoney(source,din) end Didn't worked. I Loged in, Set my money, quit, connect, login, and nothing No debugscript or console errors Link to comment
JR10 Posted August 26, 2011 Share Posted August 26, 2011 function onPlayerJoin ( ) local conta = getPlayerAccount ( source ) local din = getAccountData(conta,"char.1") setPlayerMoney(source,din) end Link to comment
Headshot4Fun Posted August 26, 2011 Author Share Posted August 26, 2011 function onPlayerJoin ( ) local conta = getPlayerAccount ( source ) local din = getAccountData(conta,"char.1") setPlayerMoney(source,din) end Didn't work Link to comment
JR10 Posted August 26, 2011 Share Posted August 26, 2011 -------------------------------------------------------- -- Salvar informações no LOGIN/EXIT ------------------ function onPlayerQuit ( ) local conta = getPlayerAccount ( source ) if ( conta ) then armas = {} for i = 0,12 do local arma = getPedweapon(source,i) local ammu = getPedTotalAmmo(source,i) if ammu > 0 then table.insert(armas, {arma,ammu}) end end local x,y,z = getElementPosition(source) local rx,ry,rz = getElementRotation(source) local salvarConta = { [1] = getPlayerMoney ( source ); [2] = getElementModel(source); [3] = x; [4] = y; [5] = z; [6] = rx; [7] = getElementDimension(source); [8] = getElementInterior(source) } setAccountData(conta,"char.armas",armas) for i,v in ipairs(salvarConta) do setAccountData(conta,"char."..tostring(i),tostring(v)) end end end function onPlayerJoin ( ) local conta = getPlayerAccount ( source ) local din = getAccountData(conta,"char.1") setPlayerMoney(source,din) end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerJoin ) -------------------------------------------------------- -------------------------------------------------------- Link to comment
Headshot4Fun Posted August 26, 2011 Author Share Posted August 26, 2011 -------------------------------------------------------- -- Salvar informações no LOGIN/EXIT ------------------ function onPlayerQuit ( ) local conta = getPlayerAccount ( source ) if ( conta ) then armas = {} for i = 0,12 do local arma = getPedweapon(source,i) local ammu = getPedTotalAmmo(source,i) if ammu > 0 then table.insert(armas, {arma,ammu}) end end local x,y,z = getElementPosition(source) local rx,ry,rz = getElementRotation(source) local salvarConta = { [1] = getPlayerMoney ( source ); [2] = getElementModel(source); [3] = x; [4] = y; [5] = z; [6] = rx; [7] = getElementDimension(source); [8] = getElementInterior(source) } setAccountData(conta,"char.armas",armas) for i,v in ipairs(salvarConta) do setAccountData(conta,"char."..tostring(i),tostring(v)) end end end function onPlayerJoin ( ) local conta = getPlayerAccount ( source ) local din = getAccountData(conta,"char.1") setPlayerMoney(source,din) end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerJoin ) -------------------------------------------------------- -------------------------------------------------------- Ive tryed alot, and i found the problem was the table. All i want is to save the informations using a table and a loop. Using the "char.itemname". But looks like the only way to do this is with numbers... Isn't there another way?Like, getAccountData ( conta, "char.dinheiro" )) would return the money. Not getAccountData(conta,"char.1"). i Want to make it easy to change you know... but im failing for like 2 months trying to make this work Link to comment
Cadu12 Posted August 26, 2011 Share Posted August 26, 2011 onPlayerJoin doesnt works with set/getAccountData, becuase he didnt used /login if he connected Only you have to use command /login and then get/setAccountData P.S: Are you from brazil? I am from brazil too Link to comment
Headshot4Fun Posted August 26, 2011 Author Share Posted August 26, 2011 onPlayerJoin doesnt works with set/getAccountData, becuase he didnt used /login if he connectedOnly you have to use command /login and then get/setAccountData P.S: Are you from brazil? I am from brazil too Have you read the full thread? Você leu o topico inteiro? Link to comment
Cadu12 Posted August 26, 2011 Share Posted August 26, 2011 Change to setAccountData(conta,"char."..tostring(i), tonumber(v)) Se vc quer ajudar, me add no skype Link to comment
Headshot4Fun Posted August 26, 2011 Author Share Posted August 26, 2011 Change to setAccountData(conta,"char."..tostring(i), tonumber(v)) Se vc quer ajudar, me add no skype Ja consegui ageitar. Mas vlwI've found the problem and fixed this. Thansk everybody for the help 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