Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      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. Forum Support

    3. Suggestions

[V|REL|HOOK] LUA Plugin for Script Hook V


headscript
 Share

Recommended Posts

 

I found this code in the thread by Alexander

void NotifyAboveMap(char* Message){	_0x202709F4C58A0424("STRING");	ADD_TEXT_COMPONENT_STRING(Message);	_0x2ED7843F8F801023(0, 1);}
but I have no idea how to actually use that in lua lol. If anyone could help or teach me, sh*t would be awesome.

 

Thanks for making this possible headscript

function NotifyAboveMap(message)    _0x202709F4C58A0424("STRING")    ADD_TEXT_COMPONENT_STRING(message)    _0x2ED7843F8F801023(0, 1)end
Try something like that, maybe? I'd test it but I'm without a computer for now...

 

Hm maybe those values aren't right, I can't find them on http://www.dev-c.com/nativedb/and it's giving me an error (a nil value). Appreciate the help!

Link to comment
Share on other sites

coldboy1357

Hi I am new to GTA scripting and new to LUA. but I had extensive scripting experience with ARMA.

 

Possible to provide a bit more example code for GUI? Specifically on how to invoke the GUI menu only on keypress, and hide the menu when no longer needed with keypress. I know the native trainer has that function and the source code is available, but I dont have VS2013 right now and I prefer LUA for the instant refreshing function without restarting the game.

 

Thanks mate! Nice work you have done.

Link to comment
Share on other sites

Check the bodyguard script I should have updated it here to use a GUI and to disable / enable it is just missing a user input block for some ms, which I can't send now because of no pc, the GUI. Lua uses it extensive though maybe have a look at there

Link to comment
Share on other sites

coldboy1357

Check the bodyguard script I should have updated it here to use a GUI and to disable / enable it is just missing a user input block for some ms, which I can't send now because of no pc, the GUI. Lua uses it extensive though maybe have a look at there

Now I have created a simple menu, but how do I clear the menu?

 

I simply called customMenu.GUI.unload(), but it doesn't do anything. Any example you can provide me? =)

 

Btw, the download link in the first post doesn't seem to be working for me.

 

Edit: discovered that simply not calling GUI.tick in the tick function will stop the menu from appearing. now I have a simple save car menu

Edited by coldboy1357
Link to comment
Share on other sites

I'm trying to figure out how to make the character play various animations (like dancing etc.) with a press of a button. Also is there any list with all the animations available?

Any help on this?

Link to comment
Share on other sites

This seems to be broken in this LUA scripthook for now. Many of the natives when called do not have the right parameter types. Like:

tick: scripts/addins/test.lua:10: error in function 'TASK_PLAY_ANIM'.     argument #3 is 'string'; 'number' expected.

The native function being called is:

AI.TASK_PLAY_ANIM(playerPed, "[email protected]@[email protected]@base", "take_off_helmet_walk", 0x8f, -0x8f, -1, 48, 0, 0, 0, 0)

 

This was just for testing but I may have to head back to C++ coding and restarting the game constantly during this research process...

 

@headscript: Do you need feedback like this to help fix things or are you waiting on someone to update the native DB? Thx

Link to comment
Share on other sites

Do you need feedback like this to help fix things or are you waiting on someone to update the native DB? Thx

smaller things i will fix my self but when native db is updated im way faster with fixing stuff

also for yours to work i should also change anim dicts to string aswell :)

thanks for feedback

Link to comment
Share on other sites

I've put two different scripts (ragdoll and slow motion, downloaded from gta5mods) in the folder as described in OP and did all the other things but I can't seem to get it working ingame. Nothing happens if I press either of the keys to activate the two scripts. Do I have to enable this lua plugin first or is there any reason why it wouldn't work? Other scripthook mods work fine such as the native trainer or carmageddon/mayhem.

Edited by Freezer89
Link to comment
Share on other sites

I've put two different scripts (ragdoll and slow motion, downloaded from gta5mods) in the folder as described in OP and did all the other things but I can't seem to get it working ingame. Nothing happens if I press either of the keys to activate the two scripts. Do I have to enable this lua plugin first or is there any reason why it wouldn't work? Other scripthook mods work fine such as the native trainer or carmageddon/mayhem.

you installed 2013 redist x64 ? if so send me the .log files

Link to comment
Share on other sites

 

 

 

 

 

I've put two different scripts (ragdoll and slow motion, downloaded from gta5mods) in the folder as described in OP and did all the other things but I can't seem to get it working ingame. Nothing happens if I press either of the keys to activate the two scripts. Do I have to enable this lua plugin first or is there any reason why it wouldn't work? Other scripthook mods work fine such as the native trainer or carmageddon/mayhem.

you installed 2013 redist x64 ? if so send me the .log files

 

 

I don't think so, no. But 2010. Where would I find these logfiles? I also checked in asiloader.log and there is this:

LOADER: Loading *.asi pluginsASI: Loading "C:\Program Files\Rockstar Games\Grand Theft Auto V\LUA.asi"     "LUA.asi" failed to load
Link to comment
Share on other sites

 

 

 

 

 

 

I've put two different scripts (ragdoll and slow motion, downloaded from gta5mods) in the folder as described in OP and did all the other things but I can't seem to get it working ingame. Nothing happens if I press either of the keys to activate the two scripts. Do I have to enable this lua plugin first or is there any reason why it wouldn't work? Other scripthook mods work fine such as the native trainer or carmageddon/mayhem.

you installed 2013 redist x64 ? if so send me the .log files

 

 

I don't think so, no. But 2010. Where would I find these logfiles? I also checked in asiloader.log and there is this:

LOADER: Loading *.asi pluginsASI: Loading "C:\Program Files\Rockstar Games\Grand Theft Auto V\LUA.asi"     "LUA.asi" failed to load

https://www.microsoft.com/en-us/download/details.aspx?id=40784

Link to comment
Share on other sites

I believe animations are a must have feature.

It will be great if you manage to include them in an update.

Keep up the great work!

 

Also, is this actually working?

AI.TASK_PLAY_ANIM(playerPed, "[email protected]@[email protected]@base", "take_off_helmet_walk", 0x8f, -0x8f, -1, 48, 0, 0, 0, 0)

I can't test it yet.

 

And how can I get the speed of the current car (in kmh) and display it as a ui text?

Edited by sakis25
Link to comment
Share on other sites

I believe animations are a must have feature.

It will be great if you manage to include them in an update.

Keep up the great work!

 

Also, is this actually working?

AI.TASK_PLAY_ANIM(playerPed, "[email protected]@[email protected]@base", "take_off_helmet_walk", 0x8f, -0x8f, -1, 48, 0, 0, 0, 0)

I can't test it yet.

 

And how can I get the speed of the current car (in kmh) and display it as a ui text?

 

I'm also sort of trying to find how to display text that way. I found slik's code for his .asi addon that displays car's speed above the minimap (https://github.com/slik/JMM/blob/master/JMM/script.cpp) but I'm a totally rookie and have no idea how to translate that into lua

Link to comment
Share on other sites

SET_VEHICLE_ENGINE_ON(Vehicle veh, BOOL engineState, BOOL p3)

is not working for some reason. The car engine is still on and if I add a vehicle in argument #1 I get an error.

Link to comment
Share on other sites

SET_VEHICLE_ENGINE_ON(Vehicle veh, BOOL engineState, BOOL p3)

is not working for some reason. The car engine is still on and if I add a vehicle in argument #1 I get an error.

 

VEHICLE.SET_VEHICLE_ENGINE_ON(vehicleID,true,true)

 

I believe animations are a must have feature.

It will be great if you manage to include them in an update.

Keep up the great work!

 

Also, is this actually working?

AI.TASK_PLAY_ANIM(playerPed, "[email protected]@[email protected]@base", "take_off_helmet_walk", 0x8f, -0x8f, -1, 48, 0, 0, 0, 0)

I can't test it yet.

 

And how can I get the speed of the current car (in kmh) and display it as a ui text?

you cant pass yet string arguments to AI.TASK_PLAY_ANIM i will add this feature soon(tomorrow/two days) if Alexander Blade doesnt update his nativesdb until then

Edited by headscript
Link to comment
Share on other sites

SgtDirtyMike

Here's my script:

 local SWATteam = {} local _start = os.time() local _end = _start+1 swat_toggle_key_code = 79function SWATteam.tick()	local playerPed = PLAYER.PLAYER_PED_ID()	local player = PLAYER.GET_PLAYER_PED(playerPed)	local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)	if not playerExists then		return	end		if(get_key_pressed(swat_toggle_key_code)) then		local veh = PED.GET_VEHICLE_PED_IS_IN(playerPed,true)				local clock = os.clock				local t0 = clock()				while clock() - t0 <= 1 do end				local SWATskinID = GAMEPLAY.GET_HASH_KEY("s_m_y_marine_03")				os.execute("sleep " .. tonumber(5))				local heliID = GAMEPLAY.GET_HASH_KEY("BUZZARD")				local coords = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0);				STREAMING.REQUEST_MODEL(SWATskinID)				STREAMING.REQUEST_MODEL(heliID)				local SWAT = PED.CREATE_PED( 26,SWATskinID,coords.x, coords.y, coords.z,0,false,true)				local group = PLAYER.GET_PLAYER_GROUP(PLAYER.PLAYER_ID())				local car = VEHICLE.CREATE_VEHICLE(heliID, coords.x, coords.y -5.0, coords.z, 0, false, true) 				PED.SET_PED_AS_GROUP_MEMBER(SWAT, group)				AI.TASK_COMBAT_HATED_TARGETS_AROUND_PED(SWAT, 5000, 0)				PED.SET_PED_KEEP_TASK(SWAT, true)				WEAPON.GIVE_DELAYED_WEAPON_TO_PED(SWAT, GAMEPLAY.GET_HASH_KEY("weapon_carbinerifle"), 5, true)				WEAPON.GIVE_DELAYED_WEAPON_TO_PED(SWAT, GAMEPLAY.GET_HASH_KEY("WEAPON_APPISTOL"), 5, true)				ENTITY.SET_ENTITY_INVINCIBLE(SWAT, false)				local driver = PED.CREATE_RANDOM_PED_AS_DRIVER(car, true)				PED.SET_PED_KEEP_TASK(driver, true)				AI.TASK_COMBAT_HATED_TARGETS_AROUND_PED(driver, 5000, 0)				AI.TASK_WARP_PED_INTO_VEHICLE(SWAT, car, -1)									endendreturn SWATteam

How do I spawn in the marine as a bodyguard in a vehicle to guard the player? They keep just driving off. Have been looking at the Natives, can't find anything that works.

Link to comment
Share on other sites

 

I believe animations are a must have feature.

It will be great if you manage to include them in an update.

Keep up the great work!

 

Also, is this actually working?

AI.TASK_PLAY_ANIM(playerPed, "[email protected]@[email protected]@base", "take_off_helmet_walk", 0x8f, -0x8f, -1, 48, 0, 0, 0, 0)

I can't test it yet.

 

And how can I get the speed of the current car (in kmh) and display it as a ui text?

 

I'm also sort of trying to find how to display text that way. I found slik's code for his .asi addon that displays car's speed above the minimap (https://github.com/slik/JMM/blob/master/JMM/script.cpp) but I'm a totally rookie and have no idea how to translate that into lua

 

 

Just tested this just now:

	function DEV.draw_text(text, x, y, scale)		UI.SET_TEXT_FONT(0)		UI.SET_TEXT_SCALE(scale, scale)		UI.SET_TEXT_COLOUR(255, 255, 255, 255)		UI.SET_TEXT_WRAP(0.0, 1.0)		UI.SET_TEXT_CENTRE(false)		UI.SET_TEXT_DROPSHADOW(2, 2, 0, 0, 0)		UI.SET_TEXT_EDGE(1, 0, 0, 0, 205)		UI._SET_TEXT_ENTRY("STRING")		UI._ADD_TEXT_COMPONENT_STRING(text)		UI._DRAW_TEXT(y, x)	end

Converting from C++ to LUA is slightly tricky as some folks use 0 for bool types. LUA is strictly false (I think?). This is only my third day scripting in LUA. I'm still getting used to how all the plumbing comes together.

 

Use

DEV.draw_text("JUST DISPLAY ME, DAMMIT", 0.5, 0.01, 0.3)

...as a test (0.5 to put it in mid height (y), 0.01 to put it just of the left side of the screen (x))

 

Change 'DEV' to the name of your local whatever = {}.

 

For example, I have a script which changes the license plate to "CAIN" and displays the above for any car I get into.

 

My DEV.lua:

local DEV = {}	function DEV.draw_text(text, x, y, scale)		UI.SET_TEXT_FONT(0)		UI.SET_TEXT_SCALE(scale, scale)		UI.SET_TEXT_COLOUR(255, 255, 255, 255)		UI.SET_TEXT_WRAP(0.0, 1.0)		UI.SET_TEXT_CENTRE(false)		UI.SET_TEXT_DROPSHADOW(2, 2, 0, 0, 0)		UI.SET_TEXT_EDGE(1, 0, 0, 0, 205)		UI._SET_TEXT_ENTRY("STRING")		UI._ADD_TEXT_COMPONENT_STRING(text)		UI._DRAW_TEXT(y, x)	end	function DEV.tick()		local playerPed = PLAYER.PLAYER_PED_ID()		local veh = PED.GET_VEHICLE_PED_IS_USING(playerPed)				if(PED.IS_PED_IN_ANY_VEHICLE(playerPed, false)) then			VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(veh, "CAIN")			DEV.draw_text("JUST DISPLAY ME, DAMMIT", 0.5, 0.01, 0.3)		end	endreturn DEV

Have fun.

Edited by ffzero58
Link to comment
Share on other sites

How do I spawn in the marine as a bodyguard in a vehicle to guard the player? They keep just driving off. Have been looking at the Natives, can't find anything that works.

 

If you're in a car, try the below.

AI::TASK_VEHICLE_ESCORT

Hash: 0x9FDCB250

void TASK_VEHICLE_ESCORT(Ped pedHandle, Vehicle vehicle, Vehicle targetVehicle,

int p3, float p4, Any p5, float minDistance, int p7,

float p8) // 0x9FDCB250

Makes a ped follow the targetVehicle with <minDistance> in between.

Check the rest of the AI namespace, there might be something there.

Link to comment
Share on other sites

SgtDirtyMike

 

How do I spawn in the marine as a bodyguard in a vehicle to guard the player? They keep just driving off. Have been looking at the Natives, can't find anything that works.

 

If you're in a car, try the below.

AI::TASK_VEHICLE_ESCORT

Hash: 0x9FDCB250

void TASK_VEHICLE_ESCORT(Ped pedHandle, Vehicle vehicle, Vehicle targetVehicle,

int p3, float p4, Any p5, float minDistance, int p7,

float p8) // 0x9FDCB250

Makes a ped follow the targetVehicle with <minDistance> in between.

Check the rest of the AI namespace, there might be something there.

 

What if Player isn't in vehicle?

Link to comment
Share on other sites

 

 

 

 

Just tested this just now:

	function DEV.draw_text(text, x, y, scale)		UI.SET_TEXT_FONT(0)		UI.SET_TEXT_SCALE(scale, scale)		UI.SET_TEXT_COLOUR(255, 255, 255, 255)		UI.SET_TEXT_WRAP(0.0, 1.0)		UI.SET_TEXT_CENTRE(false)		UI.SET_TEXT_DROPSHADOW(2, 2, 0, 0, 0)		UI.SET_TEXT_EDGE(1, 0, 0, 0, 205)		UI._SET_TEXT_ENTRY("STRING")		UI._ADD_TEXT_COMPONENT_STRING(text)		UI._DRAW_TEXT(y, x)	end

Converting from C++ to LUA is slightly tricky as some folks use 0 for bool types. LUA is strictly false (I think?). This is only my third day scripting in LUA. I'm still getting used to how all the plumbing comes together.

 

Use

DEV.draw_text("JUST DISPLAY ME, DAMMIT", 0.5, 0.01, 0.3)

...as a test (0.5 to put it in mid height (y), 0.01 to put it just of the left side of the screen (x))

 

Change 'DEV' to the name of your local whatever = {}.

 

For example, I have a script which changes the license plate to "CAIN" and displays the above for any car I get into.

 

My DEV.lua:

local DEV = {}	function DEV.draw_text(text, x, y, scale)		UI.SET_TEXT_FONT(0)		UI.SET_TEXT_SCALE(scale, scale)		UI.SET_TEXT_COLOUR(255, 255, 255, 255)		UI.SET_TEXT_WRAP(0.0, 1.0)		UI.SET_TEXT_CENTRE(false)		UI.SET_TEXT_DROPSHADOW(2, 2, 0, 0, 0)		UI.SET_TEXT_EDGE(1, 0, 0, 0, 205)		UI._SET_TEXT_ENTRY("STRING")		UI._ADD_TEXT_COMPONENT_STRING(text)		UI._DRAW_TEXT(y, x)	end	function DEV.tick()		local playerPed = PLAYER.PLAYER_PED_ID()		local veh = PED.GET_VEHICLE_PED_IS_USING(playerPed)				if(PED.IS_PED_IN_ANY_VEHICLE(playerPed, false)) then			VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(veh, "CAIN")			DEV.draw_text("JUST DISPLAY ME, DAMMIT", 0.5, 0.01, 0.3)		end	endreturn DEV

Have fun.

 

 

Awesome man that worked, thanks a lot!

 

Edited by Ynd21
Link to comment
Share on other sites

Hey guys, when I hit F4, 'unload' is not being called in my script, any ideas why?

I see that the bodyguard example script is not working properly also (bodyguards not being deleted when hit F4), so unload is not being called too.:

 

function bodyguard.unload()
for k,guard in pairs(bodyguard.peds) do
if( guard ~= nil) then
PED.DELETE_PED(guard)
bodyguard.peds[k] = nil
end
end
end

 

EDIT: Also, where is the part that loads stuff when you hit F4? It's not in main.lua any longer.

Edited by Szabo
Link to comment
Share on other sites

Do you have the LUA SDK? It was taken out (for some reason). Can we have it back in the SDK ver?

Link to comment
Share on other sites

Do you have the LUA SDK? It was taken out (for some reason). Can we have it back in the SDK ver?

it's still in there but not in main lua atm l, but don't worry it will come back with next bigger update

Hey guys, when I hit F4, 'unload' is not being called in my script, any ideas why?

I see that the bodyguard example script is not working properly also (bodyguards not being deleted when hit F4), so unload is not being called too.:

 

function bodyguard.unload()

for k,guard in pairs(bodyguard.peds) do

if( guard ~= nil) then

PED.DELETE_PED(guard)

bodyguard.peds[k] = nil

end

end

end

 

EDIT: Also, where is the part that loads stuff when you hit F4? It's not in main.lua any longer.

It's in the c++ part atm, but that it's not calling. Unload is definitely a bug gonna upload after work about at (7pm gmt +1) a new version to fix those kind of problems
Link to comment
Share on other sites

so this is my first time doing this and its giving me a in the console <a nil value>. anything i can change in the code im kind of a noob

local car ={}function car.tick()        local playerPed = PLAYER.PLAYER_PED_ID()	local player = PLAYER.GET_PLAYER_PED(playerPed)	local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)	if(playerExists) then		if(PED.IS_PED_IN_ANY_VEHICLE(playerPed, false)) then			local veh = PED.GET_VEHICLE_PED_IS_IN(playerPed,true)			if(get_key_pressed(110)) then				 SET_VEHICLE_ENGINE_ON(veh, false,true)				local testmodule = {}															end		end	endend return car
Link to comment
Share on other sites

VEHICLE.SET_VEHICLE_ENGINE_ON

THANK YOU ALOT

Edited by Marqurs
Link to comment
Share on other sites

So i'm trying to get this to work but so far i cant

if(get_key_pressed(117)) then                 print("Pressed F6")                 local nearby_peds = {}                 local nearby_ped_count = PED.GET_PED_NEARBY_PEDS(PLAYER.PLAYER_PED_ID, nearby_peds, -1)                 print("Nearby PEDs #: " .. string.format("%s", nearby_ped_count))                 if (nearby_ped_count > 0) then                        for k, v in ipairs(nearby_peds) do                                                             math.randomseed( os.time() )                                           local money_amount = math.random(1000,20000)                                PED.SET_PED_MONEY(v, money_amount);                                 print("Added $" .. string.format("%s", money_amount) .. " to PED")                        end                end          end
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.