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. DLC
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
      7. The Diamond Casino Heist
    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

Lovono

how to know if a vehicle model is trailer

Recommended Posts

Lovono

Hi everybody,

Is there anyway we can detect if a model is a trailer so we can use the funciton:

ATTACH_VEHICLE_TO_TRAILER

Thank :)

 

Update:

The awesome answer is post #12 , thank 123iamking

Edited by Lovono

Share this post


Link to post
Share on other sites
Jitnaught

 

Use this function

int GET_ENTITY_TYPE(Entity entity) // 8ACD366038D14505 0B1BD08DReturns:1 = peds2 = cars3 = objects14 = SCRIPT_GLASS_PANE13 = SCRIPT_TRAIN12 = SCRIPT_TRAILER11 = PLAYER10 = SCRIPT_SUBMARINE9 = SCRIPT_PLANE8 = SCRIPT_PICKUP_PLACEMENT7 = SCRIPT_PICKUP6 =5 =4 =3 = SCRIPT_DOOR2 = SCRIPT_BOAT1 = SCRIPT_BIKE0 = SCRIPT_AUTOMOBILE

 

Or you can check if the model is contained within a list of the trailer models, which are

0xA7FF33F50x9E6B14D60xE82AE6560x1F3D44B50x806EFBEE0xD1ABB6660x3CC7F5960x153E1B0A0x174CB1720x782A236D0xCBB2BE0E0xA1DA3C910x8548036D0x2A72BEAB0x967620BE

The GET_ENTITY_TYPE function would be the ideal way to go though because if there are more trailers added later you won't have to update your mod to add them.

Or use the functions given in post #12.

Edited by Jitnaught

Share this post


Link to post
Share on other sites
unknown modder

Use this function

int GET_ENTITY_TYPE(Entity entity) // 8ACD366038D14505 0B1BD08DReturns:1 = peds2 = cars3 = objects14 = SCRIPT_GLASS_PANE13 = SCRIPT_TRAIN12 = SCRIPT_TRAILER11 = PLAYER10 = SCRIPT_SUBMARINE9 = SCRIPT_PLANE8 = SCRIPT_PICKUP_PLACEMENT7 = SCRIPT_PICKUP6 =5 =4 =3 = SCRIPT_DOOR2 = SCRIPT_BOAT1 = SCRIPT_BIKE0 = SCRIPT_AUTOMOBILE

Or you can check if the model is contained within a list of the trailer models, which are

0xA7FF33F50x9E6B14D60xE82AE6560x1F3D44B50x806EFBEE0xD1ABB6660x3CC7F5960x153E1B0A0x174CB1720x782A236D0xCBB2BE0E0xA1DA3C910x8548036D0x2A72BEAB0x967620BE

The GET_ENTITY_TYPE function would be the ideal way to go though because if there are more trailers added later you won't have to update your mod to add them.

GetEntityType only returns if its an object, ped or vehicle. not if its a trailer

Share this post


Link to post
Share on other sites
Jitnaught

But it says "12 = SCRIPT_TRAILER"?

Share this post


Link to post
Share on other sites
Lovono

Use this function

int GET_ENTITY_TYPE(Entity entity) // 8ACD366038D14505 0B1BD08DReturns:1 = peds2 = cars3 = objects14 = SCRIPT_GLASS_PANE13 = SCRIPT_TRAIN12 = SCRIPT_TRAILER11 = PLAYER10 = SCRIPT_SUBMARINE9 = SCRIPT_PLANE8 = SCRIPT_PICKUP_PLACEMENT7 = SCRIPT_PICKUP6 =5 =4 =3 = SCRIPT_DOOR2 = SCRIPT_BOAT1 = SCRIPT_BIKE0 = SCRIPT_AUTOMOBILE

Or you can check if the model is contained within a list of the trailer models, which are

0xA7FF33F50x9E6B14D60xE82AE6560x1F3D44B50x806EFBEE0xD1ABB6660x3CC7F5960x153E1B0A0x174CB1720x782A236D0xCBB2BE0E0xA1DA3C910x8548036D0x2A72BEAB0x967620BE

The GET_ENTITY_TYPE function would be the ideal way to go though because if there are more trailers added later you won't have to update your mod to add them.

Ah, since there is no native function help that, I think the solution 2 seems great.

But what strange is that there are native functions like:

IS_THIS_MODEL_A_PLANE_IS_THIS_MODEL_AN_EMERGENCY_BOATIS_THIS_MODEL_A_BOATIS_THIS_MODEL_A_HELIIS_THIS_MODEL_A_CARIS_THIS_MODEL_A_TRAIN...

So I think there should be a native to determine if it's the trailer model, maybe we still haven't found it yet.

Share this post


Link to post
Share on other sites
InfamousSabre

You can probably check for the position of the trailer hitch receiver bone. If it isnt 0,0,0, its a trailer.

Share this post


Link to post
Share on other sites
unknown modder

You can probably check for the position of the trailer hitch receiver bone. If it isnt 0,0,0, its a trailer.

that only works if it's spawned though. Also checking if boneindex is -1 would be easier. Edited by unknown modder

Share this post


Link to post
Share on other sites
InfamousSabre

I assume its already spawned since he's trying to attach it to a vehicle. You're right, checking the boneIndex would be better. I'm just going off the top of my head.

Edited by InfamousSabre

Share this post


Link to post
Share on other sites
unknown modder

But it says "12 = SCRIPT_TRAILER"?

