Jump to content

If actor enters car without driver ?


2pacproducer2

Recommended Posts

2pacproducer2

Hi guys , i m need some litle help on script. I have created some mods like , lights turn on/off , car components open mod , and some many mods, so I have an experience on coding , but i need help anyway.

 

So heres what I m trying to do ,

I have create a mod like turn on/off cars engine , and i want to create a mod , when i enter parked car , I need to start it with my mod , but i cant create it.

 

Here what i thinking about, it mus be.(sry for my english biggrin.gif ) :

 

 

 :kaka_1Ifactor $player_ actor drives car without driver ( or parked car )  <--- here's the place where i need help.jf @kaka_1then 02D4: car 0@ turn_off_engine

 

 

I know this code i wrote now , without copying , and when I enter that car, it engine is turned off , and with a help of mine other mod ( turn engine on/off mod) i would start that engine , and drive the car.

 

I want to create this mod because i want to make sanandreas more look like gta 4.

 

 

Link to comment
Share on other sites

 

Hi guys , i m need some litle help on script. I have created some mods like , lights turn on/off , car components open mod , and some many mods, so I have an experience on coding , but i need help anyway.

 

So heres what I m trying to do ,

I have create a mod like turn on/off cars engine , and i want to create a mod , when i enter parked car , I need to start it with my mod , but i cant create it.

 

Here what i thinking about, it mus be.(sry for my english biggrin.gif ) :

 

 

 :kaka_1Ifactor $player_ actor drives car without driver ( or parked car )  <--- here's the place where i need help.jf @kaka_1then 02D4: car 0@ turn_off_engine

 

 

I know this code i wrote now , without copying , and when I enter that car, it engine is turned off , and with a help of mine other mod  ( turn engine on/off mod) i would start that engine , and drive the car.

 

I want to create this mod because i want to make sanandreas more look like gta 4.

Try this....I haven't tried it

 

 

{$CLEO .cs}thread 'SOMMAT':CHECKSwait 0 msif0256:   player $PLAYER_CHAR defined004D: jump_if_false @CHECKS03C0: 1@ = actor $PLAYER_ACTOR car:MAINPARTwait 0 msif00DB:   actor $PLAYER_ACTOR in_car 1@004D: jump_if_false @CHECKS02D4: car 1@ turn_off_engine01C3: remove_references_to_car 1@ // Like turning a car into any random car jump @MAINPART2:MAINPART2wait 0 msif80DB:   not actor $PLAYER_ACTOR in_car 1@004D: jump_if_false @MAINPARTjump @CHECKS

 

Edited by james227uk
Link to comment
Share on other sites

2pacproducer2

yeah , now when i enter any car then the engine is off , but I mean i wanted to do , that if i enter car without driver or parked car then the engine is off ,

 

Now when i enter any car , steal the car , etc , i hit the driver , then throve him away , ant when i enter his already started car , his engine studently off , thats not what i needed,

Edited by 2pacproducer2
Link to comment
Share on other sites

2pacproducer2

yeah , now when i enter any car then the engine is off , but I mean i wanted to do , that if i enter car without driver or parked car then the engine is off ,

 

Now when i enter any car , steal the car , etc , i hit the driver , then throve him away , ant when i enter his already started car , his engine studently off , thats not what i needed,

 

Link to comment
Share on other sites

yeah , now when i enter any car then the engine is off , but I mean i wanted to do , that if i enter car without driver or parked car then the engine is off ,

 

Now when i enter any car , steal the car , etc , i hit the driver , then throve him away , ant when i enter his already started car , his engine studently off , thats not what i needed,

Might have a solution....testing it now

Link to comment
Share on other sites

suicidal.gifsuicidal.gifsuicidal.gif Didn't work sad.gifsuicidal.gifsuicidal.gifsuicidal.gif

 

Maybe a better coder will work out whats wrong.

 

 

