Jump to content

xml question


Castillo

Recommended Posts

Posted

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

Admin.png
Posted

Just a thought:

You are addicted to XML i see :P

Notice that XML after getting big is much slower than SQL. And SQL is actually easier :)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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 :P

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

post your small xml example, and i'll show you what you need to change if you dont understand Static-X

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

<playerfriends> 
    <user account="2F71C8856F19CD2523627FFCE58BA3A1"> 
        <friend name="Chase_Oquinn" serial="B92D9BF5F9C1AE0A514F445EBFC63394" /> 
        <friend name="[MM]Castillo" serial="2F71C8856F19CD2523627FFCE58BA3A1" /> 
    </user> 
</playerfriends> 

that?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
  
    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 
  

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...