But the native can literally only return 0(not an entity), 1, 2 or 3

DCoOs0d.png

Edited by unknown modder

Share this post


Link to post
Share on other sites
Lovono

I assume its already spawned since he's trying to attach it to a vehicle. You're right, checking the boneIndex would be better. I'm just going off the top of my head.

It's best to check before spawning, Imagine you want to draw a list of trailer to attach. I need a native function to check model trailer because who knows when will R* add new trailer model for the next DLC/Update.

Edited by Lovono

Share this post


Link to post
Share on other sites
unknown modder

 

I assume its already spawned since he's trying to attach it to a vehicle. You're right, checking the boneIndex would be better. I'm just going off the top of my head.

It's best to check before spawning, Imagine you want to draw a list of trailer to attach. I need a native function to check model trailer because who knows when will R* add new trailer model for the next DLC/Update.the native function may not exist, natives are only made if the scripts need to use them.

Share this post


Link to post
Share on other sites
123iamking

Here is how it's done

you can use 2 native function

VEHICLE::_GET_VEHICLE_MAX_SPEED(vehModel)//Later the function renamed to VEHICLE::_GET_VEHICLE_MODEL_MAX_SPEED by the authorVEHICLE::GET_VEHICLE_MODEL_ACCELERATION(vehModel))

The trailer always has the acceleration as 0, no doubt. And the speed as negative (-0.51). Just check a vehicle model if the acc is 0 or spd is negative and there you go.

Have fun :)

Edited by 123iamking

Share this post


Link to post
Share on other sites
bhavinbhai2707

heyy guys sorry to interrupt n ask question from this topic. . .

is their anyway to check if the car model is Michael,trevor,franklins personal vehicle. . .if u know please reply :)

Share this post


Link to post
Share on other sites
unknown modder

heyy guys sorry to interrupt n ask question from this topic. . .

is their anyway to check if the car model is Michael,trevor,franklins personal vehicle. . .if u know please reply :)

car model or actual car

Share this post


Link to post
Share on other sites
bhavinbhai2707

 

heyy guys sorry to interrupt n ask question from this topic. . .

is their anyway to check if the car model is Michael,trevor,franklins personal vehicle. . .if u know please reply :)

car model or actual cari mean to say their personal vehicles which have that blip on them. . . . i want to check whether the player ie(frank mike n trev) are in their personal vehicle or not

for ex:- if trev is in his truck then some code will activate i hope u understand what i mean

Edited by bhavinbhai2707

Share this post


Link to post
Share on other sites
Lovono

heyy guys sorry to interrupt n ask question from this topic. . .

is their anyway to check if the car model is Michael,trevor,franklins personal vehicle. . .if u know please reply :)

Thank you for join my topic :)

Did you try this native function

BOOL _GET_VEHICLE_OWNER(Vehicle vehicle, Entity* entity)//0x8F5EBAB1F260CFCE

Param:

The entity should be Michael, Trevor, Franklin ped, and vehicle is the vehicle you want to check

Share this post


Link to post
Share on other sites
bhavinbhai2707

 

heyy guys sorry to interrupt n ask question from this topic. . .

is their anyway to check if the car model is Michael,trevor,franklins personal vehicle. . .if u know please reply :)

Thank you for join my topic :)

Did you try this native function

BOOL _GET_VEHICLE_OWNER(Vehicle vehicle, Entity* entity)//0x8F5EBAB1F260CFCE
Param:

The entity should be Michael, Trevor, Franklin ped, and vehicle is the vehicle you want to check

i didn't understand the param section can u please give an example

Share this post


Link to post
Share on other sites
Jitnaught

​That code would require you to know the Ped handles of each player. I don't know how to get each player's ped so I'll just give you the code regarding _GET_VEHICLE_OWNER.

Ped michaelPed = /*get michael ped*/, trevorPed = /*get trevor ped*/, franklinPed = /*get franklin ped*/;Vehicle veh = /*vehicle you are checking*/;OutputArgument outArg = new OutputArgument();if (GTA.Native.Function.Call<bool>(Hash._GET_VEHICLE_OWNER, veh, outArg)){    Ped owner = (Ped)outArg.GetResult<Entity>(); //can you just cast it or should you use GET_PED_INDEX_FROM_ENTITY_INDEX?    if (owner == michaelPed)    {        //...    }    else if //...​}​else GTA.UI.Notify("No owner found");

Edited by Jitnaught

Share this post


Link to post
Share on other sites
unknown modder

​That code would require you to know the Ped handles of each player. I don't know how to get each player's ped so I'll just give you the code regarding _GET_VEHICLE_OWNER.

Ped michaelPed = /*get michael ped*/, trevorPed = /*get trevor ped*/, franklinPed = /*get franklin ped*/;Vehicle veh = /*vehicle you are checking*/;OutputArgument outArg = new OutputArgument();if (GTA.Native.Function.Call<bool>(Hash._GET_VEHICLE_OWNER, veh, outArg)){    Ped owner = (Ped)outArg.GetResult<Entity>(); //can you just cast it or should you use GET_PED_INDEX_FROM_ENTITY_INDEX?    if (owner == michaelPed)    {        //...    }    else if //...​}​else GTA.UI.Notify("No owner found");

you dont need to use GET_PED_INDEX_FROM_ENTITY_INDEX, that native seems like its what R* use to cast an entity to a ped in the scripts, but in reality it just returns whatever was passed to it

Share this post


Link to post
Share on other sites
Jitnaught

​Thanks for the info! :)

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.