{$CLEO .cs}thread 'SOMMAT':CHECKSwait 0 msif0256:   player $PLAYER_CHAR defined004D: jump_if_false @CHECKS03C0: 1@ = actor $PLAYER_ACTOR car:MAINPARTwait 0 ms//---if00DB:   actor $PLAYER_ACTOR in_car 1@004D: jump_if_false @CHECKS046C: 23@ = car 1@ driver//---if00DB:   actor 23@ in_car 1@then081D: set_car 1@ engine_operation 1else081D: set_car 1@ engine_operation 0end//---if00DB:   actor $PLAYER_ACTOR in_car 1@then081D: set_car 1@ engine_operation 1endwait 100 ms jump @MAINPART2//---:MAINPART2wait 0 msif80DB:   not actor $PLAYER_ACTOR in_car 1@01C2: remove_references_to_actor 23@ // Like turning an actor into a random pedestrian01C3: remove_references_to_car 1@ // Like turning a car into any random car 004D: jump_if_false @MAINPARTjump @CHECKS

 

Link to comment
Share on other sites

@james227uk:

Let's take a look at your code:

 

{$CLEO .cs}thread 'SOMMAT':CHECKSwait 0 msif0256:   player $PLAYER_CHAR defined004D: jump_if_false @CHECKS03C0: 1@ = actor $PLAYER_ACTOR car

 

 

You cannot use 03C0 here since the fact that the player is defined doesn't mean that he is sitting in a car at the same time.

 

 

:MAINPARTwait 0 ms//---if00DB:   actor $PLAYER_ACTOR in_car 1@004D: jump_if_false @CHECKS

 

 

Right before this check we made sure that 1@ holds the player_car, so the check will always return true. Your code is logically inconsistent and thus cannot work...

 

 

046C: 23@ = car 1@ driver//---if00DB:   actor 23@ in_car 1@

 

 

Again, it's obvious that the driver of the car will also fulfill the condition.

 

...

 

If I wanted to code something like this I'd check whether the 'car hijacking' animations have been triggered (sure sign that we DON'T want the engine to be turned off when the following player_in_car check returns true). If the result of the player_in_car check changes from false to true without the hijacking animations being triggered in the meantime we may assume that the engine should be turned off because we've stolen a car with an unoccupied driver's seat.

Link to comment
Share on other sites

@james227uk:

Let's take a look at your code:

 

{$CLEO .cs}thread 'SOMMAT':CHECKSwait 0 msif0256:   player $PLAYER_CHAR defined004D: jump_if_false @CHECKS03C0: 1@ = actor $PLAYER_ACTOR car

 

 

You cannot use 03C0 here since the fact that the player is defined doesn't mean that he is sitting in a car at the same time.

 

 

:MAINPARTwait 0 ms//---if00DB:   actor $PLAYER_ACTOR in_car 1@004D: jump_if_false @CHECKS

 

 

Right before this check we made sure that 1@ holds the player_car, so the check will always return true. Your code is logically inconsistent and thus cannot work...

 

 

046C: 23@ = car 1@ driver//---if00DB:   actor 23@ in_car 1@

 

 

Again, it's obvious that the driver of the car will also fulfill the condition.

 

...

 

If I wanted to code something like this I'd check whether the 'car hijacking' animations have been triggered (sure sign that we DON'T want the engine to be turned off when the following player_in_car check returns true). If the result of the player_in_car check changes from false to true without the hijacking animations being triggered in the meantime we may assume that the engine should be turned off because we've stolen a car with an unoccupied driver's seat.

Thanks SteaVor.....proves I have still got loads to learn.

Link to comment
Share on other sites

2pacproducer2

I edited the code a bit , but it cant compile it:

 

 

thread 'SOMMAT':CHECKSwait 0 msif0256:   player $PLAYER_CHAR defined004D: jump_if_false @CHECKSif03C0: 1@ = actor $PLAYER_ACTOR car004D: jump_if_false @CHECKS:MAINPARTwait 0 msif00DB:   actor $PLAYER_ACTOR in_car 1@004D: jump_if_false @CHECKS 046C: 23@ = car 1@ driverif00DB:   actor 23@ in_car 1@then081D: set_car 1@ engine_operation 0endif00DB:   actor $PLAYER_ACTOR in_car 1@then081D: set_car 1@ engine_operation 0endif80DB:   not actor 23@ in_car 1@ then081D: set_car 1@ engine_operation 1jump @MAINPART2:MAINPART2wait 0 msif80DB:   not actor $PLAYER_ACTOR in_car 1@01C2: remove_references_to_actor 23@ // Like turning an actor into a random pedestrian01C3: remove_references_to_car 1@ // Like turning a car into any random car004D: jump_if_false @MAINPARTjump @CHECKS

 

 

 

