Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

Detect when CJ walks in a door


brutalis11
 Share

Recommended Posts

brutalis11

I wanna know if it's somehow possible to detect when CJ walks in a door. A CLEO script I've been working on involves a ped following me around constantly. I've managed to detect when CJ walks in a door by doing the following (part of my script. INTERIOR_1 was defined in the beginning of the script, when the ped spawns):

 

 

:SOFY_322077E: get_active_interior_to $INTERIOR_2 if and803A:   not  $INTERIOR_2 == $INTERIOR_1 // (int)  $SOFY_WAITING == 0   not Actor.Driving($PLAYER_ACTOR)else_jump @SOFY_522 04C4: store_coords_to $X_1 $Y_1 $Z_1 from_actor $PLAYER_ACTOR with_offset 15.0 15.0 15.0 04C4: store_coords_to $X_2 $Y_2 $Z_2 from_actor $PLAYER_ACTOR with_offset -15.0 -15.0 -15.0 :SOFY_416wait 0 80A4:   not actor $PLAYER_ACTOR sphere 0 in_cube_cornerA $X_1 $Y_1 $Z_1 cornerB $X_2 $Y_2 $Z_2 else_jump @SOFY_416 0860: link_actor $SOFY to_interior $INTERIOR_2 077E: get_active_interior_to $INTERIOR_1 04C4: store_coords_to $X $Y $Z from_actor $PLAYER_ACTOR with_offset 0.0 1.0 0.0 02CE: $GROUND = ground_z_at $X $Y $Z 0362: remove_actor $SOFY from_car_and_place_at $X $Y $GROUND

 

 

So as you can see... Once CJ enters a door, the script will make a rectangle around CJ. Once CJ is outside the rectangle, Sofy (the ped tounge.gif) will get warped in front of CJ & linked to the new interior. When you enter a safehouse or something like that, you're suddenly far away from where you were before entering the door, which causes CJ to be outside the rectangle. However, this doesn't seem to work with the safehouse at Verdant Meadows, since I think you're actually at the same coordinates after entering the door, but in a different interior. I recall having police forces outside the safehouse at Verdant Meadows, & I could still hear them from inside. The policemen, their cars...

So, to sum it up... Is there any way to directly detect when CJ walks in a door, so Sofy will still follow CJ inside the house even at Verdant Meadows? Or another solution? Help appreciated.

Edited by brutalis11
Link to comment
Share on other sites

Instead of going through all that, I'd just make an invisible sphere at the entering spawn coordinates that teleports the actor to your interior near you somewhere and another invisible sphere at the exit spawn of the house that teleports him back outside near you.

Link to comment
Share on other sites

brutalis11

Thanks for your input, but right now it seems that I actually found a solution. You know, once entering a door leading to another interior, CJ becomes uncontrollable. So I thought why not check if the interior has changed (which happens immediately once you enter a door & the camera changes), & then check when CJ's controllable again. I tried doing this instead of making a rectangle & check if CJ's outside the rectangle, & guess what... It works perfectly! Now Sofy follows CJ into the Verdant Meadows safehouse, too. I can't believe it was that easy. If anyone's having a problem with detecting when CJ's walking in a door, here's what I did:

 

 

:SOFY_39wait 0   Player.Defined($PLAYER_CHAR)else_jump @SOFY_39 // Model load, actor create blabla077E: get_active_interior_to $INTERIOR_1 // Model destroy blabla// Later:SOFY_322077E: get_active_interior_to $INTERIOR_2 if and803A:   not  $INTERIOR_2 == $INTERIOR_1 // (int)  $SOFY_WAITING == 0   not Actor.Driving($PLAYER_ACTOR)else_jump @SOFY_444 :SOFY_358wait 0   Player.Controllable($PLAYER_CHAR)else_jump @SOFY_358 0860: link_actor $SOFY to_interior $INTERIOR_2 077E: get_active_interior_to $INTERIOR_1 04C4: store_coords_to $X $Y $Z from_actor $PLAYER_ACTOR with_offset 0.0 1.0 0.0 02CE: $GROUND = ground_z_at $X $Y $Z 0362: remove_actor $SOFY from_car_and_place_at $X $Y $GROUND

 

Link to comment
Share on other sites

Always nice to find a R* way to do it, with a minimum of fuss. Well done! smile.gif

I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets

Link to comment
Share on other sites

brutalis11

Thanks. Gotta find alternate ways since there's no Actor.WalkingInDoor opcode. xP

Link to comment
Share on other sites

It has been known since ages here. This check should work:

 

const   INTERIOR_ENTERING_STATUS_PICKUP_SHOWN = 0   INTERIOR_ENTERING_STATUS_WALKING = 1   INTERIOR_ENTERING_STATUS_DOOR_OPENED = 2   INTERIOR_ENTERING_STATUS_SPAWNED = 3end0A8D: [email protected] = read_memory 0x0096A7CC size 4 virtual_protect 0 // iInteriorEnteringStatusif or   [email protected] == INTERIOR_ENTERING_STATUS_WALKING   [email protected] == INTERIOR_ENTERING_STATUS_DOOR_OPENEDthen   // Player is walking or entering (after opening the door).end

 

Edited by Wesser

012          345
678   9A   BCD
EFG HIJK LMN
OPQR  STUV
WX    YZ

Link to comment
Share on other sites

brutalis11

Oh, thanks. I did search & go through a couple of topics before starting this one, but I couldn't find what I wanted. This works, too. This should be better since it actually detects when CJ walks in a door.

Link to comment
Share on other sites

 

Oh, thanks. I did search & go through a couple of topics before starting this one, but I couldn't find what I wanted. This works, too. This should be better since it actually detects when CJ walks in a door.

make 2 loops, first loop to check if player leave interior 0, then code runs into second loop which check if player leave the current interior, then code jumps back to first loop

 

:Exteriorwait 0077E: get_active_interior_to [email protected]:   NOT   [email protected] ==  0  jf @Exterior04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset  0.0  2.2 0.200A1: put_actor [email protected] at [email protected] [email protected] [email protected]: link_actor [email protected] to_interior [email protected]:Interiorwait  0077E: get_active_interior_to [email protected]:   [email protected] ==  0  jf @Interior04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset  0.0  2.2 0.200A1: put_actor [email protected] at [email protected] [email protected] [email protected]: link_actor [email protected] to_interior [email protected] @Exterior

 

consider that this only work for changing between exterior/interior and not between interiorA/interiorB like entering wardrope

Link to comment
Share on other sites

brutalis11

Hi ZAZ. Thanks for your input, & for your scripting tutorial which taught me how to make CLEO scripts in Sannybuilder.

But what Wesser posted is exactly what I wanted, it detects when CJ interacts with a door, which means it also teleports actor $SOFY inside wardrobes etc. This also worked with my first code, but I experienced that if I just checked if the active interior was changed, then actor $SOFY would get teleported to inconvenient locations during certain missions etc. Afaik (& as far as I have tested, 'cause I've only bothered trying one mission so far), the memory address which Wesser posted also fixes this.

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
 Share

  • 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.