Location: JBPLAY \ Meteor 2 \ Editing \ Getting "void OnObjectTypeEnter" to affect only the vehicle your in? Back to Threads |
Assain
![]() Joined: 02 November 2003 Posts: 979 |
19 February 2006 21:16 (UK time)
Ok, so in my map ive made it so all the vheicles are invunerable untill your enter them. Rather than having a thousand "OnEnterVehicle" event triggers, I used 1 "OnObjectTypeEnter" (basically it means it does the event when you enter a vehicle/turret) event trigger. Although, the script works perfectly, it affects ALL vehicles. Such as, when i enter a vehicle, it not only makes that vehicle your in destroyable again, but it makes every vehicle on the map destroyable (even when they are not manned). Is there a way to get this event to only affect the single vehicle you entered? You need to login to create posts in this thread. |
arezey
![]() Joined: 16 June 2005 Posts: 1599 |
20 February 2006 12:48 (UK time)
Well, I quess that you could try this: void OnObjectTypeEnter( int ObjectId, int ObjectTypeNumber) { if(ObjectId=ACarIdNumber) { SC_SetObjectIndestructible(ObjectId, 0); } } And maybe this too: void OnObjectTypeExit( int ObjectId, int ObjectTypeNumber) { if(ObjectId=ACarIdNumber) { SC_SetObjectIndestructible(ObjectId, 1); } } <small>Actually I haven't tested this out yet.</small> You need to login to create posts in this thread. |
me_mantis
![]() Joined: 26 September 2003 Posts: 1152 |
21 February 2006 15:16 (UK time)
If you don't mind your vehicles respawning, you can just set them to multiplayer respawn, and they will be invincible untill occupied. You need to login to create posts in this thread. |
Assain
![]() Joined: 02 November 2003 Posts: 979 |
21 February 2006 20:35 (UK time)
Yeah, but I dont like the idea of a vehicle constantly there no matter what (do vehicals come back after a while if taken?) Also, i have it set so when you enter the player gets a 7 second god mode (since its in space, and space vehicles start out moving very slowly in the hanger, i put in this for balance), and when the player exits the god mode is taken away (if they still have it), except that one command affects all the vheicles on the map if 1 vehical is entered. Ill try aleks's solution and see what that does. You need to login to create posts in this thread. |
me_mantis
![]() Joined: 26 September 2003 Posts: 1152 |
21 February 2006 21:21 (UK time)
That would work. I have massive script with tons of that script function, so I may be able to release a bit of it for you. You need to login to create posts in this thread. |
James Bunting
Posts: 1308 |
23 February 2006 00:59 (UK time)
Am I missing the point here or is this the answer... Basically the ObjectId parameter is automatially populated with the vehicle's ID number. void OnObjectTypeEnter( int ObjectId, int ObjectTypeNumber) { // declare a string to store the object type's filename in char ObjectFilename[256]; // get the object type's filename strcpy( ObjectFilename, SC_GetObjectTypeNameForNumber(ObjectTypeNumber) ); // if the object is a Chinook if( !stricmp( ObjectFilename, "ChinookHelicpter.ob" ![]() { // make this object destructible SC_SetObjectIndestructible( ObjectId, 0); } } You need to login to create posts in this thread. |
Assain
![]() Joined: 02 November 2003 Posts: 979 |
28 February 2006 03:25 (UK time)
Both didnt work. I'm thinking the only way to make it so the vehicle your in only gets invunarability taken off is to individually do every "OnEnterVehicle" for every vehicle you want affected then... You need to login to create posts in this thread. |
Assain
![]() Joined: 02 November 2003 Posts: 979 |
08 March 2006 01:27 (UK time)
I still need some insight on this... is the only way to do this is having "OnEnterVehicle" for every vehicle that i want to turn invincibility off of? I think mantis was able to pull this script off in his map, but Jame's and Alek's methods were not working (atleast in multiplayer). To recap: Basically i'm looking to have it so no matter what vehicle you enter (not counting turrets), it looses its invincibility and you get god mode for 7-10 seconds. I was hoping to do this in one single script trigger instead of 100's of OnEnterVehicles ![]() You need to login to create posts in this thread. |
me_mantis
![]() Joined: 26 September 2003 Posts: 1152 |
08 March 2006 02:53 (UK time)
Alrighty. Heres what you should try. Lets say you jump into a minelayer your code should say "Hey!! he got into a minelayer!" Then it should think SC_SetObjectInvincible(Sc_GetPlayerObjectId, 0); //not actually the right code, but you get the idea. then it thinks SC_GiveItem("God Mode", SC_Random(7,9)); this should work on only one vehicle: the vehicle you are in. You need to login to create posts in this thread. |
James Bunting
Posts: 1308 |
22 March 2006 01:07 (UK time)
I don't understand why this is causing trouble. OnObjectTypeEnter is specifically designed to pass the object ID of the vehicle object just entered in the ObjectId parameter. The example for OnObjectTypeEnter in the Meteor 2 docs shows how this should work. I could make an example map to do what you are describing, just yell if you want me to do it. It may be a good idea in case something with M2 is not working properly. James You need to login to create posts in this thread. |
|
Forums system (C) 1999-2023 by James Bunting.
Terms of Use