I've one small question regarding instance-variables, when an event get triggered.
I've got this little file called XMarker.cs
usingGTANetworkAPI;publicdelegatevoidMyFoo();publicclassXMarker:Script{publicMarker jobStartMarker { get;set;}publicColShape jobStartCol { get;set;}publicMyFoo foo;publicXMarker(){}publicXMarker(MyFoo callback){this.jobStartMarker = NAPI.Marker.CreateMarker(0,newVector3(-420.21115,1133.7943,325.90845),newVector3(),newVector3(),1f,newColor(255,0,0));this.jobStartCol = NAPI.ColShape.CreateSphereColShape(newVector3(-420.21115,1133.7943,325.90845),1f);this.foo = callback;}[ServerEvent(Event.PlayerEnterColshape)]publicvoidOnPlayerColShapeHit(ColShape cl,Player pl){// Is Null when the event gets triggeredthis.foo();if(cl == jobStartCol){
NAPI.Chat.SendChatMessageToPlayer(pl,"Job","asdasdasdasdasd!");}}}
And this little file:
publicclassScriptTest:Script{publicScriptTest(){}[ServerEvent(Event.ResourceStart)]publicvoid myResourceStart(){
var call =newMyFoo(this.littleFlowerPot);
var test =newXMarker(call);
test.foo();}publicvoid 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.
Event - Instance Variables
in Scripting
Posted · Edited by civele
Hey there.
I've one small question regarding instance-variables, when an event get triggered.
I've got this little file called XMarker.cs
And this little file:
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.