Jump to content

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


headscript

Recommended Posts

Thanks for the update.

 

Can basemodule.lua be deleted like exampleGUI.lua or is it needed for functionality?

Link to comment
Share on other sites

v10.0 Auto-builds every 10 min? That's a killer one headscript! Thank you! :)

Edited by Szabo
Link to comment
Share on other sites

v10.0 Auto-builds every 10 min? That's a killer one headscript! Thank you! :)

Yeah, nativedb updates each 10mins :cool:

Link to comment
Share on other sites

Just a quick question.
What's up with the new files added in this version that weren't in 9.0?

I'm talking about the following files inside the scripts folder:

keys.lua

utils.lua

 

Also inside the addins folder there's:

 

basemodule.lua

exampleGUI.lua

 

I already deleted the example gui thing but I'm not sure about the basemodule file, is it important?

Link to comment
Share on other sites

diamond-optic

anyone know how to get how much ammo is in a weapons clip?

 

trying GET_AMMO_IN_CLIP, and going by http://www.gtamodding.com/wiki/GET_AMMO_IN_CLIP the 3rd param should be a variable for it to save the amount of ammo to, but when using the native its saying the 3rd param has to be a number and not an empty variable

 

*edit*

 

ughh maybe that native description is wrong, just noticed it says its from gta iv even tho i was brought to that page from the gta v native listing

 

and the gta v entry from the nativedb isnt very helpful when it comes to figuring out how to get an actual clip ammo value:

 

BOOL GET_AMMO_IN_CLIP(Ped Handle, Hash WeaponHash, Any *p2)

Edited by diamond-optic
Link to comment
Share on other sites

flynhigh09

GET_AMMO_IN_CLIP(Pedid, WeaponHash, true);

 

anyone know how to get how much ammo is in a weapons clip?

 

trying GET_AMMO_IN_CLIP, and going by http://www.gtamodding.com/wiki/GET_AMMO_IN_CLIP the 3rd param should be a variable for it to save the amount of ammo to, but when using the native its saying the 3rd param has to be a number and not an empty variable

 

*edit*

 

ughh maybe that native description is wrong, just noticed it says its from gta iv even tho i was brought to that page from the gta v native listing

 

and the gta v entry from the nativedb isnt very helpful when it comes to figuring out how to get an actual clip ammo value:

 

BOOL GET_AMMO_IN_CLIP(Ped Handle, Hash WeaponHash, Any *p2)

Edited by flynhigh09
Link to comment
Share on other sites

diamond-optic

GET_AMMO_IN_CLIP(Pedid, WeaponHash, true);

 

error in function 'GET_AMMO_IN_CLIP'. argument #3 is 'boolean'; 'number' expected.

 

 

 

*edit*

 

 

..but i did just now notice v10 of this is out.. installed it, and basically my entire script is now broken lol.. so I guess its more important for me to figure out why its not working anymore :-\ hmm lol

 

 

*edit 2*

 

i think i see what my problem is now.. im not getting the same hashes I was with the previous version....

 

before these would give the same hash, now they are different...

 

 

 

-- have UNARMED selected  print("get_hash: ".. GAMEPLAY.GET_HASH_KEY("WEAPON_UNARMED")) print("player_weap: ".. WEAPON.GET_SELECTED_PED_WEAPON(PLAYER.PLAYER_PED_ID()))
console output:

 

get_hash: -1569615261

player_weap: 2725352035

 

*edit 4*

 

using the old version:

 

get_hash: 2725352035

player_weap: 2725352035

Edited by diamond-optic
Link to comment
Share on other sites

headscript

 

GET_AMMO_IN_CLIP(Pedid, WeaponHash, true);

 

error in function 'GET_AMMO_IN_CLIP'. argument #3 is 'boolean'; 'number' expected.

 

 

 

*edit*

 

 

..but i did just now notice v10 of this is out.. installed it, and basically my entire script is now broken lol.. so I guess its more important for me to figure out why its not working anymore :-\ hmm lol

 

 

*edit 2*

 

i think i see what my problem is now.. im not getting the same hashes I was with the previous version....

 

