Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

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

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

    2. Forum Support

    3. Site Suggestions

arewenotmen

Play horn in player-occupied vehicle?

Recommended Posts

arewenotmen

This sounds easy, but it doesn't seem to be so far.

 

I want, for a vehicle occupied by the player, to sound the horn.

 

I have tried:

 

- VEHICLE::START_VEHICLE_HORN() - this plays very briefly, unless the player is not in control of the car, whereupon it behaves as expected

- AI::TASK_VEHICLE_TEMP_ACTION() - various param values make the player do stuff like accelerate, turn etc, but apparently not play the horn. I could have missed one. Some unused ones crash the game.

- AUDIO::PLAY_... - I don't have a string name for the sound

- lock the player controls in case that matters - nope

 

Any help please!

 

It's performed in game during the LSC mod shop, but the script is long and I can't figure out everything it does.

Share this post


Link to post
Share on other sites
Jitnaught

The only thing I found in the LSC script file for using the horn was

VEHICLE::START_VEHICLE_HORN(v_2, v_D, GAMEPLAY::GET_HASH_KEY("HELDDOWN"), 0); //v_2 = vehicle, v_D = duration

Share this post


Link to post
Share on other sites
arewenotmen

Yeah, that works fine until the player is sat in the driver's seat whereupon it stops.

Share this post


Link to post
Share on other sites
Jitnaught

Do you mean that it stops working when you play the horn when the player is outside of the car and then gets in, or that it stops working if the player is in the car regardless if he got in after the horn started?

Share this post


Link to post
Share on other sites
arewenotmen

Literally it will work on an empty car until the player shuffles over to the driver seat and it will then stop. I guess the fact that the player isn't pressing the horn overrides it.

Share this post


Link to post
Share on other sites
Enumerator

Literally it will work on an empty car until the player shuffles over to the driver seat and it will then stop. I guess the fact that the player isn't pressing the horn overrides it.

The only way to do this is to take control of the driver entity handle

Then make that ped press the horn

 

Make sure the horn is active/enabled

void OVERRIDE_VEH_HORN(Vehicle vehicle, False, 0)

 

Make ped press the horn

void START_VEHICLE_HORN(Vehicle vehicle, 10000, GET_HASH_KEY("HELDDOWN"), True)

Share this post


Link to post
Share on other sites
arewenotmen

The only way to do this is to take control of the driver entity handle

This bit - what specifically do you do?

Share this post


Link to post
Share on other sites
Enumerator

 

The only way to do this is to take control of the driver entity handle

This bit - what specifically do you do?

 

Abuse the handle of the current PED

Create a new ped with its handle, then you can control the ped entirely, its position, its tasks, animations,

 

Dim ped as new ped(HANDLE OF PED)

You can now abuse this ped.

FUNCTION/HASH<PED>

Share this post


Link to post
Share on other sites
arewenotmen

Right, but (apart from me being in C++) I tried a bunch of stuff like clear tasks etc and if it didn't result in something bad (like exiting the car) it didn't seem to help either.

 

I think killing off player control is certainly the answer but I can't work out what natives it actually needs.

Share this post


Link to post
Share on other sites
Neutrinobeam

I'd suggest

 

CONTROLS::DISABLE_CONTROL_ACTION(0, 86,1) // Horn

 

Maybe swapping 2 for the 0.

Share this post


Link to post
Share on other sites
arewenotmen

Yeah, I did that (and all the controls), no difference. To be fair I probably didn't try the 2.

Share this post


Link to post
Share on other sites
Neutrinobeam

Are you disabling it per tick / making sure the game isn't reverting control?

 

My other thought is to swap out the driver with a cloned ped and hide & freeze the player's ped.

Share this post


Link to post
Share on other sites
arewenotmen

Ha, that might work, but a bit of a stretch.

 

When I tried this originally , I went as far as trying to spawn an additional invisible car and use that, a similar bodge, but I didn't try very hard as it felt too stupid.

 

The feature I wanted this for was simply to preview horn sounds in the ENT vehicle modifications menu, but if it involves taking away player control I think I'll just leave it.

Share this post


Link to post
Share on other sites
Enumerator

Ha, that might work, but a bit of a stretch.

 

When I tried this originally , I went as far as trying to spawn an additional invisible car and use that, a similar bodge, but I didn't try very hard as it felt too stupid.

 

The feature I wanted this for was simply to preview horn sounds in the ENT vehicle modifications menu, but if it involves taking away player control I think I'll just leave it.

instead of storing the car and trying to modify its parameters, Why dont you abuse its handle instead? You'll notice alot of things can open up if you start to take control of objects properly instead of trying to brute force your way in with bool checks.

 

