Jump to content

Automatic openable electric gate?


/!\ErManu/!\

Recommended Posts

/!\ErManu/!\

Hello!

 

I make a private hangar with fences,I job with proyect mod based on garbage truck jobs,new trucks with functions,private garage for this trucks and Sweepers,I add a dumpers for SA map,etc,etc...

 

Even things stay for doing,because of it I ask so much and do not show anything sarcasm.gif wip mod sigh.gif

 

I want to know that code to use in order that on having entered with Trashmaster and Sweeper the ''electricgate'' is opened automatic to left,for the moment the electricgate is possible to open because I edit object.dat and add the line of an interior door biggrin.gif is onlooker!

 

Sketch of for what I look:

 

http://www.subirimagenes.com/privadas-1-476386.html

 

http://www.subirimagenes.com/privadas-2-476391.html

 

Thanks!

Link to comment
Share on other sites

gtasearcher

You need to create that gate via scm.

Object.Create([email protected], {gate model}, {gate x}, {gate y}, {gate z})

Then, check if the player is near it.

0474:   actor $PLAYER_ACTOR near_object_in_cube [email protected] radius 15.0 15.0 4.0 flag 0

Then, you must check if the player is driving, and if he is, then if he's driving a trashmaster or sweeper.

if orActor.DrivingVehicleType($PLAYER_ACTOR, #TRASH)Actor.DrivingVehicleType($PLAYER_ACTOR, #SWEEPER)jf @begin

Then you got to move the object.

0381: throw_object [email protected] velocity_in_direction {xv} {yv} {zv}

Then you got to check if the player left the gate.

repeatwait 0until 8474: not  actor $PLAYER_ACTOR near_object_in_cube [email protected] radius 20.0 20.0 5.0 flag 0

Then put the object back.

0381: throw_object [email protected] velocity_in_direction {xv} {yv} {zv}

 

Entire code would be

{$CLEO}thread 'GATEO'0A95: enable_thread_saving  // required to make sure the object won't appear over and over again when starting the gameObject.Create([email protected], {gate model}, {gate x}, {gate y}, {gate z})jump @begin:beginwait 0ifPlayer.Defined($PLAYER_CHAR) // he shouldn't be wasted or bustedjf @begin // else_jumpifPlayer.Controllable($PLAYER_CHAR)  // he shouldn't be uncontrollablejf @beginif0474:   actor $PLAYER_ACTOR near_object_in_cube [email protected] radius 15.0 15.0 4.0 flag 0jf @beginif orActor.DrivingVehicleType($PLAYER_ACTOR, #TRASH)Actor.DrivingVehicleType($PLAYER_ACTOR, #SWEEPER)jf @begin0381: throw_object [email protected] velocity_in_direction {xv} {yv} {zv}repeatwait 0until 8474: not  actor $PLAYER_ACTOR near_object_in_cube [email protected] radius 20.0 20.0 5.0 flag 00381: throw_object [email protected] velocity_in_direction {xv} {yv} {zv}jump @begin

 

 

Link to comment
Share on other sites

I doubt that "throw object" will result in the correct behaviour.

 

I would do the actual moving of the gate with:

 

repeat  wait 100until 834E:   not move_object [email protected] to  967.62 15.438 speed 0.1 0.1 0.1 flag 0 

 

 

The values behind "speed" are the steps by which the gate is moved each iteration.

bS8xA.png
Link to comment
Share on other sites

/!\ErManu/!\

Ok,I tested the CLEO code and...

 

Add the name of gate ''electricgate'' and coordinates and coordinates for move the gate to left:

 

http://www.subirimagenes.com/privadas-gter-476504.html

 

But...

 

http://www.subirimagenes.com/privadas-aggg-476505.html

 

I do something badly,to the wait of instructions...sorry for my bad CLEO,only to do simple things with CLEO,I am more of shaping dozingoff.gif

 

Thanks!

Link to comment
Share on other sites

gtasearcher

Ok, in your script, you can't use

electricgate

Use

#electricgate

 

The coordinates are ok, but in the last one, remove the commas.

 

Should work.

Link to comment
Share on other sites

/!\ErManu/!\

Ok,done,the code compiled ok!!

 

But!!this...

 

Ingame appear a rare and static icon...

 

http://www.subirimagenes.com/privadas-lol-476549.html

 

The code before of compile:

 

http://www.subirimagenes.com/privadas-before-476551.html

 

After of compile:

 

http://www.subirimagenes.com/privadas-after-476553.html

 

The code seems to be correct but something there is evil,I do not deal on this,to seeing if your you know sarcasm.gif

 

Thanks for your pacience cookie.gif

Link to comment
Share on other sites

gtasearcher

Are you sure "electricgate" is a valid object?

 

For me it sounds too simple to be valid.

 

That icon is an info pickup "#INFO"

Link to comment
Share on other sites

You shouldn't use #electricgate, as symbolic id's for objects don't work correctly in CLEO scripts.

Use the numerical value for #electricgate, which is 969.

 

 

You can change the value by placing the cursor on #electricgate in sannybuilder and pressing <ctrl>+<alt>+H

 

That should give you the correct gate model.

bS8xA.png
Link to comment
Share on other sites

/!\ErManu/!\

I dont know...

 

Is this object:

 

http://www.subirimagenes.com/privadas-1-476386.html

 

In map editor:

 

DATA/MAPS/generic/barriers.IDE

 

ID 969 Object Electricgate Texture electricgate

 

And in ''object.dat'' also it call Electricgate

 

Is not it an object validated?,that I object use at the time?,thanks!

 

EDIT: Ok ok,PatrickW,I go to test the code with number 969 icon14.gif

 

RE-EDIT: I test the code and work but incorrectly,the gate dont open on Trashmaster or Sweeper and appear this way:

 

http://www.subirimagenes.com/privadas-casi-476596.html

 

We are almost obtaining it but something is absent!

Edited by /!\ErManu/!\
Link to comment
Share on other sites

/!\ErManu/!\

I have been testing the code and changing things and I do not manage to obtain it, aver if you can help me to end it...is that there is very little and what is wrong must be something simple dozingoff.gif

Link to comment
Share on other sites

Try looking in the game's MAIN.SCM for an example your problem may be that the xyz might be switched.

Link to comment
Share on other sites

As I said in my first post in this topic, you need to use the "move object" opcode instead of the "throw object".

 

Something like this:

 

{$CLEO}thread 'GATEO'0A95: enable_thread_saving  // required to make sure the object won't appear over and over again when starting the gameObject.Create([email protected], 969, 2408.22, -2088.12, 12.5678)object.Angle([email protected]) = {RZ}:beginwait 0ifPlayer.Defined($PLAYER_CHAR) // he shouldn't be wasted or bustedjf @begin // else_jumpifPlayer.Controllable($PLAYER_CHAR)  // he shouldn't be uncontrollablejf @beginif0474:   actor $PLAYER_ACTOR near_object_in_cube [email protected] radius 15.0 15.0 4.0 flag 0jf @beginif orActor.DrivingVehicleType($PLAYER_ACTOR, #TRASH)Actor.DrivingVehicleType($PLAYER_ACTOR, #SWEEPER)jf @begin// Move gate back to open positionrepeat  wait 100until 834E:   not move_object [email protected] to {X2} {Y2} {Z2} speed {dx} {dy} 0.0 flag 0 // Wait for the player to leave the area of the gaterepeat wait 100until 8474: not  actor $PLAYER_ACTOR near_object_in_cube [email protected] radius 20.0 20.0 5.0 flag 0// Move gate back to original positionrepeat  wait 100until 834E:   not move_object [email protected] to 2408.22 -2088.12 12.5678 speed {-dx} {-dy} 0.0 flag 0 jump @begin

 

 

You need to fill in the {RZ} which determines the direction of the gate.

Furthermore you need to determine the "open" position of the gate. Those coordinates must be filled in for {X2}, {Y2} and {Z2}.

 

The tricky part is determining the {dx} and {dy}. if the gate should translate along one of the main axis ( Y or X), than simply insert 0.1 for both should be okay. If the gate is to translate along an angle in respect with the main axes, those two are a bit more complex. But I'll be able to help you find the correct values, once you have determined the direction of the gate and the "open" position.

 

 

 

bS8xA.png
Link to comment
Share on other sites

/!\ErManu/!\

Uff...sorry but I dont know more about this...

 

The angle of the ''electricgate'' is 90º,this information was absent in the code but I dont know more...If you get confused your that you can do...I dead with this code cry.gif

 

 

{$CLEO}thread 'GATEO'0A95: enable_thread_saving  // required to make sure the object won't appear over and over again when starting the gameObject.Create([email protected], 969, 2408.22, -2088.12, 12.5678)object.Angle([email protected]) = 90:beginwait 0ifPlayer.Defined($PLAYER_CHAR) // he shouldn't be wasted or bustedjf @begin // else_jumpifPlayer.Controllable($PLAYER_CHAR)  // he shouldn't be uncontrollablejf @beginif0474:   actor $PLAYER_ACTOR near_object_in_cube [email protected] radius 15.0 15.0 4.0 flag 0jf @beginif orActor.DrivingVehicleType($PLAYER_ACTOR, #TRASH)Actor.DrivingVehicleType($PLAYER_ACTOR, #SWEEPER)jf @begin// Move gate back to open positionrepeat wait 100until 834E:   not move_object [email protected] to {X2} {Y2} {Z2} speed {dx} {dy} 0.0 flag 0 // Wait for the player to leave the area of the gaterepeatwait 100until 8474: not  actor $PLAYER_ACTOR near_object_in_cube [email protected] radius 20.0 20.0 5.0 flag 0// Move gate back to original positionrepeat wait 100until 834E:   not move_object [email protected] to 2408.22 -2088.12 12.5678 speed {-dx} {-dy} 0.0 flag 0 jump @begin

 

 

I dont know more sarcasm.gif sorry...

Link to comment
Share on other sites

You have somehow determined the correct location of the gate, when it is closed,

I presume with MED.

 

Can you determine the location the gate should be at, when it is open?

 

 

BTW..

The angle should be 90.0, as it is an floating-point number, not an integer.

 

bS8xA.png
Link to comment
Share on other sites

/!\ErManu/!\

Electricgate closed:

 

Position X: 2408.22

Position Y: -2088.12

Position Z: 12.5678

Rotation X: 0

Rotation Y: 0

Rotation Z: 90

 

Electricgate open:

 

Position X: 2408.22

Position Y: -2096.12

Position Z: 12.5678

Rotation X: 0

Rotation Y: 0

Rotation Z: 90

 

This is all information,only I modified the rotation Z.

Link to comment
Share on other sites

This code should so the job:

 

{$CLEO}thread 'GATEO'0A95: enable_thread_saving  // required to make sure the object won't appear over and over again when starting the gameObject.Create([email protected], 969, 2408.22, -2088.12, 12.5678)object.Angle([email protected]) = 90.0:beginwait 100ifPlayer.Defined($PLAYER_CHAR) // he shouldn't be wasted or bustedjf @begin // else_jumpifPlayer.Controllable($PLAYER_CHAR)  // he shouldn't be uncontrollablejf @beginif0474:   actor $PLAYER_ACTOR near_object_in_cube [email protected] radius 15.0 15.0 4.0 flag 0jf @beginif orActor.DrivingVehicleType($PLAYER_ACTOR, #TRASH)Actor.DrivingVehicleType($PLAYER_ACTOR, #SWEEPER)jf @begin// Move gate back to open positionrepeat wait 10until 034E:  move_object [email protected] to 2408.22 -2096.12 12.5678 speed 0.1 0.1 0.1 flag 0// Wait for the player to leave the area of the gaterepeatwait 100until 8474: not  actor $PLAYER_ACTOR near_object_in_cube [email protected] radius 20.0 20.0 5.0 flag 0// Move gate back to original positionrepeat wait 10until 034E: move_object [email protected] to 2408.22 -2088.12 12.5678 speed 0.1 0.1 0.1 flag 0jump @begin

 

have fun smile.gif

bS8xA.png
Link to comment
Share on other sites

/!\ErManu/!\

JAJAJA Yeahhh!!,is very curious biggrin.gif this work correctly,I fixed the coordinates in the code because the gate appear open and close when I enter with Trashmaster or Sweeper,but now it works correctly icon14.gif

 

This code is very useful for any mod devil.gif thanks for your pacience!!,thanks very much!! cookie.gifdevil.gif

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.