Can someone look at it , and tell why it cant compile

Link to comment
Share on other sites

The reason it won't compile would be the 03c0 line at the beginning because it cannot be used as a conditional.

The check in :MAINPART2 cannot work because the jump_if_false instruction doesn't follow right behind the conditional.

The JUMP line at the end of :MAINPART is unnecessary.

Keep in mind that those are syntactical errors only - logically the code still doesn't make any sense.

 

 

Link to comment
Share on other sites

2pacproducer2

If it have no sense , then could you please help me making what i want ?

Link to comment
Share on other sites

I've already outlined how I would go about implementing such a feature.

 

 

If I wanted to code something like this I'd check whether the 'car hijacking' animations have been triggered (sure sign that we DON'T want the engine to be turned off when the following player_in_car check returns true). If the result of the player_in_car check changes from false to true without the hijacking animations being triggered in the meantime we may assume that the engine should be turned off because we've stolen a car with an unoccupied driver's seat.

 

Coding this should be pretty straightforward, like this:

 

 

:MYMODif  player_definedjf LOOP1if player_in_carjf LOOP1waitjump MYMOD// we made sure that the player is NOT in a car at the moment, so we can loop until he's about to enter one:LOOP1waitif  player_definedjf LOOP1if  NOT player performing 'hijacking' animationjf MYMOD  // we don't need to turn off the engine if he's hijacking, so back to the beginningif  player performing 'car theft / car entering' animation  // cars without driver and parked carsjf LOOP1  // he's not about to enter a car, so back to the beginning of the loop// at this point he's trying to enter a car, so loop until he's in, then turn off the engine:LOOP2waitif  player_definedjf LOOP1if NOT player_in_carjf TURNOFF    // now just turn off the engine and we're doneif player performing 'car theft / car entering' animationjf LOOP1   // car theft was interrupted, back to the beginningjump LOOP2 :TURNOFF// whatever you want to dojump MYMOD  // back to the very beginning

 

 

All that's left to do is filling in the appropriate animations.

Link to comment
Share on other sites

2pacproducer2

yeah , i think this code should work , but I will finish this mod later , I need one more help .

 

What opcode makes cars 2 rear wheels explode ?

Link to comment
Share on other sites

2pacproducer2

Sry for double post.

 

Here , I made this code , but its not work, IT CRASHES THE GAME.

 

 

:MYMODthread 'MYMOD':MYMOD_11if   Player.Defined($PLAYER_CHAR)jf @LOOP103C0: 1@ = actor $PLAYER_ACTOR carif00DB:   actor $PLAYER_ACTOR in_car 1@jf @LOOP1wait 0jump @MYMOD_11// we made sure that the player is NOT in a car at the moment, so we can loop until he's about to enter one:LOOP1wait 0if  Player.Defined($PLAYER_CHAR)jf @LOOP1if8611:   not actor $PLAYER_ACTOR performing_animation "HIJACKING" jf @MYMOD_11  // we don't need to turn off the engine if he's hijacking, so back to the beginningif0611:   actor $PLAYER_ACTOR performing_animation "CAR_THEFT / CAR_ENTERING" // cars without driver and parked carsjf @LOOP1  // he's not about to enter a car, so back to the beginning of the loop// at this point he's trying to enter a car, so loop until he's in, then turn off the engine:LOOP2wait 0if  Player.Defined($PLAYER_CHAR)jf @LOOP1if80DB:   not actor $PLAYER_ACTOR in_car 1@jf @TURNOFF    // now just turn off the engine and we're doneif0611:   actor $PLAYER_ACTOR performing_animation "CAR_THEFT / CAR_ENTERING"jf @LOOP1   // car theft was interrupted, back to the beginningjump @LOOP2:TURNOFF02D4: car 1@ turn_off_engine jump @MYMOD_11  // back to the very beginning 

 

Edited by 2pacproducer2
Link to comment
Share on other sites

I don't usually post finished scripts, so you're very lucky that you got this much - originally I meant to post merely a rough outline of the logic behind it, but I noticed that it was somewhat more complex than I had expected. However, I did explicitly state that you'd still need to replace my placeholder animations "HIJACKING" and "CAR_THEFT / CAR_ENTERING" with the real ones before the code can work properly.

To be honest I don't even know whether there's a comprehensive list of all animations available. That's yours to research.

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.