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

What is a good program to use for writing lua scripts? :)

Nvm guess any text editor will do

Edited by Echelonc
Link to comment
Share on other sites

What is a good program to use for writing lua scripts? :)

Nvm guess any text editor will do

 

Notepad++ and SublimeText are very good ones, you don't need more. Both support plugins and autocompletion.

 

The script doesn't work for me for some reason, it says that it failed to run in the log. I had the same issue with the vehicle controller script but that was solved somehow.

 

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

Link to comment
Share on other sites

Any way to have autocompletion in something like notepad++? I don't really know any of the variables like GET_WANTED_LEVEL_RADIUS

Link to comment
Share on other sites

Any way to have autocompletion in something like notepad++? I don't really know any of the variables like GET_WANTED_LEVEL_RADIUS

Once you already have something typed notepad++ will show an auto completion thing when you start typing something simliar to it go through it with the arrow keys and press enter or use your mouse to select it

Link to comment
Share on other sites

Im trying to make a prop spawning script but console keeps saying

tick: scripts/addins.propspawner.lua:16: attempt to call global 'CREATE_OBJECT' (a nil value)

heres my code

local propspawn ={}function propspawn.tick()local propID = GAMEPLAY.GET_HASH_KEY("petrol_pump")		local playerPed = PLAYER.PLAYER_PED_ID()		local player = PLAYER.GET_PLAYER_PED(playerPed)		local playerID = PLAYER.PLAYER_ID()		local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)		local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)		local playerGroup = PED.GET_PED_GROUP_INDEX(playerPed)	local player = PLAYER.GET_PLAYER_PED(playerPed)	local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)	if(playerExists) then	if(get_key_pressed(40)) then	CREATE_OBJECT(PETROL_PUMP)	propspawn.unload()		STREAMING.REQUEST_MODEL(propID)		while(not STREAMING.HAS_MODEL_LOADED(propID)) do				wait(50)		end			prop.object[i] = OBJECT.CREATE_OBJECT( 26,propID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)			STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(propID)		end	end	end	return propspawn
Link to comment
Share on other sites

Personality

 

Im trying to make a prop spawning script but console keeps saying

tick: scripts/addins.propspawner.lua:16: attempt to call global 'CREATE_OBJECT' (a nil value)

heres my code

local propspawn ={}function propspawn.tick()local propID = GAMEPLAY.GET_HASH_KEY("petrol_pump")		local playerPed = PLAYER.PLAYER_PED_ID()		local player = PLAYER.GET_PLAYER_PED(playerPed)		local playerID = PLAYER.PLAYER_ID()		local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)		local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)		local playerGroup = PED.GET_PED_GROUP_INDEX(playerPed)	local player = PLAYER.GET_PLAYER_PED(playerPed)	local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)	if(playerExists) then	if(get_key_pressed(40)) then	CREATE_OBJECT(PETROL_PUMP)	propspawn.unload()		STREAMING.REQUEST_MODEL(propID)		while(not STREAMING.HAS_MODEL_LOADED(propID)) do				wait(50)		end			prop.object[i] = OBJECT.CREATE_OBJECT( 26,propID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)			STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(propID)		end	end	end	return propspawn

 

I made a example this should work

 

local basemodule = {} function basemodule.unload()endfunction basemodule.init() endfunction basemodule.tick()local player = PLAYER.PLAYER_ID()local playerPed = PLAYER.PLAYER_PED_ID()local coords = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)if(get_key_pressed(114)) then OBJECT.CREATE_OBJECT(GAMEPLAY.GET_HASH_KEY("prop_windmill_01"), coords.x, coords.y, coords.z, true, false, true);end endreturn basemodule
Edited by Personality
Link to comment
Share on other sites

 

 

Im trying to make a prop spawning script but console keeps saying

tick: scripts/addins.propspawner.lua:16: attempt to call global 'CREATE_OBJECT' (a nil value)

heres my code

local propspawn ={}function propspawn.tick()local propID = GAMEPLAY.GET_HASH_KEY("petrol_pump")		local playerPed = PLAYER.PLAYER_PED_ID()		local player = PLAYER.GET_PLAYER_PED(playerPed)		local playerID = PLAYER.PLAYER_ID()		local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)		local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)		local playerGroup = PED.GET_PED_GROUP_INDEX(playerPed)	local player = PLAYER.GET_PLAYER_PED(playerPed)	local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)	if(playerExists) then	if(get_key_pressed(40)) then	CREATE_OBJECT(PETROL_PUMP)	propspawn.unload()		STREAMING.REQUEST_MODEL(propID)		while(not STREAMING.HAS_MODEL_LOADED(propID)) do				wait(50)		end			prop.object[i] = OBJECT.CREATE_OBJECT( 26,propID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)			STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(propID)		end	end	end	return propspawn

 