Create a blank vehicle model, direct cast the model as a vehicle, "make sure you're returning a "NEW" vehicle with the handle of the car you want to manipulate. this is essentially a clone of its parameters but once it is returned, you can modify the car natives as much as you like.

Edited by Enumerator

Share this post


Link to post
Share on other sites
arewenotmen

Because there's no difference/no such thing - everything in C++ operates via the handle anyway.

Edited by arewenotmen

Share this post


Link to post
Share on other sites
Enumerator

Because there's no difference/no such thing - everything in C++ operates via the handle anyway.

 

You can't directly control most of the functions of the ped/vehicle just by setting it as a ped for example...

You need to take control of it, NATIVES that we have provide three methods, Interacting/Setting/Getting

However most of the function calls take data in many arrays and formats as parameter lists which can only mean one thing, There are other methods that you need to take into account such as Demanding that you own the ped, Not trying to own the ped by feeding it constantly with commands on every tick or trying to alter the ped with natives tha require that you OWN the ped. This is a very broad spectrum to analyse and i doubt anyone would even bother sorting out the natives other than simply showing us the function call parameters.

Edited by Enumerator

Share this post


Link to post
Share on other sites
arewenotmen

I'm not sure I understand your point.

 

Either you're saying:

 

- we're missing documented natives that give you exclusive player control - you might well be right

 

or

 

- you think there is something special about how we manipulate handles; there isn't, they're just IDs

 

Don't forget that C++ has effectively raw access to the natives; this may not be the case with whatever you're writing in (.NET?) and what you're describing might be a product of that library.

Share this post


Link to post
Share on other sites
Neutrinobeam

From the "carmod_shop" script.

 

CONTROLS::0x2CEDE6C5(int p1) (which I've seen all over)

 

CONTROLS::SET_INPUT_EXCLUSIVE(int p1, int p2)

 

setElem(AUDIO::GET_VEHICLE_DEFAULT_HORN(rPtr(A_1)), 0, getElemPtr(A_0, (&g_86931) + 19517, 172) + 132, 4);
setElem(AUDIO::0xFD4B5B3B(rPtr(A_1)), 0, getElemPtr(A_0, (&g_86931) + 19517, 172) + 132, 4);
AUDIO::OVERRIDE_VEH_HORN(A_0, 1, rPtr((A_1) + 204)).
Could be useful?
Edited by Neutrinobeam

Share this post


Link to post
Share on other sites
arewenotmen

Yeah, I spent a long time looking through that originally.

 

I don't know what AUDIO::0xFD4B5B3B() does but it operates on a vehicle and returns a value, so isn't likely to do much.

 

The controls ones might be worth another look.

Share this post


Link to post
Share on other sites
Cyron43

I once had the same issue but it's pretty simple once you know what to do. Simply connect the KeyDown event with a handler that calls the Horn method after filtering the right key (I use E).
The following link leads to the source of my Autodrive if you need a closer look (start at KeyHandling.cs).

https://bitbucket.org/CyronsTeam/vautodrive/src/d7490685b994e4719c369e43402c4a486f5117aa/VAutodrive/?at=master

Edited by Cyron43

Share this post


Link to post
Share on other sites
arewenotmen

I once had the same issue but it's pretty simple once you know what to do. Simply connect the KeyDown event with a handler that calls the Horn method after filtering the right key (I use E).

The following link leads to the source of my Autodrive if you need a closer look (start at KeyHandling.cs).

https://bitbucket.org/CyronsTeam/vautodrive/src/d7490685b994e4719c369e43402c4a486f5117aa/VAutodrive/?at=master

Thanks, although I think your success with this is less about keys and more about what you've done to take control of the player, e.g. DriverHandling::PrepareDriver().

 

It's great that your work is open source and I'll have a proper look when I get chance.

Edited by arewenotmen

Share this post


Link to post
Share on other sites
Cyron43

 

I once had the same issue but it's pretty simple once you know what to do. Simply connect the KeyDown event with a handler that calls the Horn method after filtering the right key (I use E).

The following link leads to the source of my Autodrive if you need a closer look (start at KeyHandling.cs).

https://bitbucket.org/CyronsTeam/vautodrive/src/d7490685b994e4719c369e43402c4a486f5117aa/VAutodrive/?at=master

Thanks, although I think your success with this is less about keys and more about what you've done to take control of the player, e.g. DriverHandling::PrepareDriver().

 

It's great that your work is open source and I'll have a proper look when I get chance.

 

Hi again,

I revoked my repos from public availability now but if you still like to rummage through the code then just pm me your email address and I'll send you an invitation. :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


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