XADRENALINEIX

K3R3DOR'S Ped Follower Mod

May 18th, 2013
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.42 KB | None | 0 0
  1. //Main.c
  2.  #include <natives.h>
  3. #include <common.h>
  4. #include <strings.h>
  5. #include <types.h>
  6. #include <consts.h>
  7. #include "settings.c"
  8. #include "functions.c"
  9. float line1=0.76000000;
  10. float line2=0.79000000;
  11. float line3=0.82000000;
  12. float line4=0.85000000;
  13. float x1, y1, z1;
  14. Ped carped, footped, delped;
  15. Vehicle pedcar, mycar;
  16. Object lights;
  17. int carmake, myspeed, pednet, object1, menuon = 0;
  18. bool Exist=0, weapswap=0 , curweap=0;
  19. Group mygroup;
  20. void Display(float LinePosition, char *Title) // For Displaying
  21. {
  22. set_up_draw(6, 0.40000000, 0.30000000, 242, 30, 242, 255 ); //Pink
  23. draw_text("STRING", 0.50, LinePosition, Title);
  24. }
  25. void neons(void)
  26. {
  27.     REQUEST_MODEL(0xD20167BE);
  28.            while (!HAS_MODEL_LOADED(0xD20167BE)) WAIT(0);
  29.                 CREATE_OBJECT(0xD20167BE, 0.0f, 0.0f, 0.0f, &lights, 1);
  30. WAIT(1);
  31. ATTACH_OBJECT_TO_CAR(lights,carmake,0.0f,0.0,0,0,-80,0,0.0);
  32. SET_OBJECT_LIGHTS(lights, true);
  33. SET_OBJECT_VISIBLE(lights, true);
  34. SET_OBJECT_INVINCIBLE(lights, 1);
  35. CREATE_OBJECT(0xD20167BE, 0.0f, 0.0f, 0.0f, &lights, 1);
  36.             WAIT(1);
  37. ATTACH_OBJECT_TO_CAR(lights,carmake,0.0f,0.0,0,0,-80,0,0.0);
  38. SET_OBJECT_LIGHTS(lights, true);
  39. SET_OBJECT_VISIBLE(lights, true);
  40. SET_OBJECT_INVINCIBLE(lights, 1);
  41. CREATE_OBJECT(0xD20167BE, 0.0f, 0.0f, 0.0f, &lights, 1);
  42.             WAIT(1);
  43. ATTACH_OBJECT_TO_CAR(lights,carmake,0.0f,0.0,0,0,-80,0,0.0);
  44. SET_OBJECT_LIGHTS(lights, true);
  45. SET_OBJECT_VISIBLE(lights, true);
  46. SET_OBJECT_INVINCIBLE(lights, 1);
  47. CREATE_OBJECT(0xD20167BE, 0.0f, 0.0f, 0.0f, &lights, 1);
  48.             WAIT(1);
  49. ATTACH_OBJECT_TO_CAR(lights,carmake,0.0f,0.0,0,0,-80,0,0.0);
  50. SET_OBJECT_VISIBLE(lights, true);
  51. SET_OBJECT_INVINCIBLE(lights, 1);
  52. SET_OBJECT_VISIBLE(lights, true);
  53. CREATE_OBJECT(0xD20167BE, 0.0f, 0.0f, 0.0f, &lights, 1);
  54.             WAIT(1);
  55. ATTACH_OBJECT_TO_CAR(lights,carmake,0.0f,0.0,0,0,-80,0,0.0);
  56. SET_OBJECT_VISIBLE(lights, true);
  57. SET_OBJECT_INVINCIBLE(lights, 1);
  58. SET_OBJECT_VISIBLE(lights, true);
  59. }
  60. void findme(void)
  61.     {
  62.     GET_CHAR_COORDINATES(GetPlayerPed(), &x1, &y1, &z1);
  63.     GET_CAR_CHAR_IS_USING(GetPlayerPed(), &mycar);
  64.     GET_CAR_MODEL(mycar, &carmake);
  65.     }
  66. void CreateGroup(void)
  67. {
  68. if(Exist==0)
  69. {
  70. GET_PLAYER_GROUP(GetPlayerIndex(), &mygroup);
  71. if(!DOES_GROUP_EXIST(mygroup))
  72. {
  73. CREATE_GROUP(0, mygroup, true);
  74. SET_GROUP_LEADER(mygroup, GetPlayerPed());
  75. SET_GROUP_SEPARATION_RANGE(mygroup, 9999.9);
  76.         SET_PLAYER_GROUP_TO_FOLLOW_ALWAYS(GetPlayerPed(),1);
  77.         SET_GROUP_FOLLOW_STATUS(mygroup,1);
  78.         SET_GROUP_FORMATION(mygroup,3);
  79.         SET_GROUP_FORMATION_SPACING(mygroup, 5);
  80. Exist=1;
  81. }
  82. }
  83. }
  84. void carprefs(void)
  85. {
  86.     //LOCK_CAR_DOORS(carmake,4);
  87.     SET_CAR_ENGINE_ON(carmake, true, false);
  88.     SET_CAR_CAN_BE_DAMAGED(carmake, false);
  89.     SET_CAR_CAN_BE_VISIBLY_DAMAGED(carmake, false);
  90.     SET_CAN_BURST_CAR_TYRES(carmake, false);
  91.     SET_CAR_ALWAYS_CREATE_SKIDS(carmake, true);
  92.     SET_CAR_STAY_IN_SLOW_LANE(carmake, false);
  93.     neons();
  94. }
  95. void pedprefs(void)
  96. {
  97.     SET_GROUP_MEMBER(mygroup, carped);
  98.     SET_GROUP_CHAR_DUCKS_WHEN_AIMED_AT(carped, false);
  99. SET_CHAR_NEVER_LEAVES_GROUP(carped, true);
  100. SET_CHAR_ACCURACY(carped, 100);
  101. SET_CHAR_CAN_BE_SHOT_IN_VEHICLE(carped, false);
  102. SET_CHAR_WILL_DO_DRIVEBYS(carped, true);
  103. SET_CHAR_WILL_MOVE_WHEN_INJURED(carped, true);
  104. SET_CHAR_WILL_USE_COVER(carped, false);
  105.     SET_CHAR_BULLETPROOF_VEST(carped, true);
  106. SET_CHAR_PROVIDE_COVERING_FIRE(carped, true);
  107. SET_CHAR_WILL_USE_CARS_IN_COMBAT(carped, true);
  108. SET_CHAR_WILL_LEAVE_CAR_IN_COMBAT(carped, false);
  109. SET_PED_DONT_DO_EVASIVE_DIVES(carped, true);
  110. UpdateWeaponOfPed(carped, WEAPON_M4);
  111. SET_PED_DIES_WHEN_INJURED(carped, false);
  112. SET_PED_IS_BLIND_RAGING(carped, true);
  113. SET_CHAR_RELATIONSHIP_GROUP(carped, RELATIONSHIP_GROUP_PLAYER);
  114. SET_CHAR_RELATIONSHIP(carped, RELATIONSHIP_RESPECT, RELATIONSHIP_GROUP_PLAYER);
  115. SET_CHAR_MOVE_ANIM_SPEED_MULTIPLIER(carped, 15);
  116. SET_CHAR_CANT_BE_DRAGGED_OUT(carped, true);
  117. SET_CHAR_WILL_FLY_THROUGH_WINDSCREEN(carped, false);
  118. SET_PED_PATH_MAY_USE_CLIMBOVERS(carped, true);
  119. SET_PED_PATH_MAY_USE_LADDERS(carped, true);
  120. SET_PED_PATH_MAY_DROP_FROM_HEIGHT(carped, true);
  121. SET_PED_DIES_WHEN_INJURED(carped, false);
  122. SET_CHAR_CAN_SMASH_GLASS(carped, true);
  123. GIVE_PED_HELMET(carped);
  124. }
  125. void createpeds(void)
  126.     {
  127.     findme();
  128.     CreateGroup();
  129.         REQUEST_MODEL(carmake);
  130.         while (!HAS_MODEL_LOADED(carmake)) WAIT(0);
  131.         CREATE_CAR(carmake, x1+10.0f, y1+15.0f, z1, &carmake, 1);
  132.            REQUEST_MODEL(MODEL_M_M_FATCOP_01);
  133.            while (!HAS_MODEL_LOADED(MODEL_M_M_FATCOP_01)) WAIT(0);
  134.            CREATE_CHAR_INSIDE_CAR(carmake, 16, MODEL_M_M_FATCOP_01, &carped);
  135.         carprefs();
  136.         pedprefs();
  137.         TASK_CAR_MISSION(carped, carmake, mycar, 2, 160, 2, 15, 10);
  138.     SET_CHAR_WILL_LEAVE_CAR_IN_COMBAT(carped, false);
  139.     SET_CHAR_CAN_BE_SHOT_IN_VEHICLE(carped, false);
  140.         SET_CHAR_KEEP_TASK(carped, true);
  141.         UpdateWeaponOfPed(carped, WEAPON_MP5);
  142.            MARK_MODEL_AS_NO_LONGER_NEEDED(carmake);
  143.            MARK_MODEL_AS_NO_LONGER_NEEDED(carped);
  144.         {
  145.             print("New member IN A CAR added to your gang");
  146.         }
  147.     }
  148. void footpeds(void)
  149. {
  150.     GET_CHAR_COORDINATES(GetPlayerPed(), &x1, &y1, &z1);
  151.     CreateGroup();
  152.        REQUEST_MODEL(MODEL_IG_BRUCIE);
  153.        while (!HAS_MODEL_LOADED(MODEL_IG_BRUCIE)) WAIT(0);
  154.        CREATE_CHAR(16, MODEL_IG_BRUCIE, x1, y1+4.0f, z1, &carped, true);
  155.     pedprefs();
  156.     SET_CHAR_INVINCIBLE(carped, 1);
  157.     UpdateWeaponOfPed(carped, WEAPON_M4);
  158.     MARK_MODEL_AS_NO_LONGER_NEEDED(carped);
  159.     {
  160.         print("New member ON FOOT added to your gang");
  161.     }
  162. }
  163. void pedspawner(void)
  164. {
  165.   if (menuon==1);
  166.          {
  167. Display(line1,"UP - Change ped weapon");
  168. Display(line2,"DOWN - Hippo bodyguards");
  169. Display(line3,"LEFT - Spawn peds on foot");
  170. Display(line4,"RIGHT - Spawn peds in cars");
  171. }
  172.  if(IS_BUTTON_JUST_PRESSED(0, DPAD_RIGHT))
  173.        {
  174.         if (IS_CHAR_IN_ANY_CAR(GetPlayerPed()))
  175.              {
  176.                createpeds();
  177.              }
  178.        else
  179.              {
  180.                print("You need to be in a vehicle");
  181.              }
  182.        }
  183.  if(IS_BUTTON_JUST_PRESSED(0, DPAD_LEFT))
  184.        {
  185.          if (IS_CHAR_IN_ANY_CAR(GetPlayerPed()))
  186.              {
  187.                print("You need to be on foot");
  188.              }
  189.        else
  190.              {
  191.                  footpeds();
  192.              }
  193.        }
  194.  if(IS_BUTTON_JUST_PRESSED(0, DPAD_DOWN))
  195.     {
  196.       if(DOES_CHAR_EXIST(carped))
  197.       {
  198.           DELETE_CHAR(&carped);
  199.           DELETE_CAR(&carmake);
  200.           print("Peds have been deleted");
  201.       }
  202.       else
  203.            {
  204.                uint pednet;
  205.            GET_CHAR_COORDINATES(GetPlayerPed(), &x1, &y1, &z1);
  206.            GET_CLOSEST_CHAR(x1, y1, z1, 300, 0, 70, &delped);
  207.            if(DOES_CHAR_EXIST(delped))
  208.               {
  209.                GET_NETWORK_ID_FROM_PED(delped,&pednet);
  210.                while(!REQUEST_CONTROL_OF_NETWORK_ID(pednet))
  211.                {
  212.                    WAIT(0);
  213.                    DELETE_CHAR(&delped);
  214.                }
  215.               }
  216.            }
  217.     }
  218.  if((IS_BUTTON_JUST_PRESSED(0,DPAD_UP))  &&  (DOES_CHAR_EXIST(carped)))
  219. {
  220. if(weapswap==3)
  221.   {
  222. weapswap=0;
  223. curweap=0;
  224.            }
  225. else
  226.    {
  227. weapswap++;
  228. curweap=0;
  229.    }
  230. if((weapswap==0) && (curweap==0))
  231.    {
  232. UpdateWeaponOfPed(carped, WEAPON_MOLOTOV);
  233. weapswap=1;
  234. curweap=1;
  235. print("Peds now have molotovs");
  236.    }
  237. else if((weapswap==1) && (curweap==0))
  238.    {
  239. UpdateWeaponOfPed(carped, WEAPON_ROCKET);
  240. weapswap=2;
  241. curweap=1;
  242. print("Peds now have rockets");
  243.    }
  244. else if((weapswap==2) && (curweap==0))
  245.    {
  246. UpdateWeaponOfPed(carped, WEAPON_GRENADE);
  247. weapswap=3;
  248. curweap=1;
  249. print("Peds now have grenades");
  250.    }
  251.         }
  252. }
  253. void menutoggle(void)
  254. {
  255.      if((IS_BUTTON_PRESSED(0,STICK_R))  &&  (menuon == 0))
  256.         {
  257.                 menuon = 1;
  258.                 pedspawner();
  259.              }
  260. else if((IS_BUTTON_PRESSED(0,STICK_R))  &&  (menuon == 1))
  261.              {
  262.                 menuon = 0;
  263.              }
  264. }
  265. void main(void)
  266. {
  267. THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME();
  268. while (TRUE)
  269. {
  270. WAIT(0);
  271. menutoggle();
  272. }
  273. }
  274. //Functions.c
  275.    void draw_title(float x, float y, float width, float height, uint r, uint g, uint b, uint a, char *val)
  276. {
  277. #ifdef PC
  278. if (!IS_FONT_LOADED(7))
  279. {
  280. LOAD_TEXT_FONT(7);
  281. }
  282. SET_TEXT_FONT(7);
  283. #else
  284. if (!IS_FONT_LOADED(6))
  285. {
  286. LOAD_TEXT_FONT(6);
  287. }
  288. SET_TEXT_FONT(6);
  289. #endif
  290. SET_TEXT_BACKGROUND(0);
  291. SET_TEXT_DROPSHADOW(0, 0, 0, 0, 255);
  292. SET_TEXT_EDGE(1, 0, 0, 0, 255);
  293. SET_TEXT_PROPORTIONAL(1);
  294. SET_TEXT_WRAP(0.0000, 1.0000);
  295. SET_TEXT_COLOUR(r, g, b, a);
  296. SET_TEXT_SCALE(width, height);
  297. SET_TEXT_JUSTIFY(0);
  298. SET_TEXT_CENTRE(1);
  299. SET_TEXT_RIGHT_JUSTIFY(0);
  300. DISPLAY_TEXT_WITH_LITERAL_STRING(x, y, "STRING", val);
  301. }
  302. void set_up_draw(int type, float width, float height, uint r, uint g, uint b, uint a)
  303. {
  304. SET_TEXT_FONT(0);
  305. SET_TEXT_BACKGROUND(0);
  306. SET_TEXT_DROPSHADOW(0, 0, 0, 0, 255);
  307. SET_TEXT_EDGE(1, 0, 0, 0, 255);
  308. if (type == 1)
  309. {
  310. SET_TEXT_BACKGROUND(1);
  311. }
  312. else if (type == 2)
  313. {
  314. SET_TEXT_DROPSHADOW(1, 0, 0, 0, 255);
  315. }
  316. else if (type == 3)
  317. {
  318. SET_TEXT_EDGE(1, 0, 0, 0, 255);
  319. }
  320. SET_TEXT_COLOUR(r, g, b, a);
  321. SET_TEXT_SCALE(width, height);
  322. SET_TEXT_PROPORTIONAL(1);
  323. SET_TEXT_JUSTIFY(0);
  324. SET_TEXT_CENTRE(0);
  325. SET_TEXT_RIGHT_JUSTIFY(0);
  326. }
  327. float draw_text(char *gxtName, float x, float y, char *val)
  328. {
  329. float result;
  330. result = GET_STRING_WIDTH_WITH_STRING(gxtName, val);
  331. DISPLAY_TEXT_WITH_LITERAL_STRING(x, y, gxtName, val);
  332. return result;
  333. }
  334. void draw_number(char *gxtName, float x, float y, int val)
  335. {
  336. DISPLAY_TEXT_WITH_NUMBER(x, y, gxtName, val);
  337. }
  338. void draw_float(char *gxtName, float x, float y, float val)
  339. {
  340. DISPLAY_TEXT_WITH_FLOAT(x, y, gxtName, val, 4);
  341. }
  342. //Settings.c
  343.      /****************************************************
  344. SCRIPT SETTINGS - Values and data that can be changed to
  345. suit your needs.
  346. *****************************************************/
  347. #define SUPER_SPEED_MULTIPLIER 10.0f
  348. ////#define NUMBER_OF_NETWORK_PLAYERS 16
  349. //#define DEBUG
  350. //############### Define Ps3 GamePad ################################//
  351. #define SELECT  0xD
  352. #define START  0xC
  353. #define SQUARE  0xE
  354. #define TRIANGLE  0xF
  355. #define X  0x10
  356. #define CIRCLE  0x11
  357. #define DPAD_UP  0x8
  358. #define DPAD_DOWN  0x9
  359. #define DPAD_LEFT  0xA
  360. #define DPAD_RIGHT  0xB
  361. #define L2  0x5
  362. #define R2  0x7
  363. #define L1  0x4
  364. #define R1  0x6
  365. #define STICK_L  0x12
  366. #define STICK_R  0x13  
  367. //############### Define Ps3 GamePad ################################//
Advertisement
Add Comment
Please, Sign In to add comment