I made a example this should work

local basemodule = {} function basemodule.unload()endfunction basemodule.init() endfunction basemodule.tick()local player = PLAYER.PLAYER_ID()local playerPed = PLAYER.PLAYER_PED_ID()local coords = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)if(get_key_pressed(114)) then OBJECT.CREATE_OBJECT(GAMEPLAY.GET_HASH_KEY("prop_windmill_01"), coords.x, coords.y, coords.z, true, false, true);end endreturn basemodule

Still getting an error

Error in function 'CREATE_OBJECT'. Argument #5 is 'number'; 'boolean' expected.

Link to comment
Share on other sites

Personality

 

 

 

Im trying to make a prop spawning script but console keeps saying

tick: scripts/addins.propspawner.lua:16: attempt to call global 'CREATE_OBJECT' (a nil value)

heres my code

local propspawn ={}function propspawn.tick()local propID = GAMEPLAY.GET_HASH_KEY("petrol_pump")		local playerPed = PLAYER.PLAYER_PED_ID()		local player = PLAYER.GET_PLAYER_PED(playerPed)		local playerID = PLAYER.PLAYER_ID()		local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)		local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)		local playerGroup = PED.GET_PED_GROUP_INDEX(playerPed)	local player = PLAYER.GET_PLAYER_PED(playerPed)	local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)	if(playerExists) then	if(get_key_pressed(40)) then	CREATE_OBJECT(PETROL_PUMP)	propspawn.unload()		STREAMING.REQUEST_MODEL(propID)		while(not STREAMING.HAS_MODEL_LOADED(propID)) do				wait(50)		end			prop.object[i] = OBJECT.CREATE_OBJECT( 26,propID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)			STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(propID)		end	end	end	return propspawn

 

I made a example this should work

local basemodule = {} function basemodule.unload()endfunction basemodule.init() endfunction basemodule.tick()local player = PLAYER.PLAYER_ID()local playerPed = PLAYER.PLAYER_PED_ID()local coords = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)if(get_key_pressed(114)) then OBJECT.CREATE_OBJECT(GAMEPLAY.GET_HASH_KEY("prop_windmill_01"), coords.x, coords.y, coords.z, true, false, true);end endreturn basemodule

Still getting an error

Error in function 'CREATE_OBJECT'. Argument #5 is 'number'; 'boolean' expected.

 

 

Yeah i edited my post and fixed that straight after :lol:

Link to comment
Share on other sites

 

 

 

 

Im trying to make a prop spawning script but console keeps saying

tick: scripts/addins.propspawner.lua:16: attempt to call global 'CREATE_OBJECT' (a nil value)

heres my code

local propspawn ={}function propspawn.tick()local propID = GAMEPLAY.GET_HASH_KEY("petrol_pump")		local playerPed = PLAYER.PLAYER_PED_ID()		local player = PLAYER.GET_PLAYER_PED(playerPed)		local playerID = PLAYER.PLAYER_ID()		local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)		local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)		local playerGroup = PED.GET_PED_GROUP_INDEX(playerPed)	local player = PLAYER.GET_PLAYER_PED(playerPed)	local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)	if(playerExists) then	if(get_key_pressed(40)) then	CREATE_OBJECT(PETROL_PUMP)	propspawn.unload()		STREAMING.REQUEST_MODEL(propID)		while(not STREAMING.HAS_MODEL_LOADED(propID)) do				wait(50)		end			prop.object[i] = OBJECT.CREATE_OBJECT( 26,propID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)			STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(propID)		end	end	end	return propspawn

 

I made a example this should work

local basemodule = {} function basemodule.unload()endfunction basemodule.init() endfunction basemodule.tick()local player = PLAYER.PLAYER_ID()local playerPed = PLAYER.PLAYER_PED_ID()local coords = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)if(get_key_pressed(114)) then OBJECT.CREATE_OBJECT(GAMEPLAY.GET_HASH_KEY("prop_windmill_01"), coords.x, coords.y, coords.z, true, false, true);end endreturn basemodule