before these would give the same hash, now they are different...

 

 

 

-- have UNARMED selected  print("get_hash: ".. GAMEPLAY.GET_HASH_KEY("WEAPON_UNARMED")) print("player_weap: ".. WEAPON.GET_SELECTED_PED_WEAPON(PLAYER.PLAYER_PED_ID()))
console output:

 

get_hash: -1569615261

player_weap: 2725352035

 

*edit 4*

 

using the old version:

 

get_hash: 2725352035

player_weap: 2725352035

 

not my fault on nativedb GET_HASH_KEY(char *ToHash)

returns a int instead of a Hash

change it there and wait 10-20 min for the next version on github

Edited by headscript
Link to comment
Share on other sites

Just a quick question.

What's up with the new files added in this version that weren't in 9.0?

I'm talking about the following files inside the scripts folder:

 

keys.lua

utils.lua

 

Also inside the addins folder there's:

 

basemodule.lua

exampleGUI.lua

 

I already deleted the example gui thing but I'm not sure about the basemodule file, is it important?

Keys.lua & Utils.lua is a split of main.lua to keep it more organized.

 

You can remove both basemodule.lua and exampleGUI.lua

Link to comment
Share on other sites

diamond-optic

changing the return from int to Hash for the GET_HASH_KEY fixed the issue I was having earliar, on to the next one now lol

 

but.. did the natives get like.. messed up or something?

 

because now im also finding that:

 

 

  local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(PLAYER.PLAYER_PED_ID(), 0.0, 0.0, 0.0)  print("x: ", playerPosition.x)  print("y: ", playerPosition.y)  print("z: ", playerPosition.z)
outputs the same coords as:

 

 

  local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(PLAYER.PLAYER_PED_ID(), 10.0, 5.0, 0.5)  print("x: ", playerPosition.x)  print("y: ", playerPosition.y)  print("z: ", playerPosition.z)
..like its not doing anything with the offset values anymore

 

 

*edit*

 

GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS is working now after changing the coord params from int to float

 

 

..what happened to all this stuff that was working fine before?

Edited by diamond-optic
Link to comment
Share on other sites

headscript

changing the return from int to Hash for the GET_HASH_KEY fixed the issue I was having earliar, on to the next one now lol

 

but.. did the natives get like.. messed up or something?

 

because now im also finding that:

 

  local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(PLAYER.PLAYER_PED_ID(), 0.0, 0.0, 0.0)  print("x: ", playerPosition.x)  print("y: ", playerPosition.y)  print("z: ", playerPosition.z)
outputs the same coords as:

 

 

  local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(PLAYER.PLAYER_PED_ID(), 10.0, 5.0, 0.5)  print("x: ", playerPosition.x)  print("y: ", playerPosition.y)  print("z: ", playerPosition.z)
..like its not doing anything with the offset values anymore

 

 

*edit*

 

GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS is working now after changing the coord params from int to float

 

 

..what happened to all this stuff that was working fine before?

 

well i hate made many changes myself in my private natives.h to fix some of those issues

and on nativedb they were changed to it before the update

but the update didnt only changed the hashes it also reverted the argument and return types

Link to comment
Share on other sites

The SDK file works however the Lua.ASI does not. I don't want the file updated every 10 mins.

Link to comment
Share on other sites

Anyone have the lua plugin for 9.0 for download? I was stupid and didn't back up but replaced my lua with this update and want to roll back.

Link to comment
Share on other sites

headscript

Anyone have the lua plugin for 9.0 for download? I was stupid and didn't back up but replaced my lua with this update and want to roll back.

whats wrong with it?

 

 

The SDK file works however the Lua.ASI does not. I don't want the file updated every 10 mins.

how does it not work? and why dont u want it to be rebuild every 10 mins?

Link to comment
Share on other sites

Can anyone tell me why is says nil value for get_frame_count? I am very new to this and tried to test my first easy lua file to learn from, I obviously am doing something wrong, but what?

