I need some help getting part of a script to work. My issue is that I need a value to be a string rather than userdata in a string.find, but I’ve heard it’s pretty much impossible to convert, so I’m hoping it’s possible to just use the context of what I’m trying to do to properly get the var I would like. Take a look at the example below to know what I mean.
--An example, trying to find whether a prop (in this case, a barrel) exists in an environment or not. for k, v in pairs( ents.GetAll() ) do for i=0,v:GetPhysicsObjectCount() do local bone=v:GetPhysicsObjectNum(i) if IsValid(bone) then --I NEED to validate it as I need to use it later (you'd know why if this was the original script, but it shouldn't be important). if not string.find( bone, "models/props_c17/oildrum001.mdl" ) then --'string' expected, got userdata print("Barrel not found!") else print("Barrel found!") end end end end end
In case you missed it,
if IsValid(bone) then
returns a userdata value rather than a string, making the string.find impossible. Please help.
Also, in case it helps, there is an entity using this script, and I would like the script to exclude the entity (assuming it has a barrel as it’s model, as in this example). Maybe I can just use the context of what I want to do?