Still getting an error

Error in function 'CREATE_OBJECT'. Argument #5 is 'number'; 'boolean' expected.

 

 

Yeah i edited my post and fixed that straight after :lol:

 

Thanks now i have to make a delete script

Link to comment
Share on other sites

Hey,

 

Why are there 'a' 'b' 'c' 'd' on the left hand corner of the game? Is there a way to remove it? It really goes in the way of the Native Trainer.

Link to comment
Share on other sites

Hey,

 

Why are there 'a' 'b' 'c' 'd' on the left hand corner of the game? Is there a way to remove it? It really goes in the way of the Native Trainer.

because of the testgui which is a example how to write guis just delete it if you dont need it

Link to comment
Share on other sites

Is at possible at the moment to create a AI driver with the functions currently available?

Link to comment
Share on other sites

Hey guys, this project is progressing really fast... Is there a way to 'reload' a lua script on-the-fly? Even if it had some kind of error? (so you fix the error and re-run the script?)

Link to comment
Share on other sites

Hey guys, this project is progressing really fast... Is there a way to 'reload' a lua script on-the-fly? Even if it had some kind of error? (so you fix the error and re-run the script?)

Make a change, save the lua script. Press F4 ingame.

Link to comment
Share on other sites

 

Hey guys, this project is progressing really fast... Is there a way to 'reload' a lua script on-the-fly? Even if it had some kind of error? (so you fix the error and re-run the script?)

Make a change, save the lua script. Press F4 ingame.

 

Thanks, yeah, i see that in main.lua there's:

	if(get_key_pressed(115)) then		loadLibs()		loadAddIns()	end

where 115 happens to be f4 of course, but I couldn't find the code to 'unload' the stuff. Unless that's not needed.

Link to comment
Share on other sites

Anyone

 

 

 

 

 

 

Im trying to make a prop spawning script but console keeps saying

tick: scripts/addins.propspawner.lua:16: attempt to call global 'CREATE_OBJECT' (a nil value)

heres my code

local propspawn ={}function propspawn.tick()local propID = GAMEPLAY.GET_HASH_KEY("petrol_pump")		local playerPed = PLAYER.PLAYER_PED_ID()		local player = PLAYER.GET_PLAYER_PED(playerPed)		local playerID = PLAYER.PLAYER_ID()		local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)		local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)		local playerGroup = PED.GET_PED_GROUP_INDEX(playerPed)	local player = PLAYER.GET_PLAYER_PED(playerPed)	local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)	if(playerExists) then	if(get_key_pressed(40)) then	CREATE_OBJECT(PETROL_PUMP)	propspawn.unload()		STREAMING.REQUEST_MODEL(propID)		while(not STREAMING.HAS_MODEL_LOADED(propID)) do				wait(50)		end			prop.object[i] = OBJECT.CREATE_OBJECT( 26,propID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)			STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(propID)		end	end	end	return propspawn

 

I made a example this should work

local basemodule = {} function basemodule.unload()endfunction basemodule.init() endfunction basemodule.tick()local player = PLAYER.PLAYER_ID()local playerPed = PLAYER.PLAYER_PED_ID()local coords = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)if(get_key_pressed(114)) then OBJECT.CREATE_OBJECT(GAMEPLAY.GET_HASH_KEY("prop_windmill_01"), coords.x, coords.y, coords.z, true, false, true);end endreturn basemodule

Still getting an error

Error in function 'CREATE_OBJECT'. Argument #5 is 'number'; 'boolean' expected.

 

 

Yeah i edited my post and fixed that straight after :lol:

 

Thanks now i have to make a delete script

 

is there a bong or pipe entity lol, i want to be able to hit a bong or joint where ever i go

Link to comment
Share on other sites

 

 

Hey guys, this project is progressing really fast... Is there a way to 'reload' a lua script on-the-fly? Even if it had some kind of error? (so you fix the error and re-run the script?)

Make a change, save the lua script. Press F4 ingame.

 

Thanks, yeah, i see that in main.lua there's:

	if(get_key_pressed(115)) then		loadLibs()		loadAddIns()	end

where 115 happens to be f4 of course, but I couldn't find the code to 'unload' the stuff. Unless that's not needed.

 

I'm pretty sure it does that for you.

Link to comment
Share on other sites

 

 

 