local FPSCounter = {}local FPS = 30function FPSCounter.init()	wait(0)	FPSCounter.FPS = GAMEPLAY.GET_FRAME_COUNT()	FPSUI.SET_TEXT_FONT(0)        FPSUI.SET_TEXT_PROPORTIONAL(1)        FPSUI.SET_TEXT_SCALE(0.0, 0.35)        FPSUI.SET_TEXT_COLOUR(255, 255, 255, 255)        FPSUI.SET_TEXT_DROPSHADOW(0, 0, 0, 0,255)        FPSUI.SET_TEXT_EDGE(1, 0, 0, 0, 255)        FPSUI.SET_TEXT_DROP_SHADOW()        FPSUI.SET_TEXT_OUTLINE()        FPSUI._SET_TEXT_ENTRY("STRING")        FPSUI._ADD_TEXT_COMPONENT_STRING(FPSCounter.FPS)        FPSUI._DRAW_TEXT(0.05, 0.05)endreturn FPSCounter
Edited by xToK3x
Link to comment
Share on other sites

alfonsouchiha

is it possible to install this LUA Plugin side-by-side with the GTALua? Because some mods need this plugin, the other need GTALua :O

please answer :D

Link to comment
Share on other sites

is it possible to install this LUA Plugin side-by-side with the GTALua? Because some mods need this plugin, the other need GTALua :O please answer :D

Yes, it's possible.

But make sure you dont put GTALua addons into this addons folder and the other way around :D

Link to comment
Share on other sites

 

 

 

 

What key is it to reload the files? it used to be F3 but i think he changed it

ctrl + R

 

nvm that doesnt work

 

do you use the sdk?

 

No

 

Reload don't work for me too even with the SDK version.

Link to comment
Share on other sites

diamond-optic

Reload don't work for me too even with the SDK version.

do you have the game paused or something? reload only works while not in the menu/loading screen/paused

Edited by diamond-optic
Link to comment
Share on other sites

I'm having an issue swapping the player skin, causing Script Hook/LUA to crash. I can spawn any ped just fine, but when I try to swap the player skin, I get an error and the game crashes.

 

With this code, the game doesn't crash, but the player skin doesn't swap either:

local player = PLAYER.PLAYER_ID()local playerPed = PLAYER.PLAYER_PED_ID()local ImpoSkinID = GAMEPLAY.GET_HASH_KEY("u_m_y_imporage");ENTITY.SET_ENTITY_INVINCIBLE(playerPed, true);	if(CONTROLS.IS_CONTROL_PRESSED(x,x))then	STREAMING.REQUEST_MODEL(ImpoSkinID);	PLAYER.SET_PLAYER_MODEL(playerPed, ImpoSkinID);	AI.TASK_SKY_DIVE(playerPed);	ENTITY.SET_ENTITY_INVINCIBLE(playerPed, true);

With this code, the game crashes:

local player = PLAYER.PLAYER_ID()local playerPed = PLAYER.PLAYER_PED_ID()local ImpoSkinID = GAMEPLAY.GET_HASH_KEY("u_m_y_imporage");ENTITY.SET_ENTITY_INVINCIBLE(playerPed, true);	if(CONTROLS.IS_CONTROL_PRESSED(x,x))then	STREAMING.REQUEST_MODEL(ImpoSkinID);	PLAYER.SET_PLAYER_MODEL(player, ImpoSkinID);	AI.TASK_SKY_DIVE(playerPed);	ENTITY.SET_ENTITY_INVINCIBLE(playerPed, true);

The only thing I change is playerPed to player in PLAYER.SET_PLAYER_MODEL. I've tried all combinations, this is how scripthook itself does it, or am I missing something? Ignore the button push line, I removed the variables for display here.

 

Edit: I added the following checks and it spawned him, but now it's crashing again after a restart:

STREAMING.IS_MODEL_IN_CDIMAGE(ImpoSkinID) and STREAMING.IS_MODEL_VALID(ImpoSkinID)

Edit2: Seems to be a LUA issue, if I start the game with the following code, it crashes when I press the button for spawning:

