Page 1 of 1
Tag OnPlayerTouchesObject
Posted: 07 Jul 2015, 12:50
by weerwolf
Moin,
I placed a rocket item on the map. I figured out to catch the event. Now i want to show a bigmessage with the objects tag, which is "Rocket"
However the script returns a error with null object or parameter not in array
Code: Select all
else if (Event.Type == CSmModeEvent::EType::OnPlayerTouchesObject)
{
if (Event.Landmark.Tag == "Rocket")
{
declare Message = Event.Landmark.Tag;
Message::SendBigMessage(Message, 5000, 1);
}
}
Re: Tag OnPlayerTouchesObject
Posted: 07 Jul 2015, 12:57
by steeffeen
the Landmark property is only filled for events that depend on landmarks
the PlayerTouchesObject event depends on an object so you could access the property CSmModeEvent::Object
Re: Tag OnPlayerTouchesObject
Posted: 07 Jul 2015, 13:30
by weerwolf
tnx steeffeen
Unfortunally this is the point i guess where i get lost.
So after this event happens (the player touches the object), i should read the properties of the object
with that? Or is the object the event itself?
Code: Select all
else if (Event.Type == CSmModeEvent::EType::Object)
{
if (Event.Landmark.Tag == "Rocket")
{
declare Message = Event.Landmark.Tag;
Message::SendBigMessage(Message, 5000, 1);
}
}
or someting like this
Code: Select all
else if (Event.Type == CSmModeEvent::EType::OnPlayerTouchesObject)
{
declare Object <=> CSmModeEvent::EType::Object;
if (Object.Landmark.Tag == "Rocket")
{
declare Message = Object.Landmark.Tag;
Message::SendBigMessage(Message, 5000, 1);
}
}
Re: Tag OnPlayerTouchesObject
Posted: 07 Jul 2015, 13:54
by Eole
What Steeffeen wants to say is that not all properties of the Event are filled. Some stay Null because they are not pertinent. For example Event.Victim is null on an OnShoot event because there can't be a victim in this case, only an Event.Shooter.
It's the same thing for the OnPlayerTouchesObject event. Event.Landmark is Null because touching an object doesn't necessarily mean that the player touched a landmark. However Event.Object will contains the informations about the object the player just touched. And from there you can access the landmark the object is linked to (if any) : Event.Object.AnchorLandmark.
Re: Tag OnPlayerTouchesObject
Posted: 07 Jul 2015, 15:41
by weerwolf
as a unexpierienced coder fun and frustration come as waves on water :XD
Basically i think i dont yet fully understand wat information is getting back at me when i call someting and how its presented.
In php i usually can provide myself more information by using a var_dump
In this case i am trying to do an action when someone touches a item. For example the item called rocket. And then do something with it. Either send a message, change weapon, spawn a bot etc
Code: Select all
Event.Type == CSmModeEvent::EType::OnPlayerTouchesObject
I understand that this line is correct cause it will see that im touching a object (any object)
Code: Select all
declare CSmObject Object <=> Event.Object;
I think this will store the specifications of the touched object in Object
But what is stored? Im i correct if im looking at this page:
http://maniascript.team-devota.com/stru ... bject.html

Re: Tag OnPlayerTouchesObject
Posted: 08 Jul 2015, 19:15
by Eole
Oups, looking at the doc you linked I see that you don't have access yet to the new "AnchorLandmark" property on CSmObject. It's only available in our dev build for now. Sorry for the confusion.
However the documentation you linked is also not updated to the latest release of Maniaplanet. Check this
topic, people link their doc there when they update it.
So you have two solutions. If you are using a different 3d model for each of your pick up you can use Event.Object.ModelId to find out which kind of object was picked.
Otherwise you can take a look at the
combo game mode script where we are doing something pretty similar. The interesting parts are the
Combo_SpawnObjects() function, the
OnPlayerTouch event and the
PickUpObject() function.
Each time I spawn an object on an anchor I save the anchor name in the object with a "declare for" variable. Then when the object is picked up I just access this variable to find the anchor.
weerwolf wrote:
Code: Select all
Event.Type == CSmModeEvent::EType::OnPlayerTouchesObject
I understand that this line is correct cause it will see that im touching a object (any object)
Exact.
That's also right.
Re: Tag OnPlayerTouchesObject
Posted: 08 Jul 2015, 22:40
by weerwolf
Eole wrote:Oups, looking at the doc you linked I see that you don't have access yet to the new "AnchorLandmark" property on CSmObject. It's only available in our dev build for now. Sorry for the confusion.
Thanks Eole, i will take a look at the combo script
Re: Tag OnPlayerTouchesObject
Posted: 10 Jul 2015, 23:52
by weerwolf

not only my brain ....
I'm becoming a star at crashing maniaplanet .....