Hey guys, this project is progressing really fast... Is there a way to 'reload' a lua script on-the-fly? Even if it had some kind of error? (so you fix the error and re-run the script?)

Make a change, save the lua script. Press F4 ingame.

 

Thanks, yeah, i see that in main.lua there's:

	if(get_key_pressed(115)) then		loadLibs()		loadAddIns()	end

where 115 happens to be f4 of course, but I couldn't find the code to 'unload' the stuff. Unless that's not needed.

 

I'm pretty sure it does that for you.

 

Yeah, thanks. I was stupid... the functions they check and unload the stuff when needed, sorry.

Edited by Szabo
Link to comment
Share on other sites

Hey guys, I'm looking into using GET_PED_NEARBY_PEDS, which takes the PED to search from, an array out and a radius I guess (-1 being no limit).

 

My only problem is that I don't know how to properly pass the output array that the function expects - I tried just passing a table and that didn't work.

 

Here's another thread where the usage is shown: http://gtaforums.com/topic/789788-function-args-to-pedget-ped-nearby-peds/

 

Any help is greatly appreciated!

Link to comment
Share on other sites

So I've been trying to get this to work!

if(get_key_pressed(114)) then		wait(100)		local playerPed = PLAYER.PLAYER_PED_ID()		local tester = PLAYER.PLAYER_ID()		local player = PLAYER.GET_PLAYER_PED(playerPed)		local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)		local zombieskinID = GAMEPLAY.GET_HASH_KEY("s_m_y_swat_01")		STREAMING.REQUEST_MODEL(zombieskinID)		PLAYER.SET_PLAYER_MODEL(tester, zombieskinID)		PED.SET_PED_DEFAULT_COMPONENT_VARIATION(playerPed);		-print("Test!")end

The line PED.SET_PED_DEFAULT_COMPONENT_VARIATION(playerPed); seems to crash it but Im not 100% sure

Edited by Swarm96
Link to comment
Share on other sites

Hello there, I just released my first script: http://gtaforums.com/topic/790030-vrelhookluaalpha-szabos-persistance-mod-scripthook-lua/

 

Now I need to know if it's possible to somehow serialize all data of a vehicle so I can store it (like, color, mods, etc) on a file in order to re-spawn it on the next launch. Any ideas?

 

Also, any ideas on how I can get the 'owner' of the vehicle? Or at least a way to know if the vehicle was bought by the player?

EDIT: I don't think it's possible.... i'm gonna use VEHICLE::IS_VEHICLE_STOLEN in the meantime... I don't know when a vehicle is considered 'stolen' by the engine though

 

Thanks in advance.

Edited by Szabo
Link to comment
Share on other sites

ikilluwitastick

First of all, this is amazing. Love it, love everything about it. Created an account just to post on here.

One thing I've noticed though: the bodyguards...don't make very good bodyguards. Hahaha if any of them accidentally shoots the other one, all hell breaks loose and they all start shooting each other AND me. Any ideas how to fix this? I tried adding a call to PED.SET_CAN_ATTACK_FRIENDLY, but I must have done something wrong or that must not be the right thing because it didn't make any difference.

Link to comment
Share on other sites

First of all, this is amazing. Love it, love everything about it. Created an account just to post on here.

One thing I've noticed though: the bodyguards...don't make very good bodyguards. Hahaha if any of them accidentally shoots the other one, all hell breaks loose and they all start shooting each other AND me. Any ideas how to fix this? I tried adding a call to PED.SET_CAN_ATTACK_FRIENDLY, but I must have done something wrong or that must not be the right thing because it didn't make any difference.

I don't know, but it's a heck of a lot of fun to watch 20-50 peds shoot it out in the street. :)

Link to comment
Share on other sites

I'm looking for a little help on this.

What i'm trying to create is a script to increase/decrease the amount of dirt on a vehicle rather than what i have now where its either fully dirty or clean.

I tried using GET_VEHICLE_DIRT_LEVEL then adding/subtracting from that value but i dont think i did it correctly since it didn't work or show a error.

I have basically no knowledge of LUA so any help on this would be appreciated.

local dirtyvehicle = {}function dirtyvehicle.unload()endfunction dirtyvehicle.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(109)) then            VEHICLE.SET_VEHICLE_DIRT_LEVEL(veh, 0.0) -- clean            elseif(get_key_pressed(107)) then            VEHICLE.SET_VEHICLE_DIRT_LEVEL(veh, 15) -- 15 = maximum dirt            end        end    endendreturn dirtyvehicle
Edited by StephenSCO
Link to comment
Share on other sites