if CONTROLS.IS_CONTROL_PRESSED(x,x) and CONTROLS.IS_CONTROL_PRESSED(x,x) and STREAMING.IS_MODEL_IN_CDIMAGE(ImpoSkinID) and STREAMING.IS_MODEL_VALID(ImpoSkinID) then		STREAMING.REQUEST_MODEL(ImpoSkinID);		PLAYER.SET_PLAYER_MODEL(player, ImpoSkinID);

However, if I start the game with this code, then change the playerPed variable to player and reload the scripts using Ctrl+R, it works fine.

if CONTROLS.IS_CONTROL_PRESSED(x,x) and CONTROLS.IS_CONTROL_PRESSED(x,x) and STREAMING.IS_MODEL_IN_CDIMAGE(ImpoSkinID) and STREAMING.IS_MODEL_VALID(ImpoSkinID) then		STREAMING.REQUEST_MODEL(ImpoSkinID);		PLAYER.SET_PLAYER_MODEL(playerPed, ImpoSkinID);**Change PLAYER.SET_PLAYER_MODEL(playerPed, ImpoSkinID); to PLAYER.SET_PLAYER_MODEL(player, ImpoSkinID); then reload scripts, works fine

Edit3: STREAMING.REQUEST_MODEL(ImpoSkinID); has to be declared before the button is pressed, works now with the following:

function ImpotentRage.tick()	local player = PLAYER.PLAYER_ID()	local playerPed = PLAYER.PLAYER_PED_ID()	local ImpoSkinID = GAMEPLAY.GET_HASH_KEY("u_m_y_imporage");	STREAMING.REQUEST_MODEL(ImpoSkinID);	ENTITY.SET_ENTITY_INVINCIBLE(playerPed, true);		if CONTROLS.IS_CONTROL_PRESSED(x,x) and CONTROLS.IS_CONTROL_PRESSED(x,x) and STREAMING.IS_MODEL_IN_CDIMAGE(ImpoSkinID) and STREAMING.IS_MODEL_VALID(ImpoSkinID) then		keypress0=true		PLAYER.SET_PLAYER_MODEL(player, ImpoSkinID);		ENTITY.SET_ENTITY_INVINCIBLE(playerPed, true);
Edited by H1Vltg3
Link to comment
Share on other sites

 

Anyone have the lua plugin for 9.0 for download? I was stupid and didn't back up but replaced my lua with this update and want to roll back.

whats wrong with it?

 

 

The SDK file works however the Lua.ASI does not. I don't want the file updated every 10 mins.

how does it not work? and why dont u want it to be rebuild every 10 mins?

 

 

None of my lua scripted plugins work with this version of the injector as of last evening. The SDK loaded fine, but the normal asi did not load the lua scripts at all. The GUI was not appearing.

 

I do not want the script injector to rebuild every 10 mins because entire mods are created based on predictable code. If this code can change every ten mins with updates to a website then all mods will become unstable with this version. This will prove much more useful as time goes by but at present, mod development is still in its infancy, which means significant changes are still to come to.

Link to comment
Share on other sites

 

 

Anyone have the lua plugin for 9.0 for download? I was stupid and didn't back up but replaced my lua with this update and want to roll back.

whats wrong with it?

 

 

The SDK file works however the Lua.ASI does not. I don't want the file updated every 10 mins.

how does it not work? and why dont u want it to be rebuild every 10 mins?

 

 

None of my lua scripted plugins work with this version of the injector as of last evening. The SDK loaded fine, but the normal asi did not load the lua scripts at all. The GUI was not appearing.

 

I do not want the script injector to rebuild every 10 mins because entire mods are created based on predictable code. If this code can change every ten mins with updates to a website then all mods will become unstable with this version. This will prove much more useful as time goes by but at present, mod development is still in its infancy, which means significant changes are still to come to.

 

 

I agree. Plus I can't think that rebuilding every 10 mins is good for performance either. Any errors will also cause issues. I guess you want to reduce maintenance but being able to just manually trigger the update (for example on game start) should the developer wish to do so would be best. The non-SDK LUA.asi should not update.

Link to comment
Share on other sites

headscript

 

 

 

Anyone have the lua plugin for 9.0 for download? I was stupid and didn't back up but replaced my lua with this update and want to roll back.

