Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      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. Support

    3. Suggestions

Bodyguards : Secondary weapon + Follow in car


Recommended Posts

Hello world,

I'm new to scripting but however i'm trying to improve bodyguard system as i feel it's lacking some functions as of now.

( firing from vehicle & follow in a vehicle if player vehicle is full )


So here's a code from Ohmymodz (I use this one because I can customize my own groups) :

local Priest = {}Priest.peds = {}Priest.howMany = 0function Priest.unload()	for k,guard in pairs(Priest.peds) do		if( guard ~= nil) then			PED.DELETE_PED(guard)			Priest.peds[k] = nil		end	endendfunction Priest.tick()	if(get_key_pressed(35)) then		local PriestSkinID = GAMEPLAY.GET_HASH_KEY("CS_Priest")		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)		Priest.unload()		STREAMING.REQUEST_MODEL(PriestSkinID)		while(not STREAMING.HAS_MODEL_LOADED(PriestSkinID)) do				wait(50)		end		for i = 0 ,Priest.howMany,1 do			Priest.peds[i] = PED.CREATE_PED( 26,PriestSkinID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)				PED.SET_PED_CAN_SWITCH_WEAPON(Priest.peds[i],false)			WEAPON.GIVE_WEAPON_TO_PED(Priest.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_MARKSMANRIFLE"), 1, false, false)			PED.SET_PED_COMBAT_ABILITY(Priest.peds[i], 2)			PED.SET_PED_AS_GROUP_MEMBER(Priest.peds[i], playerGroup)			ENTITY.SET_ENTITY_INVINCIBLE(Priest.peds[i], true);		end		STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(PriestSkinID)	end	endreturn Priest

Now whenever I get in a car, he comes in but he just gives the finger.

If I add WEAPON.GIVE_WEAPON_TO_PED(Priest.peds, GAMEPLAY.GET_HASH_KEY("WEAPON_PISTOL50"), 1, false, false) he will not have marksman rifle in his hands anymore.

Before or after the other weapon doesn't change anything & GIVE_DELAYED_WEAPON doesn't change anything either.


Is it wise to use this instead ?


local getString = PED.IS_PED_GETTING_INTO_A_VEHICLE(playerPed)

	if (PED.IS_PED_GETTING_INTO_A_VEHICLE(playerPed) ~= nil) then		WEAPON.GIVE_WEAPON_TO_PED(Priest.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_Pistol50"), 1, true, false)			else 				WEAPON.SET_CURRENT_PED_WEAPON(Priest.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_MARKSMANRIFLE"), 1, true)	end

Problem is I'm stuck with number expected or nil errors.



Also, when I have 3 or more bodyguards, I'd like to make the extra bodyguars enter another vehicle to follow.


Maybe with this :







if x == y do

VEHICLE.CREATE_VEHICLE(fbi2, float xCoord, float yCoord, float zCoord, float Heading, BOOL networkHandle, BOOL vehiclehandle)

SET_VEHICLE_CAN_BREAK(Vehicle Vehicle, false)

AI.TASK_VEHICLE_ESCORT(Ped pedHandle, Vehicle vehicle, Vehicle targetVehicle, int p3, float p4, Any p5, float p6, int p7, float p8)





Maybe I'm all wrong, any help on this would be glady appreciated.

Is there an easiest way to troobleshoot your attempts ? Something like loading NY instead of LS to reduce game launching delay ?



Link to comment
Share on other sites

personally I just gave them a rifle, then added another line to give them a pistol, then called the native that allows them to switch weapons and they do it on their own (auto draw pistol when in vehicle)

Link to comment
Share on other sites

I just tried again with your answer and still can't make it to work.


I have 3 members in my group, each is in a separate lua file, I call the 3 guys by tapping "end" 3 times.


1 the Priest :

                for i = 0 ,Priest.howMany,1 do			Priest.peds[i] = PED.CREATE_PED( 26,PriestSkinID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)				PED.SET_PED_CAN_SWITCH_WEAPON(Priest.peds[i],true)			WEAPON.GIVE_WEAPON_TO_PED(Priest.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_MARKSMANRIFLE"), 1, false, false)			WEAPON.GIVE_WEAPON_TO_PED(Priest.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_Pistol50"), 1, false, false)			PED.SET_PED_COMBAT_ABILITY(Priest.peds[i], 2)			PED.SET_PED_AS_GROUP_MEMBER(Priest.peds[i], playerGroup)			ENTITY.SET_ENTITY_INVINCIBLE(Priest.peds[i], true);		end