override367

I've noticed npcs in the players group will only act like a group if there's 5 or less of them

 

anyway I'm having some trouble with a script to spawn 3 distinct NPCs

 

for some reason the second elseif statement never works, is it not possible to do 2 elseif statements? There's probably a better way to do this anyway

 

for i = 0 ,family.howMany,1 doif(modelselector == 1) thenfamily.peds[i] = PED.CREATE_PED( 1,familySkinID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)modelselector = modelselector + 1elseif(modelselector == 2) thenfamily.peds[i] = PED.CREATE_PED( 1,familySkinID2,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)modelselector = modelselector + 1elseif (modelselector == 3) thenfamily.peds[i] = PED.CREATE_PED( 1,familySkinID3,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)modelselector = 1endPED.SET_PED_CAN_SWITCH_WEAPON(family.peds[i],true)WEAPON.GIVE_DELAYED_WEAPON_TO_PED(family.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_SAWNOFFSHOTGUN"), 1000, false)PED.SET_PED_AS_GROUP_MEMBER(family.peds[i], playerGroup) end

 

Also does anyone know how to make NPCs a bit tought? The ones I spawn tend to get immediately gunned down, I've tried the following at the end of an otherwise working bodyguard creation script

 

I've tried things like

PED.SET_PED_MAX_HEALTH(family.peds, 10000)
to no avail
Edited by override367
Link to comment
Share on other sites

Maybe try these?

PED.ADD_ARMOUR_TO_PED(Ped PedHandle, int Amount)
PED.SET_PED_ARMOUR(Any p0, Any p1)

PED.GET_PED_ARMOUR(Ped PedHandle)

Link to comment
Share on other sites

 

 

 

I've noticed npcs in the players group will only act like a group if there's 5 or less of them

 

anyway I'm having some trouble with a script to spawn 3 distinct NPCs

 

for some reason the second elseif statement never works, is it not possible to do 2 elseif statements? There's probably a better way to do this anyway

for i = 0 ,family.howMany,1 doif(modelselector == 1) thenfamily.peds[i] = PED.CREATE_PED( 1,familySkinID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)modelselector = modelselector + 1elseif(modelselector == 2) thenfamily.peds[i] = PED.CREATE_PED( 1,familySkinID2,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)modelselector = modelselector + 1elseif (modelselector == 3) thenfamily.peds[i] = PED.CREATE_PED( 1,familySkinID3,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)modelselector = 1endPED.SET_PED_CAN_SWITCH_WEAPON(family.peds[i],true)WEAPON.GIVE_DELAYED_WEAPON_TO_PED(family.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_SAWNOFFSHOTGUN"), 1000, false)PED.SET_PED_AS_GROUP_MEMBER(family.peds[i], playerGroup) end

Also does anyone know how to make NPCs a bit tought? The ones I spawn tend to get immediately gunned down, I've tried the following at the end of an otherwise working bodyguard creation script

 

I've tried things like

PED.SET_PED_MAX_HEALTH(family.peds, 10000)
to no avail

 

elseif is only getting called when the if before is not true

 

you got two options now

1. write it differently that you dont use if/elseif (like iterating through a table)

2. convert your elseif to if then end's

 

 

I'm looking for a little help on this.

What i'm trying to create is a script to increase/decrease the amount of dirt on a vehicle rather than what i have now where its either fully dirty or clean.

I tried using GET_VEHICLE_DIRT_LEVEL then adding/subtracting from that value but i dont think i did it correctly since it didn't work or show a error.

I have basically no knowledge of LUA so any help on this would be appreciated.

local dirtyvehicle = {}

function dirtyvehicle.unload()

end

 

function dirtyvehicle.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(109)) then

VEHICLE.SET_VEHICLE_DIRT_LEVEL(veh, 0.0) -- clean

elseif(get_key_pressed(107)) then

VEHICLE.SET_VEHICLE_DIRT_LEVEL(veh, 15) -- 15 = maximum dirt

end

end

end

 

end

return dirtyvehicle

 

 

show me your add/subtract script and u probably have to add a delay between two userinputs else each set dirt level is getting 100 times called per second

Edited by headscript
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.