Guest User

Untitled

a guest
Feb 22nd, 2018
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.91 KB | None | 0 0
  1. /*
  2.  
  3. About: FCNPC Bodyguard System
  4. Author: ziggi
  5.  
  6. */
  7.  
  8. #define FILTERSCRIPT
  9.  
  10. #include <a_samp>
  11.  
  12. #if !defined _FCNPC_included
  13. #tryinclude <FCNPC>
  14. #endif
  15.  
  16. #if !defined _FCNPC_included
  17. #tryinclude "FCNPC"
  18. #endif
  19.  
  20. #if !defined _FCNPC_included
  21. #tryinclude "../FCNPC"
  22. #endif
  23.  
  24. #if !defined _FCNPC_included
  25. #error Add FCNPC.inc to your scripts directory
  26. #endif
  27.  
  28. /*
  29. Defines
  30. */
  31.  
  32. #define MAX_BODYGUARDS 6
  33. #define DEBUG
  34.  
  35. #define MAX_BODYPART_NAME 10
  36. #define BG_INVALID_SLOT_ID -1
  37.  
  38. /*
  39. Vars
  40. */
  41.  
  42. static
  43. gPlayerNpc[MAX_PLAYERS][MAX_BODYGUARDS],
  44. gNpcSlot[MAX_PLAYERS],
  45. gNpcPlayer[MAX_PLAYERS],
  46. gFollowTimer[MAX_PLAYERS],
  47. gFollowTarget[MAX_PLAYERS],
  48. PlayerText3D:gNpcText3D[MAX_PLAYERS];
  49.  
  50. /*
  51. Publics
  52. */
  53.  
  54. public OnFilterScriptInit()
  55. {
  56. for (new playerid; playerid < MAX_PLAYERS; playerid++) {
  57. for (new slot; slot < MAX_BODYGUARDS; slot++) {
  58. gPlayerNpc[playerid][slot] = INVALID_PLAYER_ID;
  59. }
  60.  
  61. gNpcSlot[playerid] = BG_INVALID_SLOT_ID;
  62. gNpcPlayer[playerid] = INVALID_PLAYER_ID;
  63. gFollowTimer[playerid] = 0;
  64. gFollowTarget[playerid] = INVALID_PLAYER_ID;
  65. }
  66.  
  67. printf("\n-------------------------------");
  68. printf(" FCNPC Bodyguard System");
  69. printf(" Author: ziggi");
  70. printf("-------------------------------\n");
  71. return 1;
  72. }
  73.  
  74. public OnFilterScriptExit()
  75. {
  76. for (new playerid; playerid < MAX_PLAYERS; playerid++) {
  77. if (BG_IsValid(playerid)) {
  78. BG_DeleteByID(playerid);
  79. }
  80. }
  81. }
  82.  
  83. public OnPlayerDisconnect(playerid, reason)
  84. {
  85. if (!BG_IsValid(playerid)) {
  86. for (new slot; slot < MAX_BODYGUARDS; slot++) {
  87. if (BG_IsValidSlot(playerid, slot)) {
  88. BG_Delete(playerid, slot);
  89. }
  90. }
  91. }
  92. return 1;
  93. }
  94.  
  95. public FCNPC_OnReachDestination(npcid)
  96. {
  97. BG_SetFollowTimer(npcid);
  98. }
  99.  
  100. public FCNPC_OnTakeDamage(npcid, damagerid, weaponid, bodypart, Float:health_loss)
  101. {
  102. if (!IsPlayerConnected(damagerid) || !BG_IsValid(npcid)) {
  103. return 1;
  104. }
  105.  
  106. #if defined DEBUG
  107. new
  108. string[44 + 3 + MAX_PLAYER_NAME + 3 + 2 + MAX_BODYPART_NAME + 16],
  109. player_name[MAX_PLAYER_NAME + 1],
  110. bodypart_name[MAX_BODYPART_NAME],
  111. weapon_name[16];
  112.  
  113. GetPlayerName(damagerid, player_name, sizeof(player_name));
  114. GetBodypartName(bodypart, bodypart_name);
  115. GetWeaponName(weaponid, weapon_name, sizeof(weapon_name));
  116.  
  117. format(string, sizeof(string),
  118. "NPC(%d) was damaged by %s(%d) with %s(%d) in the %s (hp: %f)",
  119. npcid, player_name, damagerid, weapon_name, weaponid, bodypart_name, health_loss);
  120. SendClientMessageToAll(0xFF0000FF, string);
  121. #endif
  122. return 1;
  123. }
  124.  
  125. public FCNPC_OnVehicleEntryComplete(npcid, vehicleid, seat)
  126. {
  127. #if defined DEBUG
  128. new string[27 + 3 + 1];
  129. format(string, sizeof(string), "NPC %d finished vehicle entry", npcid);
  130. SendClientMessageToAll(0xFF0000FF, string);
  131. #endif
  132. return 1;
  133. }
  134.  
  135. public FCNPC_OnVehicleExitComplete(npcid)
  136. {
  137. #if defined DEBUG
  138. new string[26 + 3 + 1];
  139. format(string, sizeof(string), "NPC %d finished vehicle exit", npcid);
  140. SendClientMessageToAll(0xFF0000FF, string);
  141. #endif
  142. return 1;
  143. }
  144.  
  145. public OnPlayerCommandText(playerid, cmdtext[])
  146. {
  147. new
  148. cmd[20],
  149. subcmd[20],
  150. param[20],
  151. idx;
  152.  
  153. cmd = strcharsplit(cmdtext, idx);
  154.  
  155. if (!strcmp(cmd, "/bg", true)) {
  156. subcmd = strcharsplit(cmdtext, idx);
  157. if (strlen(subcmd) == 0) {
  158. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg [option]");
  159. SendClientMessage(playerid, -1, "{8470FF}Options: {FFFFFF}add, delete, follow, unfollow, enter, exit");
  160. SendClientMessage(playerid, -1, "{8470FF}Options: {FFFFFF}shoot, aim, reset");
  161. return 1;
  162. }
  163.  
  164. if (!strcmp(subcmd, "add", true)) {
  165. new npcid = BG_Add(playerid);
  166. if (npcid < 0) {
  167. if (npcid == -1) {
  168. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Maximum bodyguards allowed per player is reached.");
  169. } else if (npcid == -2) {
  170. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}No slots available.");
  171. } else {
  172. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Unknown error.");
  173. }
  174. return 1;
  175. }
  176.  
  177. new
  178. Float:player_x,
  179. Float:player_y,
  180. Float:player_z,
  181. Float:player_angle;
  182.  
  183. GetPlayerPos(playerid, player_x, player_y, player_z);
  184. GetPlayerFacingAngle(playerid, player_angle);
  185.  
  186. new
  187. Float:pos_x,
  188. Float:pos_y;
  189.  
  190. GetCoordsInFront(player_x, player_y, player_angle, 2.0, pos_x, pos_y);
  191.  
  192. FCNPC_Spawn(npcid, random(4) + 163, pos_x, pos_y, player_z);
  193. FCNPC_SetAngleToPlayer(npcid, playerid);
  194. FCNPC_SetVirtualWorld(npcid, GetPlayerVirtualWorld(playerid));
  195. FCNPC_SetInterior(npcid, GetPlayerInterior(playerid));
  196. FCNPC_SetWeapon(npcid, random(3) + 22);
  197. FCNPC_ToggleInfiniteAmmo(npcid, true);
  198. FCNPC_SetArmour(npcid, 80);
  199. FCNPC_SetFightingStyle(npcid, random(4) + 3);
  200.  
  201. new label_text[2 + 3 + 1];
  202. format(label_text, sizeof(label_text), "[%d]", BG_GetSlotByID(npcid));
  203. gNpcText3D[npcid] = CreatePlayer3DTextLabel(playerid, label_text, 0xFFFFFFFF, 0.0, 0.0, 0.0, 5.0, npcid);
  204.  
  205. #if defined DEBUG
  206. new
  207. string[38 + MAX_PLAYER_NAME + 3 + 1],
  208. playername[MAX_PLAYER_NAME + 1];
  209.  
  210. GetPlayerName(playerid, playername, sizeof(playername));
  211. format(string, sizeof(string), "Player %s (ID: %d) has created a bodyguard", playername, playerid);
  212. SendClientMessageToAll(0xFF0000FF, string);
  213. #endif
  214. return 1;
  215. }
  216.  
  217. if (!strcmp(subcmd, "delete", true)) {
  218. param = strcharsplit(cmdtext, idx);
  219. if (strlen(param) == 0) {
  220. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg delete [slot]");
  221. return 1;
  222. }
  223.  
  224. new slot = strval(param);
  225. if (!BG_IsValidSlot(playerid, slot)) {
  226. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Invalid bodyguard.");
  227. return 1;
  228. }
  229.  
  230. BG_Delete(playerid, slot);
  231. return 1;
  232. }
  233.  
  234. if (!strcmp(subcmd, "follow", true)) {
  235. param = strcharsplit(cmdtext, idx);
  236. if (strlen(param) == 0) {
  237. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg follow [slot]");
  238. return 1;
  239. }
  240.  
  241. new slot = strval(param);
  242. if (!BG_IsValidSlot(playerid, slot)) {
  243. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Invalid bodyguard.");
  244. return 1;
  245. }
  246.  
  247. BG_FollowPlayer(playerid, slot, playerid);
  248. return 1;
  249. }
  250.  
  251. if (!strcmp(subcmd, "unfollow", true)) {
  252. param = strcharsplit(cmdtext, idx);
  253. if (strlen(param) == 0) {
  254. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg unfollow [slot]");
  255. return 1;
  256. }
  257.  
  258. new slot = strval(param);
  259. if (!BG_IsValidSlot(playerid, slot)) {
  260. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Invalid bodyguard.");
  261. return 1;
  262. }
  263.  
  264. BG_UnFollowPlayer(playerid, slot);
  265. return 1;
  266. }
  267.  
  268. if (!strcmp(subcmd, "aim", true)) {
  269. param = strcharsplit(cmdtext, idx);
  270. if (strlen(param) == 0) {
  271. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg aim [slot] [targetid]");
  272. return 1;
  273. }
  274.  
  275. new slot = strval(param);
  276. if (!BG_IsValidSlot(playerid, slot)) {
  277. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Invalid bodyguard.");
  278. return 1;
  279. }
  280.  
  281. param = strcharsplit(cmdtext, idx);
  282. if (strlen(param) == 0) {
  283. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg aim [slot] [targetid]");
  284. return 1;
  285. }
  286.  
  287. new targetid = strval(param);
  288. if (!IsPlayerConnected(targetid)) {
  289. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Invalid target.");
  290. return 1;
  291. }
  292.  
  293. BG_Aim(playerid, slot, targetid);
  294. return 1;
  295. }
  296.  
  297. if (!strcmp(subcmd, "shoot", true)) {
  298. param = strcharsplit(cmdtext, idx);
  299. if (strlen(param) == 0) {
  300. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg shoot [slot] [targetid]");
  301. return 1;
  302. }
  303.  
  304. new slot = strval(param);
  305. if (!BG_IsValidSlot(playerid, slot)) {
  306. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Invalid bodyguard.");
  307. return 1;
  308. }
  309.  
  310. param = strcharsplit(cmdtext, idx);
  311. if (strlen(param) == 0) {
  312. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg shoot [slot] [targetid]");
  313. return 1;
  314. }
  315.  
  316. new targetid = strval(param);
  317. if (!IsPlayerConnected(targetid)) {
  318. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Invalid target.");
  319. return 1;
  320. }
  321.  
  322. BG_Shoot(playerid, slot, targetid);
  323. return 1;
  324. }
  325.  
  326. if (!strcmp(subcmd, "reset", true)) {
  327. param = strcharsplit(cmdtext, idx);
  328. if (strlen(param) == 0) {
  329. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg reset [slot]");
  330. return 1;
  331. }
  332.  
  333. new slot = strval(param);
  334. if (!BG_IsValidSlot(playerid, slot)) {
  335. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Invalid bodyguard.");
  336. return 1;
  337. }
  338.  
  339. BG_AimReset(playerid, slot);
  340. return 1;
  341. }
  342.  
  343. if (!strcmp(subcmd, "enter", true)) {
  344. param = strcharsplit(cmdtext, idx);
  345. if (strlen(param) == 0) {
  346. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg enter [slot] [vehicleid] [seat]");
  347. return 1;
  348. }
  349.  
  350. new slot = strval(param);
  351. if (!BG_IsValidSlot(playerid, slot)) {
  352. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Invalid bodyguard.");
  353. return 1;
  354. }
  355.  
  356. param = strcharsplit(cmdtext, idx);
  357. if (strlen(param) == 0) {
  358. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg enter [slot] [vehicleid] [seat]");
  359. return 1;
  360. }
  361.  
  362. new vehicleid = strval(param);
  363. if (!GetVehicleModel(vehicleid)) {
  364. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Invalid target.");
  365. return 1;
  366. }
  367.  
  368. param = strcharsplit(cmdtext, idx);
  369. new seat = strval(param);
  370.  
  371. BG_UnFollowPlayer(playerid, slot);
  372. BG_EnterVehicle(playerid, slot, vehicleid, seat);
  373. return 1;
  374. }
  375.  
  376. if (!strcmp(subcmd, "exit", true)) {
  377. param = strcharsplit(cmdtext, idx);
  378. if (strlen(param) == 0) {
  379. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg exit [slot]");
  380. return 1;
  381. }
  382.  
  383. new slot = strval(param);
  384. if (!BG_IsValidSlot(playerid, slot)) {
  385. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Invalid bodyguard.");
  386. return 1;
  387. }
  388.  
  389. BG_ExitVehicle(playerid, slot);
  390. return 1;
  391. }
  392.  
  393. if (!strcmp(subcmd, "melee", true)) {
  394. param = strcharsplit(cmdtext, idx);
  395. if (strlen(param) == 0) {
  396. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg melee [slot]");
  397. return 1;
  398. }
  399.  
  400. new slot = strval(param);
  401. if (!BG_IsValidSlot(playerid, slot)) {
  402. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Invalid bodyguard.");
  403. return 1;
  404. }
  405.  
  406. BG_Melee(playerid, slot);
  407. return 1;
  408. }
  409.  
  410. if (!strcmp(subcmd, "stopmelee", true)) {
  411. param = strcharsplit(cmdtext, idx);
  412. if (strlen(param) == 0) {
  413. SendClientMessage(playerid, -1, "{8470FF}Use: {FFFFFF}/bg stopmelee [slot]");
  414. return 1;
  415. }
  416.  
  417. new slot = strval(param);
  418. if (!BG_IsValidSlot(playerid, slot)) {
  419. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}Invalid bodyguard.");
  420. return 1;
  421. }
  422.  
  423. BG_MeleeStop(playerid, slot);
  424. return 1;
  425. }
  426. }
  427. return 0;
  428. }
  429.  
  430. /*
  431. Vehicle functions
  432. */
  433.  
  434. stock BG_EnterVehicle(playerid, slot, vehicleid, seat)
  435. {
  436. new npcid = gPlayerNpc[playerid][slot];
  437. FCNPC_EnterVehicle(npcid, vehicleid, seat, MOVE_TYPE_RUN);
  438. }
  439.  
  440. stock BG_ExitVehicle(playerid, slot)
  441. {
  442. new npcid = gPlayerNpc[playerid][slot];
  443. FCNPC_ExitVehicle(npcid);
  444. }
  445.  
  446. /*
  447. Aim functions
  448. */
  449.  
  450. stock BG_Aim(playerid, slot, targetid)
  451. {
  452. new npcid = gPlayerNpc[playerid][slot];
  453. FCNPC_AimAtPlayer(npcid, targetid);
  454. }
  455.  
  456. stock BG_Shoot(playerid, slot, targetid)
  457. {
  458. new npcid = gPlayerNpc[playerid][slot];
  459. FCNPC_AimAtPlayer(npcid, targetid, .shoot = true);
  460. }
  461.  
  462. stock BG_AimReset(playerid, slot)
  463. {
  464. new npcid = gPlayerNpc[playerid][slot];
  465. FCNPC_StopAim(npcid);
  466. }
  467.  
  468. /*
  469. Melee functions
  470. */
  471.  
  472. stock BG_Melee(playerid, slot)
  473. {
  474. BG_MeleeStop(playerid, slot);
  475.  
  476. new npcid = gPlayerNpc[playerid][slot];
  477. SetPVarInt(npcid, "bg_last_weapon", FCNPC_GetWeapon(npcid));
  478. FCNPC_SetWeapon(npcid, 0);
  479.  
  480. FCNPC_MeleeAttack(npcid, .fightstyle = true);
  481. }
  482.  
  483. stock BG_MeleeStop(playerid, slot)
  484. {
  485. new npcid = gPlayerNpc[playerid][slot];
  486. FCNPC_SetWeapon(npcid, GetPVarInt(npcid, "bg_last_weapon"));
  487. FCNPC_StopAttack(npcid);
  488. }
  489.  
  490. /*
  491. Follow functions
  492. */
  493.  
  494. stock BG_SetFollowTimer(npcid)
  495. {
  496. if (gFollowTarget[npcid] != INVALID_PLAYER_ID) {
  497. gFollowTimer[npcid] = SetTimerEx("BG_SetFollowPosition", 300, true, "ii", npcid, gFollowTarget[npcid]);
  498. }
  499. }
  500.  
  501. stock BG_FollowPlayer(playerid, slot, targetid)
  502. {
  503. BG_UnFollowPlayer(playerid, slot);
  504.  
  505. new npcid = gPlayerNpc[playerid][slot];
  506. gFollowTarget[npcid] = targetid;
  507.  
  508. new isgo = BG_SetFollowPosition(npcid, targetid);
  509. if (!isgo) {
  510. BG_SetFollowTimer(npcid);
  511. }
  512. }
  513.  
  514. stock BG_UnFollowPlayer(playerid, slot)
  515. {
  516. new npcid = gPlayerNpc[playerid][slot];
  517.  
  518. if (gFollowTimer[npcid] != 0) {
  519. KillTimer(gFollowTimer[npcid]);
  520. gFollowTimer[npcid] = 0;
  521. }
  522.  
  523. if (gFollowTarget[npcid] == INVALID_PLAYER_ID) {
  524. return 0;
  525. }
  526.  
  527. gFollowTarget[npcid] = INVALID_PLAYER_ID;
  528. return 1;
  529. }
  530.  
  531. forward BG_SetFollowPosition(npcid, playerid);
  532. public BG_SetFollowPosition(npcid, playerid)
  533. {
  534. new
  535. Float:pos_x,
  536. Float:pos_y,
  537. Float:pos_z,
  538. Float:dist_offset,
  539. Float:range,
  540. Float:speed;
  541.  
  542. GetPlayerPos(playerid, pos_x, pos_y, pos_z);
  543.  
  544. if (FCNPC_GetVehicleID(npcid) != INVALID_VEHICLE_ID) {
  545. dist_offset = -3.0;
  546. range = -dist_offset + 1.0;
  547. speed = 0.8;
  548. } else {
  549. dist_offset = -1.0;
  550. range = -dist_offset + 0.5;
  551. speed = MOVE_SPEED_AUTO;
  552. }
  553.  
  554. if (!IsPlayerInRangeOfPoint(npcid, range, pos_x, pos_y, pos_z)) {
  555. FCNPC_GoToPlayer(npcid, playerid, .speed = speed, .dist_offset = dist_offset);
  556. KillTimer(gFollowTimer[npcid]);
  557. gFollowTimer[npcid] = 0;
  558. return 1;
  559. }
  560. return 0;
  561. }
  562.  
  563. /*
  564. Add/Delete functions
  565. */
  566.  
  567. stock BG_Add(playerid)
  568. {
  569. new slot = BG_GetFreeSlot(playerid);
  570. if (slot == BG_INVALID_SLOT_ID) {
  571. return -1;
  572. }
  573.  
  574. new name[MAX_PLAYER_NAME + 1];
  575. format(name, sizeof(name), "Guard_%d_%d", playerid, slot);
  576. new npcid = FCNPC_Create(name);
  577. if (npcid == INVALID_PLAYER_ID) {
  578. return -2;
  579. }
  580.  
  581. gPlayerNpc[playerid][slot] = npcid;
  582. gNpcPlayer[npcid] = playerid;
  583. gNpcSlot[npcid] = slot;
  584. return npcid;
  585. }
  586.  
  587. stock BG_Delete(playerid, slot)
  588. {
  589. new npcid = gPlayerNpc[playerid][slot];
  590.  
  591. FCNPC_Destroy(npcid);
  592. BG_UnFollowPlayer(playerid, slot);
  593. DeletePlayer3DTextLabel(playerid, gNpcText3D[npcid]);
  594.  
  595. gPlayerNpc[playerid][slot] = INVALID_PLAYER_ID;
  596. gNpcPlayer[npcid] = INVALID_PLAYER_ID;
  597. gNpcSlot[npcid] = BG_INVALID_SLOT_ID;
  598. }
  599.  
  600. stock BG_DeleteByID(npcid)
  601. {
  602. new playerid = gNpcPlayer[npcid];
  603. new slot = gNpcSlot[npcid];
  604.  
  605. BG_Delete(playerid, slot);
  606. }
  607.  
  608. /*
  609. Slot functions
  610. */
  611.  
  612. stock BG_IsValidSlot(playerid, slot)
  613. {
  614. if (slot < 0 || slot > sizeof(gPlayerNpc[])) {
  615. return false;
  616. }
  617. return gPlayerNpc[playerid][slot] != INVALID_PLAYER_ID;
  618. }
  619.  
  620. stock BG_IsValid(npcid)
  621. {
  622. return FCNPC_IsValid(npcid) && gNpcSlot[npcid] != BG_INVALID_SLOT_ID;
  623. }
  624.  
  625. stock BG_GetFreeSlot(playerid)
  626. {
  627. for (new slot; slot < sizeof(gPlayerNpc[]); slot++) {
  628. if (gPlayerNpc[playerid][slot] == INVALID_PLAYER_ID) {
  629. return slot;
  630. }
  631. }
  632. return BG_INVALID_SLOT_ID;
  633. }
  634.  
  635. stock BG_GetSlotByID(npcid)
  636. {
  637. return gNpcSlot[npcid];
  638. }
  639.  
  640. /*
  641. Other functions
  642. */
  643.  
  644. stock strcharsplit(const string[], &index, seperator = ' ')
  645. {
  646. new
  647. result[20],
  648. i;
  649.  
  650. if (index != 0 && string[index] != '\0') {
  651. index++;
  652. }
  653.  
  654. while (string[index] && string[index] != seperator && string[index] != '\r' && string[index] != '\n') {
  655. result[i++] = string[index++];
  656. }
  657. return result;
  658. }
  659.  
  660. stock GetCoordsInFront(Float:x, Float:y, Float:a, Float:distance, &Float:res_x, &Float:res_y)
  661. {
  662. res_x = x + (distance * floatsin(-a, degrees));
  663. res_y = y + (distance * floatcos(-a, degrees));
  664. }
  665.  
  666. stock GetBodypartName(bodypart, name[], const size = sizeof(name))
  667. {
  668. static const
  669. names[][] = {
  670. !"torso",
  671. !"groin",
  672. !"left arm",
  673. !"right arm",
  674. !"left leg",
  675. !"right leg",
  676. !"head"
  677. };
  678.  
  679. if (9 < bodypart < 3) {
  680. return 0;
  681. }
  682.  
  683. return strunpack(name, names[bodypart - 3], size);
  684. }
Add Comment
Please, Sign In to add comment