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

Sign in to follow this  
That_Guy28

"explode nearest vehicle" script in lua - here's my code,

Recommended Posts

That_Guy28

I'm trying to make a script hook mod using lua that explodes whatever vehicle is nearest to the player.

I'm not really sure why it isn't working. When I activate it, nothing happens. It doesn't even crash anything.

I'm fairly confident that the part where it determines the player position is correct. I used that when I created my whale spawning mod.

I tried changing all the bools in "EXPLODE_VEHICLE" to true instead of false and that still doesn't work.

 

Is anyone able to see what I did wrong? There weren't any examples in the "native trainer" source code that I could go by since it has nothing to do with exploding vehicles.

 

Here's my code:

function explode_vehicle.tick()    if(get_key_pressed(Keys.F5))then    local playerPed = PLAYER.PLAYER_PED_ID()    local player = PLAYER.GET_PLAYER_PED(playerPed)    local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)    local vehicleToExplode = VEHICLE.GET_CLOSEST_VEHICLE(playerPosition.x,playerPosition.y,playerPosition.z, 1000, 0, 70)    VEHICLE.EXPLODE_VEHICLE(vehicleToExplode, false, false)end
Edited by That_Guy28

Share this post


Link to post
Share on other sites
Fireboyd78

I'd start with the basics and print out a debug message after getting the closest vehicle. You know to make sure it actually got a valid vehicle.

Edited by CarLuver69

Share this post


Link to post
Share on other sites
That_Guy28

How do I do that? Using "print(insert whatever here)" won't show anything on the screen or dump the output to a log file. Is there a way to make print() work? Is there another way to print debug messages? There's not even a relevant log file anywhere in my game directory.

Edited by That_Guy28

Share this post


Link to post
Share on other sites
Fireboyd78

Are you using headscript's Lua Scripthook? You should put both LUA.asi and LUA_SDK.asi and a console should appear once you enter story mode.

Share this post


Link to post
Share on other sites
Colarocker

found this searching the game scripts:

Searching armenian2.c4...
Line 32500: v_1C = VEHICLE::GET_CLOSEST_VEHICLE(-36.5853, -1101.4737548828125, 26.3444, 5.0, $\bjxl\, 4);
Line 32508: v_1C = VEHICLE::GET_CLOSEST_VEHICLE(-46.2593994140625, -1097.838623046875, 26.3444, 5.0, $\bjxl\, 4);
Line 32516: v_1C = VEHICLE::GET_CLOSEST_VEHICLE(-50.08, -1094.4625244140625, 26.0671, 5.0, $\tailgater\, 4);
Line 32524: v_1C = VEHICLE::GET_CLOSEST_VEHICLE(-37.41279983520508, -1088.561767578125, 26.0671, 5.0, $\tailgater\, 4);
Line 32532: v_1C = VEHICLE::GET_CLOSEST_VEHICLE(-41.425899505615234, -1099.6480712890625, 26.0534, 5.0, $\tailgater\, 4);
Line 41575: v_2C = VEHICLE::GET_CLOSEST_VEHICLE(ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), 1), 50.0, 0, v_2D);
Line 43213: v_8 = VEHICLE::GET_CLOSEST_VEHICLE(-36.5853, -1101.4737548828125, 26.3444, 5.0, $\bjxl\, 4);
Line 43217: v_8 = VEHICLE::GET_CLOSEST_VEHICLE(-46.2593994140625, -1097.838623046875, 26.3444, 5.0, $\schwarzer\, 2);
Line 43221: v_8 = VEHICLE::GET_CLOSEST_VEHICLE(-50.08, -1094.4625244140625, 26.0671, 5.0, $\tailgater\, 4);
Line 43225: v_8 = VEHICLE::GET_CLOSEST_VEHICLE(-37.41279983520508, -1088.561767578125, 26.0671, 5.0, $\tailgater\, 4);
Line 43229: v_8 = VEHICLE::GET_CLOSEST_VEHICLE(-41.425899505615234, -1099.6480712890625, 26.0534, 5.0, $\baller\, 2);

 

as you can see, it looks for a specific vehicle model with $\baller\ , im not sure about the 2 other numbers.. so its cords xyz, a number 5.0, vehiclemodel, and another number ^^

so what i think you can just look for a specific vehicle..

if you manage it to make a list for all vehicles and call it from that position it should be possible to search for all models as closest vehicle?

found something similiar for GTA IV.. if you got it going pls update it, i'm gonna dig into it too now xD

 

edit: okay in the game scripts they also use 0 instead of a model.. ^^

Edited by Colarocker

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.

Sign in to follow this  

  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.