CLEO Help Code that executes upon entering a car?

CLEO related
Status
Not open for further replies.

Crayder

Active member
Joined
Mar 6, 2014
Messages
148
Reaction score
0
Ok, I know what I want to do after they enter the car, but how do I detect the moment they enter the car and only that moment? (I would also need the exit so I can remove the car from memory.)

If you must know, I want to execute this:
Code:
Car.SetSpeedInstantly(car_they_entered, 0.0)
onto the car_they_entered on detection, only if that car is a heli... (You can detect whether the player is in a heli using "04A9:  actor $PLAYER_ACTOR driving_heli " right?)

Ahead of time, thanks... :p
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
Hi, actually 04A9 should get this moment

{$CLEO}
0000: NOP

:label
wait 0
if 31@ == 1
then
    if 04A9: actor $PLAYER_ACTOR driving_heli
    then
    else
    31@ = 0
        if 056E:  car 0@ defined  //to avoid bug if you suddenly get tped
        then
       
        //here you put what is going to happen to the heli when you exit it
        end
    end 
else
    if 04A9:  actor $PLAYER_ACTOR driving_heli
    then
    31@ = 1
    0811: 0@ = actor $PLAYER_ACTOR used_car
    //here you put what is going to happen when you enter heli
    end
end
jump [member=23507]Label[/member]

   
 

Crayder

Active member
Joined
Mar 6, 2014
Messages
148
Reaction score
0
i seemed to get some code to work... here it is:
Code:
{$CLEO .cs}

thread 'AUTOHELI' 
jump @MAIN

:MAIN
wait 0 
if
09DE:   actor $PLAYER_ACTOR entering_car //called when opening door 
jf @MAIN
goto @COOLDOWN //goto initial check

:COOLDOWN
wait 100 //give player time to actually get in all the way
if
   Actor.Driving($PLAYER_ACTOR) //are they in the vehicle yet?
jf @COOLDOWN //give them more time to get in
if
04A9:   actor $PLAYER_ACTOR driving_heli //once they are in, see if their car is a heli
jf @MAIN //no heli? return to main...
$C = Actor.CurrentCar($PLAYER_ACTOR) //get their car id
Car.SetSpeedInstantly($C, 0.0) //set the speed to 0, which skips the heliblade start up time
Car.RemoveReferences($C) //remove the id from memory

jump @MAIN //begin loop again



/*======*\
| WORKS! |
\*======*/
which one is better, mine or yours... i'm a complete newbie, never scripted any cleo until today, but my code works and im pretty surprised... ill be glad to switch to yours if you say its better but can you try my code out? it worked out a lot quicker than i expected... I'll try yours tomorrow...
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
I wouldn't change anything if your code is working xd
Btw it looks like it doesn't read "not" in my code at  "if 04A9: not  actor $PLAYER_ACTOR driving_heli" and it returns the incorrect result, I edited it by deleting "not" and adding "else"
 

Crayder

Active member
Joined
Mar 6, 2014
Messages
148
Reaction score
0
monday link said:
I wouldn't change anything if your code is working xd
Btw it looks like it doesn't read "not" in my code at  "if 04A9: not  actor $PLAYER_ACTOR driving_heli" and it returns the incorrect result, I edited it by deleting "not" and adding "else"
Thanks... XD
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
monday link said:
I wouldn't change anything if your code is working xd
Btw it looks like it doesn't read "not" in my code at  "if 04A9: not  actor $PLAYER_ACTOR driving_heli" and it returns the incorrect result, I edited it by deleting "not" and adding "else"

Replacing the first 0 from an opcode with an 8 will act the same as not.

if 84A9 == if 04A9: not

Better this way, because some opcodes will ignore the 'not' keyword.
 
Status
Not open for further replies.
Top