Feche1320 Posted November 3, 2014 Share Posted November 3, 2014 Hello I am having a problem, I load resources at server startup, use the refreshResources function to add new maps/delete them, the problem is when a map gets deleted.. there is no isResource function or something similar to check if a resource still exists or not.. the only workaround is to use getResourceName but it throws a warning saying that the resource doesn't exist (this is obvious becose the resource got deleted), thanks Link to comment
DakiLLa Posted November 3, 2014 Share Posted November 3, 2014 Try to use getResourceFromName. Link to comment
Feche1320 Posted November 3, 2014 Author Share Posted November 3, 2014 Try to use getResourceFromName. Did you even read what I asked for? Link to comment
ALw7sH Posted November 3, 2014 Share Posted November 3, 2014 function isResource( resourceName ) if resourceName and type(resourceName) == 'string' then local resource = getResourceFromName( resourceName ) if resource then return true else return false end end end Link to comment
Feche1320 Posted November 3, 2014 Author Share Posted November 3, 2014 function isResource( resourceName ) if resourceName and type(resourceName) == 'string' then local resource = getResourceFromName( resourceName ) if resource then return true else return false end end end I am checking if it is a resource by passing the resource to the function, not by the name. EDIT: I inserted into the table the resource name aswell, so your code is working, thanks. Link to comment
Mr_Moose Posted November 4, 2014 Share Posted November 4, 2014 It becomes obvious when you compare the syntax of the two functions: getResourceFromName and getResourceName. resource = getResourceFromName(string name) string = getResourceName(resource res) Passing a string is always possible but you can't pass a resource that doesn't exist, that's the reason for the warning, sometimes it's good to know how things actually work Link to comment
MIKI785 Posted November 4, 2014 Share Posted November 4, 2014 Don't delete resources manually then.. use deleteResource and you won't have to check for anything. 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