civele Posted May 25, 2020 Share Posted May 25, 2020 (edited) Hey there. I've one small question regarding instance-variables, when an event get triggered. I've got this little file called XMarker.cs using GTANetworkAPI; public delegate void MyFoo(); public class XMarker : Script { public Marker jobStartMarker { get; set; } public ColShape jobStartCol { get; set; } public MyFoo foo; public XMarker() { } public XMarker(MyFoo callback) { this.jobStartMarker = NAPI.Marker.CreateMarker(0, new Vector3(-420.21115, 1133.7943, 325.90845), new Vector3(), new Vector3(), 1f, new Color(255, 0, 0)); this.jobStartCol = NAPI.ColShape.CreateSphereColShape(new Vector3(-420.21115, 1133.7943, 325.90845), 1f); this.foo = callback; } [ServerEvent(Event.PlayerEnterColshape)] public void OnPlayerColShapeHit(ColShape cl, Player pl) { // Is Null when the event gets triggered this.foo(); if (cl == jobStartCol) { NAPI.Chat.SendChatMessageToPlayer(pl, "Job", "asdasdasdasdasd!"); } } } And this little file: public class ScriptTest : Script { public ScriptTest() { } [ServerEvent(Event.ResourceStart)] public void myResourceStart() { var call = new MyFoo(this.littleFlowerPot); var test = new XMarker(call); test.foo(); } public void littleFlowerPot() { NAPI.Util.ConsoleOutput("Poel :-)"); } } My problem: On the normal resource-start I get the debug-message: "Poel :-)". However, I also want to access this callback when I enter the colshape. Now my question: Is there any way that I can access the variables within the instance when the events get triggered? Or am I able to register a event to this specific colshape? I read through several wiki-pages but wasn't able to find a way to create this kind of scenario. Edited May 25, 2020 by civele Link to comment Share on other sites More sharing options...
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