whats wrong with it?

 

 

The SDK file works however the Lua.ASI does not. I don't want the file updated every 10 mins.

how does it not work? and why dont u want it to be rebuild every 10 mins?

 

 

None of my lua scripted plugins work with this version of the injector as of last evening. The SDK loaded fine, but the normal asi did not load the lua scripts at all. The GUI was not appearing.

 

I do not want the script injector to rebuild every 10 mins because entire mods are created based on predictable code. If this code can change every ten mins with updates to a website then all mods will become unstable with this version. This will prove much more useful as time goes by but at present, mod development is still in its infancy, which means significant changes are still to come to.

 

 

I agree. Plus I can't think that rebuilding every 10 mins is good for performance either. Any errors will also cause issues. I guess you want to reduce maintenance but being able to just manually trigger the update (for example on game start) should the developer wish to do so would be best. The non-SDK LUA.asi should not update.

 

it has nothing to do with performance,

also it only updates when u download the new version from github else u still have the version

 

The non-SDK LUA.asi should not update.

it doesnt anyways

 

 

 

 

 

Anyone have the lua plugin for 9.0 for download? I was stupid and didn't back up but replaced my lua with this update and want to roll back.

whats wrong with it?

 

 

The SDK file works however the Lua.ASI does not. I don't want the file updated every 10 mins.

how does it not work? and why dont u want it to be rebuild every 10 mins?

 

 

None of my lua scripted plugins work with this version of the injector as of last evening. The SDK loaded fine, but the normal asi did not load the lua scripts at all. The GUI was not appearing.

 

I do not want the script injector to rebuild every 10 mins because entire mods are created based on predictable code. If this code can change every ten mins with updates to a website then all mods will become unstable with this version. This will prove much more useful as time goes by but at present, mod development is still in its infancy, which means significant changes are still to come to.

 

did u tried if it works with the lua.asi in the sdk?

 

 

 

Edit: revert to v9

Edited by headscript
Link to comment
Share on other sites

diamond-optic

the whole nativedb setup is starting to annoy me lol..

 

I spend hours going through the game scripts and debugging natives just to have any edits i make reverted within a few hours. Even things that are obviously right when checking the native usage in the game scripts, such as native returns being int's yet they keep getting changed back to bool's in the nativedb. Pretty much dont even want to bother trying to fix things in it anymore

 

..but at the same time, i dont know if someone else is reverting the changes, or if theres some sort of automation involved that's resetting things

 

 

too bad there isnt anything like edit time/user/reason info with the db

Edited by diamond-optic
Link to comment
Share on other sites

vitalik2187836

Hey, headscript, can you add ability to reload scipts in non sdk version? Cos sdk version dont work fine for me. Idk why(. And also i hate console ^^

Link to comment
Share on other sites

diamond-optic

you should probably just dump v10 and recompile it as v11 (or at least like v10.1 or something to make it different) to get past the issue with some people having a v10 copy that has messed up natives

 

 

Because using the non-sdk v10 from your website causes both of my released scripts to not work, so I have to tell people now to get the non-sdk version from the github master instead... which will probably lead to confusion among some people (if they even notice that i said to use the github version instead to begin with lol)

..it would just be easier to tell people that my scripts require v11+ instead

 

 

*edit*

 

 

also, is there any way to tell which LUA.asi (or LUA_SDK.asi) version you have installed? And if not, would there be some way to add something like this?

Even maybe a variable or some such that you can call in a script to check the version, which other then being able to see which version you have installed, it could be useful to make your script require at least a specific version or something that might have fixed natives you are using in the script (or maybe at least warn the user to update).

Edited by diamond-optic
  • Like 2
Link to comment
Share on other sites

carcols.dat

Hey, headscript, can you add ability to reload scipts in non sdk version? Cos sdk version dont work fine for me. Idk why(. And also i hate console ^^

Seconding this. I don't have any issues but there really needs to be a reload function, and a per-script reload.

Link to comment
Share on other sites

XXCrimsonXX

Um everytime I install this I'm getting an error depicting that both of the lua.asi files have failed to load, why??

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