Castillo Posted November 13, 2010 Share Posted November 13, 2010 hi, i have a little problem on my "friends list" resource, i noticed that you aren't able to add a friend if someone else added him, i know why this happends but i have no idea how i can fix it, the problem must be that i'm checking all accounts not only mine. here is part of code: local root = getResourceConfig("data.xml") local index = getIndex (getPlayerSerial(client),root) for i , v in pairs ( xmlNodeGetChildren ( root ) ) do for s , t in pairs ( xmlNodeGetChildren ( v ) ) do local att = xmlNodeGetAttribute ( t, "name" ) local rn = string.lower ( tostring ( nametext ) ) local ra = string.lower ( att ) if ( rn == ra ) then outputChatBox ( "A friend with this name already exist." , client , 255 , 0 , 0 ) return false end end end i hope someone know how i can fix it. Thanks in advance. Link to comment
Static-X Posted November 13, 2010 Share Posted November 13, 2010 You just need to make an nodeattribute for the account name for the player who added the friend, like when the players add another friend make it get the player's account who added the friend and check all the lines which has Account nodeattribute as ( e.g )"Static-X", then get the account of the player who I wanted to add, if the friendAccount is "Pulsar" it will return end. Link to comment
dzek (varez) Posted November 13, 2010 Share Posted November 13, 2010 Just a thought: You are addicted to XML i see Notice that XML after getting big is much slower than SQL. And SQL is actually easier Link to comment
Castillo Posted November 13, 2010 Author Share Posted November 13, 2010 yeah varez, i know i may convert it to sqlite later but for now i'm trying to create it with XML. P.S: i don't really get what do you mean static Link to comment
dzek (varez) Posted November 13, 2010 Share Posted November 13, 2010 post your small xml example, and i'll show you what you need to change if you dont understand Static-X Link to comment
Castillo Posted November 13, 2010 Author Share Posted November 13, 2010 <playerfriends> <user account="2F71C8856F19CD2523627FFCE58BA3A1"> <friend name="Chase_Oquinn" serial="B92D9BF5F9C1AE0A514F445EBFC63394" /> <friend name="[MM]Castillo" serial="2F71C8856F19CD2523627FFCE58BA3A1" /> </user> </playerfriends> that? Link to comment
dzek (varez) Posted November 13, 2010 Share Posted November 13, 2010 local playerSerial = getPlayerSerial(client) -- added, fix if needed local root = getResourceConfig("data.xml") local index = getIndex (getPlayerSerial(client),root) for i , v in pairs ( xmlNodeGetChildren ( root ) ) do local xmlNodeUserSerial = xmlNodeGetAttribute(v,"account") --- added if (xmlNodeUserSerial==playerSerial) then -- added for s , t in pairs ( xmlNodeGetChildren ( v ) ) do local att = xmlNodeGetAttribute ( t, "name" ) local rn = string.lower ( tostring ( nametext ) ) local ra = string.lower ( att ) if ( rn == ra ) then outputChatBox ( "A friend with this name already exist." , client , 255 , 0 , 0 ) return false end end end -- added, lol end Link to comment
Castillo Posted November 13, 2010 Author Share Posted November 13, 2010 thank you varez, new version uploaded https://community.multitheftauto.com/index.php?p=resources&s=details&id=1267 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