Jump to content

Solve: Addon Problem


Hadif

Recommended Posts

I want to make a script that start some resources if the resource got info, 'addon = "letsdrive"'. Example:

meta.xml:

<info author="Hadif" version="1.0" name="Data" type="misc" addon="letsdrive" /> 

Any help will be appreciate!

* PS: Letsdrive is the gamemode name.

Script (server-side):

function callAddon ( ) 
    local resources = getResources ( ) 
    for index, resources in ipairs ( resources ) do 
        local resource = getResourceInfo ( resources, "addon" ) 
        if ( resource == "letsdrive" ) then 
            for index, resource in ipairs ( resource ) do 
                startResource ( resource ) 
            end 
        end 
    end 
end 

Debug:

6: bad argument #1 to 'ipairs' (table expected, got string) 

Edited by Guest
Link to comment

Second looping isn't needed, it's actually bad; it can be like this:

  
function callAddon ( ) 
    local resources = getResources ( ) 
    for index, resources in ipairs ( resources ) do 
        local resource = getResourceInfo ( resources, "addon" ) 
        if ( resource == "letsdrive" ) then 
                startResource ( resource ) 
        end 
    end 
end 
  

Link to comment
Second looping isn't needed, it's actually bad; it can be like this:
  
function callAddon ( ) 
    local resources = getResources ( ) 
    for index, resources in ipairs ( resources ) do 
        local resource = getResourceInfo ( resources, "addon" ) 
        if ( resource == "letsdrive" ) then 
                startResource ( resource ) 
        end 
    end 
end 
  

I get an error! Anyway, thank you for response.

Debug:

7: Bad argument @ 'startResource' [Expected resource-data at argument 1, got string 'letsdrive'] 

Now, how do I fix this?

Link to comment

Never mind, i got the solution!

function callAddon ( ) 
    for index, resource in ipairs ( getResources ( ) ) do 
        if getResourceInfo ( resource, "addon" ) == "letsdrive" then 
            startResource ( resource ) 
        end 
    end 
end 

Link to comment

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