Hadif Posted August 2, 2015 Share Posted August 2, 2015 (edited) 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 August 3, 2015 by Guest Link to comment
LabiVila Posted August 2, 2015 Share Posted August 2, 2015 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
Hadif Posted August 2, 2015 Author Share Posted August 2, 2015 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
Hadif Posted August 2, 2015 Author Share Posted August 2, 2015 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
Hadif Posted August 2, 2015 Author Share Posted August 2, 2015 Great then Anyway, thanks for your help again! 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