Jump to content

What's wrong with my sintax?


12p

Recommended Posts

Posted (edited)

Gonna update and fix my 3D Texts resource.

I'm fixing the code for loading texts from XML files of a resource that is started.

The trouble is "Bad argument @ xmlNodeGetChildren ( in this case, at position 5 )

function loadText ( resource ) 
    if not resource and source then resource = source  
    elseif not resource and not source then return end 
    if not fileExists ( ":" .. getResourceName ( resource ) .."/texts.xml" ) then return end 
    local node = xmlLoadFile ( ":" .. getResourceName ( resource ) .."/texts.xml" ) 
    for i, t in ipairs ( xmlNodeGetChildren ( node ) ) do 
    --Down this part is done, no need to show it because it has no trouble 
end 
  
addEventHandler ( "onResourceStart", getRootElement ( ), loadText ) 

The XML file I'm loading is this (it's called "texts.xml"):

<texts> 
   <text posX="4000" posY="-2729.75" posZ="6" text="Sección 1 por Benxamix2" red="64", green="128" blue="0" alpha="255" scale="2" font="bankgothic" /> 
</texts> 

What's wrong?

Edited by Guest
Posted

use debugs like this to see whats wrong:

  
    function loadText ( resource ) 
        if not resource and source then resource = source 
        elseif not resource and not source then return end 
        if not fileExists ( ":" .. getResourceName ( resource ) .."/texts.xml" ) then return end 
        local node = xmlLoadFile ( ":" .. getResourceName ( resource ) .."/texts.xml" ) 
if(node == false)then 
outputChatBox("error loading file") 
end 
        for i, t in ipairs ( xmlNodeGetChildren ( node ) ) do 
        --This part is done, no need to show it because it has no trouble 
    end 
      
    addEventHandler ( "onResourceStart", getRootElement ( ), loadText ) 
  

Posted

Is the resource where you call that script from in the acl? and has access to this function: ModifyOtherObjects?

Because, I've loaded a texts.xml in a resource and works perfectly.

Posted

No. But actually I added it to the meta.xml before and the resource was unable to be started when it was server-side O_o, so I had to take it off. Yes in both sides, client and server. Doesn't do anything.

Posted

Okay. I got the same thing as yours and does not work. Hurray! I will try to use another resource with only texts.xml and meta.xml to see if that works.

EDIT. I don't know how the hell I did it, but is fixed. Thank you anyway, dude.

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...