2 Jesus :

		for i = 0 ,Jesus.howMany,1 do			Jesus.peds[i] = PED.CREATE_PED( 26,JesusSkinID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)				PED.SET_PED_CAN_SWITCH_WEAPON(Jesus.peds[i],true)			WEAPON.GIVE_WEAPON_TO_PED(Jesus.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_MINIGUN"), 1, false, false)			WEAPON.GIVE_WEAPON_TO_PED(Jesus.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_Pistol50"), 1, false, false)			PED.SET_PED_COMBAT_ABILITY(Jesus.peds[i], 2)			PED.SET_PED_AS_GROUP_MEMBER(Jesus.peds[i], playerGroup)			ENTITY.SET_ENTITY_INVINCIBLE(Jesus.peds[i], true);		end

3 The jew :

		for i = 0 ,Jew.howMany,1 do			Jew.peds[i] = PED.CREATE_PED( 26,JewSkinID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)				PED.SET_PED_CAN_SWITCH_WEAPON(Jew.peds[i],true)			WEAPON.GIVE_WEAPON_TO_PED(Jew.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_COMBATMG"), 1, false, false)			WEAPON.GIVE_WEAPON_TO_PED(Jew.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_Pistol50"), 1, false, false)			PED.SET_PED_COMBAT_ABILITY(Jew.peds[i], 2)			PED.SET_PED_AS_GROUP_MEMBER(Jew.peds[i], playerGroup)			ENTITY.SET_ENTITY_INVINCIBLE(Jew.peds[i], true);		end

What always happens whatever I try is that the jew is the only one who brings out the machine gun, Jesus and the Priest keeps the pistol. While the code is the same, what is wrong then ?

Link to comment
Share on other sites

spawn them when your character is unarmed, when you pull out ANY gun they'll equip rifles.

if they're not in combat and have switched to their pistols for some strange reason you can go back to unarmed then re-equip your weapon and they pull out their rifles again.

ALSO, that first value after you call a weapon is the ammo, setting it to 1 will give them 1 bullet or 1 clip I think :p

	                        int groupId = PLAYER::GET_PLAYER_GROUP(PLAYER::GET_PLAYER_INDEX());				Ped pedHandle = PED::CLONE_PED(PLAYER::PLAYER_PED_ID(), -852.4f, 160.0f, 65.6f);				PED::SET_PED_AS_GROUP_MEMBER(pedHandle, groupId);				WEAPON::GIVE_WEAPON_TO_PED(pedHandle, 0xBFEFFF6D, 120, 1, 1);				WEAPON::GIVE_WEAPON_TO_PED(pedHandle, 0x1B06D571, 120, 1, 1);				PED::SET_PED_COMBAT_RANGE(pedHandle, 500);				PED::SET_PED_ALERTNESS(pedHandle, 100);				PED::SET_PED_ACCURACY(pedHandle, 100);				PED::SET_PED_CAN_SWITCH_WEAPON(pedHandle, 1);				PED::SET_PED_SHOOT_RATE(pedHandle, 200);				PED::SET_PED_GENERATES_DEAD_BODY_EVENTS(pedHandle, 1);				set_status_text("Assault Crew Spawned.");

this is the code I use to spawn my assault guys that use rifles and pistols and they seem to change between them very well, i've noticed if i'm holding a weapon when I spawn them you'll spawn with a pistol for some reason O.o

the alertness, combat range and accuracy things i'm just playing around with so ignore them they're not necessary :p

edit: nvm i figured out vectors i'm an idiot

Edited by kamaitachi
Link to comment
Share on other sites

Absolutely, if we believe what's written here : GIVE_WEAPON_TO_PED(int pedHandle, int weaponAssetHash, int ammoCount, BOOL equipNow, int p4)

BUT ingame, they shoot like maniacs infinite bullets whatever this value is...


I tried spawning them unnarmed / gun / rifle / RL in hand, with / without hatred around, but nothing changes.

As i mentioned in first post, Give_delayed_weapon don't give much result either.

I tried to put more ammo on machine guns to see if AI gives priority to ammocount... nope.

I tried to put a different key_pressed per bodyguard, nope.

I tried with the LUA_SDK.asi + updated hook, nope.

I tried with hex values, like yours, I also tried to put a less damaging gun to see if AI gives priority to weapon damage, I tried to force equip now machine guns with true boolean, nope, nope & nope.

Only one of'em is handling a machine gun and it's always the same guy.


If you wish to give it a try : https://mega.co.nz/#!nNcUkR5b!jLG9Z61_HgYin0Y_jqOfTNhjSp0tCyczwh7aw8y8dxI



edit : just noticed GTA IV had a FollowDriver param in its native trainer


Anyone else has a clue about bodyguard secondary weapon & follow driver task ?

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