Advertisement
Ji9sw

Bodyguard Example

Oct 28th, 2023
678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.78 KB | None | 0 0
  1.     if (GUI::Option("Spawn Bodyguard", ""))
  2.     {
  3.         int clone[1000];
  4.         int gcount = 1;
  5.         Ped SelectedPlayer = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(Features::SelectedPlayer); // The player to spawn it for
  6.         if (!ENTITY::DOES_ENTITY_EXIST(SelectedPlayer)) return; // Making sure the player exists
  7.         Hash railgun = MISC::GET_HASH_KEY("WEAPON_RAILGUN"); // The bodyguards weapon
  8.         Vector3 pos = ENTITY::GET_ENTITY_COORDS(SelectedPlayer, false); // Players position to spawn it on
  9.         Hash pedm = MISC::GET_HASH_KEY("u_m_m_jesus_01"); // The bodyguards ped
  10.         STREAMING::REQUEST_MODEL(pedm); // Request the ped
  11.         while (!STREAMING::HAS_MODEL_LOADED(pedm)) { fibermain::pause(); } // Wait for the ped to load
  12.         int my_group = PLAYER::GET_PLAYER_GROUP(SelectedPlayer); // Create a group for the bodyguards
  13.         clone[gcount] = PED::CREATE_PED(26, pedm, pos.x + rand() % 1, pos.y + rand() % 1, pos.z + 1, 0, 1, 1); // Create the ped
  14.         PED::SET_PED_AS_GROUP_LEADER(SelectedPlayer, my_group); // Set ped as group leader
  15.         PED::SET_PED_AS_GROUP_MEMBER(clone[gcount], my_group); // Add it as a member
  16.         PED::SET_PED_NEVER_LEAVES_GROUP(clone[gcount], my_group); // Make it so it cant leave
  17.         ENTITY::SET_ENTITY_INVINCIBLE(clone[gcount], false); // Godmode?
  18.         PED::SET_PED_COMBAT_ABILITY(clone[gcount], 100); // How good are they at shooting?
  19.         WEAPON::GIVE_WEAPON_TO_PED(clone[gcount], railgun, railgun, 9999, 9999); // Give them the gun you selected
  20.         PED::SET_PED_CAN_SWITCH_WEAPON(clone[gcount], true); // Can they switch to a sidearm?
  21.         PED::SET_GROUP_FORMATION(my_group, 3); // Set the entire groups formation, you can change this anytime if you save my_group as a variable elsewhere
  22.         PED::SET_PED_MAX_HEALTH(clone[gcount], 5000); // Set peds health (Not sure why, if its godmode, unless you disable godmode)
  23.         gcount++;
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement