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. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

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

      1. Recruitment
    2. Events

    1. GTA Online

      1. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    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 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 Mods
    10. GTA Vice City

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

      1. Guides & Strategies
      2. Help & Support
      3. GTA 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

headscript

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

Recommended Posts

Ynd21

 

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!

Share this post


Link to post
Share on other sites
headscript

Put a UI. before for the name space or GRAPHICS cant check now no pc here

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
headscript

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
sakis25

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?

Share this post


Link to post
Share on other sites
ffzero58

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

Share this post


Link to post
Share on other sites
headscript

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

Share this post


Link to post
Share on other sites
Freezer89

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

Share this post


Link to post
Share on other sites
headscript

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

Share this post


Link to post
Share on other sites
Freezer89

 

 

 

 

 

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

Share this post


Link to post
Share on other sites
Chumillas

 

 

 

 

 

 

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

Share this post


Link to post
Share on other sites
sakis25

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

Share this post


Link to post
Share on other sites
Ynd21

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

Share this post


Link to post
Share on other sites
Foul_Play

EDIT:

 

Moved everything here: Bodyguard Script

Edited by Foul_Play

Share this post


Link to post
Share on other sites
sakis25
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.

Share this post


Link to post
Share on other sites
headscript
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
ffzero58

 

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

Share this post


Link to post
Share on other sites
ffzero58
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.

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites
Ynd21

 

 

 

 

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

Share this post


Link to post
Share on other sites
Szabo

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

Share this post


Link to post
Share on other sites
ffzero58

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

Share this post


Link to post
Share on other sites
headscript

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

Share this post


Link to post
Share on other sites
Marqurs

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

Share this post


Link to post
Share on other sites
headscript

VEHICLE.SET_VEHICLE_ENGINE_ON

Share this post


Link to post
Share on other sites
Marqurs

VEHICLE.SET_VEHICLE_ENGINE_ON

THANK YOU ALOT

Edited by Marqurs

Share this post


Link to post
Share on other sites
xsploit

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

Share this post


Link to post
Share on other sites
headscript

Nearby peds doesn't work yet

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.

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.


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