IsharaMeradin Posted March 16, 2014 Share Posted March 16, 2014 I have successfully used OnCrosshairRefChange and performed functions with target objects that have specific keywords. However, I'd like to know if there is a way to target any object that is a container. There is no IsContainer() bool function (that I know of) that I could check against the ref target of OnCrosshairRefChange. Does anyone have any ideas? Link to comment Share on other sites More sharing options...
DragonDude1029 Posted March 19, 2014 Share Posted March 19, 2014 The is because containers are form types, not properties of form types. To identify the type of a form you can either use the Form.GetType() function or cast it to that type. When casting, it will become null if it cannot be cast to that type. So you could either do ; This is preferable if you need to use the object as a container ObjectReference Ref ; this is the object reference passed by the OnCrosshairRefChange() Container ContainerRef = Ref as Container If containerRef ; do stuff on Ref or containerRef EndIf OR ; This is preferable if you want to cast but don't need it as a container ObjectReference Ref ; this is the object reference passed by the OnCrosshairRefChange() If (Ref as Container) ; do stuff on Ref EndIf OR ; This is preferable if you don't need to use the object as a container, and can get any form type easily ObjectReference Ref ; this is the object reference passed by the OnCrosshairRefChange() Int RefType = Ref.GetType() ; or do (Ref as Form).GetType(), but it should auto cast If (RefType == 28) ; it's a container ; do stuff on Ref ElseIf (RefType == 29) ; can be used for other types too, this checks if it's a door ; do stuff on Ref EndIf Types can be gotten here. Hope this helps! Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 19, 2014 Author Share Posted March 19, 2014 I already figured it out with the GetType(). It just wasn't an intuitive thing for me to look for. But thanks tho. Link to comment Share on other sites More sharing options...
Recommended Posts