Castillo Posted July 10, 2010 Share Posted July 10, 2010 (edited) hey there, im scripting a character system and im actually using account data functions for it, the problem is that when i make 1 character it sets the data already but when i want to make 2 characters the problem is that the data already exist so i would like to know how i can make somthing like a id for every character i create, here is code of creation. Edited July 16, 2010 by Guest Link to comment
m4rsje Posted July 10, 2010 Share Posted July 10, 2010 i dont know if you want it, but i think you can better use sql you wont have the problem, and you wont get problems later on with other scripts;) in sql he just sorts it, and the accounts wont get bugged, Link to comment
Castillo Posted July 10, 2010 Author Share Posted July 10, 2010 i dont know if you want it,but i think you can better use sql you wont have the problem, and you wont get problems later on with other scripts;) in sql he just sorts it, and the accounts wont get bugged, SQL its hard for me, also XML, trying to make it via XML but dont get anything of how works. Link to comment
MaddDogg Posted July 10, 2010 Share Posted July 10, 2010 You could do something like this: setAccountData(getPlayerAccount(source), charid .. ".charname",nombre) Link to comment
Castillo Posted July 11, 2010 Author Share Posted July 11, 2010 You could do something like this: setAccountData(getPlayerAccount(source), charid .. ".charname",nombre) this dont actually works, but nevermind i started to make it using xml , if i need help with it i will re-post. Link to comment
Castillo Posted July 12, 2010 Author Share Posted July 12, 2010 (edited) hey again, i started to build it with xml but i have a problem when loading the characters, i will post the code and the error i get (im noob at xml btw, just started to learn ) Edited July 14, 2010 by Guest Link to comment
MaddDogg Posted July 12, 2010 Share Posted July 12, 2010 xmlNodeGetChildren(root) returns a table with all nodes in it. But then you use this table again in the same function, which is your problem. The function expects a node, not a table full of nodes. So, this... ipairs (xmlNodeGetChildren (db)) should just be... ipairs (db) Also, your function "findAccountChildInDB" will just return the node of the player's values, so you can't loop within it. If you want to loop through all the characters, which are listed under the player's node, you have to again make use of xmlNodeGetChildren at this point and then loop through the returned table (if it is one, anyway) and get the attributes for every loop step. Link to comment
Castillo Posted July 12, 2010 Author Share Posted July 12, 2010 xmlNodeGetChildren(root) returns a table with all nodes in it.But then you use this table again in the same function, which is your problem. The function expects a node, not a table full of nodes. So, this... ipairs (xmlNodeGetChildren (db)) should just be... ipairs (db) Also, your function "findAccountChildInDB" will just return the node of the player's values, so you can't loop within it. If you want to loop through all the characters, which are listed under the player's node, you have to again make use of xmlNodeGetChildren at this point and then loop through the returned table (if it is one, anyway) and get the attributes for every loop step. now i get a different error in that line, "bad argument #1 to "pairs" (table exptected, got userdata)" Link to comment
MaddDogg Posted July 12, 2010 Share Posted July 12, 2010 As I said, you can't loop through the value returned by your function. You still have to get all children from this value (which is a node) and THEN you can loop through the table holding the children of your player node. Link to comment
Castillo Posted July 12, 2010 Author Share Posted July 12, 2010 As I said, you can't loop through the value returned by your function.You still have to get all children from this value (which is a node) and THEN you can loop through the table holding the children of your player node. Where do i have to use "xmlNodeGetChildren"? Link to comment
MaddDogg Posted July 12, 2010 Share Posted July 12, 2010 local characterNodes = xmlNodeGetChildren(accountRoot) for _,node in pairs(characterNodes) do local atributes = xmlNodeGetAttributes(node) local name = atributes.name triggerClientEvent ( source, "addcharacter", getRootElement(), name) end That's how it should look like. Link to comment
Castillo Posted July 12, 2010 Author Share Posted July 12, 2010 (edited) solved. Edited July 16, 2010 by Guest Link to comment
Castillo Posted July 12, 2010 Author Share Posted July 12, 2010 (edited) edit: solved. Edited July 14, 2010 by Guest Link to comment
50p Posted July 12, 2010 Share Posted July 12, 2010 i ve done some more code to check the last problem i have,... I guess you haven't read this: https://forum.multitheftauto.com/viewtop ... 91&t=27027 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