Advertisement
Felipe_Alves

Weapon Reload - v0.1b

Oct 20th, 2018
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.35 KB | None | 0 0
  1.  
  2. /*
  3.  
  4. native GiveWeapon(playerid, weaponid, ammo);
  5.  
  6. */
  7.  
  8. #if defined _include_weapon_reload
  9. #endinput
  10. #endif
  11. #define _include_weapon_reload
  12. // INCLUDES --------------------------------------------------------------------
  13. #tryinclude <a_samp>
  14. // DEFINES ---------------------------------------------------------------------
  15. // macros
  16. #define FS_CALLBACK:%0(%1) forward %0(%1); public %0(%1)
  17. //------------------------------------------------------------------------------
  18. //others
  19. #define NAME_PROJECT "Weapon - Reload"
  20. #define CREATOR_PROJECT "Felipe_Alves"
  21. #define VERSION_PROJECT "0.1b"
  22. //------------------------------------------------------------------------------
  23. #define FUNCTION static
  24. #define FINITO 100000000000000000000
  25.  
  26. // VARIAVEIS GLOBAL ------------------------------------------------------------
  27. //-- Txt:
  28. static
  29. Text:FundoPlayer[2],
  30. // VARIAVEIS PLAYER ------------------------------------------------------------
  31. //-- Txt:
  32. PlayerText:WeaponAndAmmo[MAX_PLAYERS][2],
  33.  
  34. //--Int:
  35. disparos[MAX_PLAYERS][13],
  36. balas[MAX_PLAYERS][13],
  37. Timer[MAX_PLAYERS];
  38.  
  39. // CALLBACKS NATIVAS DO SAMP --------------------------------------------------
  40. //------------------------------------------------------------------------------
  41. public OnGameModeInit()
  42. {
  43. // Global Textdraws:
  44. FundoPlayer[0] = TextDrawCreate(488.300018, 21.253330, "box");
  45. TextDrawLetterSize(FundoPlayer[0], 0.000000, 8.639999);
  46. TextDrawTextSize(FundoPlayer[0], 615.000000, 0.000000);
  47. TextDrawAlignment(FundoPlayer[0], 1);
  48. TextDrawColor(FundoPlayer[0], -1);
  49. TextDrawUseBox(FundoPlayer[0], 1);
  50. TextDrawBoxColor(FundoPlayer[0], -1464864257);
  51. TextDrawSetShadow(FundoPlayer[0], 0);
  52. TextDrawSetOutline(FundoPlayer[0], 0);
  53. TextDrawBackgroundColor(FundoPlayer[0], 255);
  54. TextDrawFont(FundoPlayer[0], 1);
  55. TextDrawSetProportional(FundoPlayer[0], 1);
  56. TextDrawSetShadow(FundoPlayer[0], 0);
  57.  
  58. FundoPlayer[1] = TextDrawCreate(492.400024, 36.186668, "box");
  59. TextDrawLetterSize(FundoPlayer[1], 0.000000, 5.199999);
  60. TextDrawTextSize(FundoPlayer[1], 539.000000, 0.000000);
  61. TextDrawAlignment(FundoPlayer[1], 1);
  62. TextDrawColor(FundoPlayer[1], -1);
  63. TextDrawUseBox(FundoPlayer[1], 1);
  64. TextDrawBoxColor(FundoPlayer[1], 538837247);
  65. TextDrawSetShadow(FundoPlayer[1], 0);
  66. TextDrawSetOutline(FundoPlayer[1], 0);
  67. TextDrawBackgroundColor(FundoPlayer[1], 255);
  68. TextDrawFont(FundoPlayer[1], 1);
  69. TextDrawSetProportional(FundoPlayer[1], 0);
  70. TextDrawSetShadow(FundoPlayer[1], 0);
  71.  
  72. for(new playerid = 0; playerid < MAX_PLAYERS; ++playerid) DestroyTxd(playerid);
  73. for(new i = 0; i < MAX_PLAYERS; i++) CreateTxd(i);
  74. for(new i = 0; i < 30; ++i)print(" ");
  75. print("\n--------------------------------------");
  76. print(" Carregado");
  77. printf("\n Nome: %s", NAME_PROJECT);
  78. printf(" By: %s", CREATOR_PROJECT);
  79. printf(" Versão: %s\n", VERSION_PROJECT);
  80. print("--------------------------------------\n");
  81.  
  82. #if defined hook_OnGameModeInit
  83. return hook_OnGameModeInit();
  84. #else
  85. return 1;
  86. #endif
  87. }
  88.  
  89. #if defined _ALS_OnGameModeInit
  90. #undef OnGameModeInit
  91. #else
  92. #define _ALS_OnGameModeInit
  93. #endif
  94. #define OnGameModeInit hook_OnGameModeInit
  95. #if defined hook_OnGameModeInit
  96. forward hook_OnGameModeInit();
  97. #endif
  98.  
  99. public OnGameModeExit()
  100. {
  101. for(new i = 0; i < 30; ++i) print(" ");
  102. print("\n|-----------------------------------|");
  103. printf("| %s |", NAME_PROJECT);
  104. print("| Encerrado |");
  105. print("|-----------------------------------|\n");
  106. for(new i = 0; i < 2; ++i) TextDrawDestroy(FundoPlayer[i]);
  107. for(new playerid = 0; playerid < MAX_PLAYERS; ++playerid) if(IsPlayerConnected(playerid) || !IsPlayerConnected(playerid)) DestroyTxd(playerid);
  108. #if defined hook_OnGameModeExit
  109. return hook_OnGameModeExit();
  110. #else
  111. return 1;
  112. #endif
  113. }
  114.  
  115. #if defined _ALS_OnGameModeExit
  116. #undef OnGameModeExit
  117. #else
  118. #define _ALS_OnGameModeExit
  119. #endif
  120. #define OnGameModeExit hook_OnGameModeExit
  121. #if defined hook_OnGameModeExit
  122. forward hook_OnGameModeExit();
  123. #endif
  124.  
  125.  
  126. public OnPlayerConnect(playerid){
  127. Timer[playerid] = SetTimerEx("UpdateWeapon", 50, 1, "d", playerid);
  128. #if defined hook_OnPlayerConnect
  129. return hook_OnPlayerConnect(playerid);
  130. #else
  131. return 1;
  132. #endif
  133. }
  134.  
  135. #if defined _ALS_OnPlayerConnect
  136. #undef OnPlayerConnect
  137. #else
  138. #define _ALS_OnPlayerConnect
  139. #endif
  140. #define OnPlayerConnect hook_OnPlayerConnect
  141. #if defined hook_OnPlayerConnect
  142. forward hook_OnPlayerConnect(playerid);
  143. #endif
  144.  
  145. public OnPlayerDisconnect(playerid, reason){
  146. KillTimer(Timer[playerid]);
  147. #if defined hook_OnPlayerDisconnect
  148. return hook_OnPlayerDisconnect(playerid, reason);
  149. #else
  150. return 1;
  151. #endif
  152. }
  153.  
  154. #if defined _ALS_OnPlayerDisconnect
  155. #undef OnPlayerDisconnect
  156. #else
  157. #define _ALS_OnPlayerDisconnect
  158. #endif
  159.  
  160. #define OnPlayerDisconnect hook_OnPlayerDisconnect
  161. #if defined hook_OnPlayerDisconnect
  162. forward hook_OnPlayerDisconnect(playerid, reason);
  163. #endif
  164.  
  165. public OnPlayerSpawn(playerid){
  166. EncerrarTxd(playerid);
  167. SetTimerEx("CarregarTxd", 500, 0, "d", playerid);
  168. #if defined hook_OnPlayerSpawn
  169. return hook_OnPlayerSpawn(playerid);
  170. #else
  171. return 1;
  172. #endif
  173. }
  174.  
  175. #if defined _ALS_OnPlayerSpawn
  176. #undef OnPlayerSpawn
  177. #else
  178. #define _ALS_OnPlayerSpawn
  179. #endif
  180. #define OnPlayerSpawn hook_OnPlayerSpawn
  181. #if defined hook_OnPlayerSpawn
  182. forward hook_OnPlayerSpawn(playerid);
  183. #endif
  184.  
  185. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ){
  186. // Conta os disparos;
  187. ++disparos[playerid][SlotsWeapons(weaponid)];
  188. // SetTimerEx é usado para verificar logo após o último disparo;
  189. SetTimerEx("WeaponCheck", 500, 0, "ddd", playerid, weaponid, 0); // 0 - ZERA O DISPARO QUANDO A VARIAVEL BALA == 0 && BALAS NA ARMA == 0;
  190. SetTimerEx("WeaponCheck", 500, 0, "ddd", playerid, weaponid, 1); // 1 - ZERA O DISPARO QUANDO BALAS NA ARMA == 0;
  191. if(disparos[playerid][SlotsWeapons(weaponid)] == 2 && weaponid == 26){
  192. ReturnAnimationReload(playerid, 26);
  193. }
  194. #if defined hook_OnPlayerWeaponShot
  195. return hook_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  196. #else
  197. return 1;
  198. #endif
  199. }
  200.  
  201. #if defined _ALS_OnPlayerWeaponShot
  202. #undef OnPlayerWeaponShot
  203. #else
  204. #define _ALS_OnPlayerWeaponShot
  205. #endif
  206. #define OnPlayerWeaponShot hook_OnPlayerWeaponShot
  207. #if defined hook_OnPlayerWeaponShot
  208. forward hook_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  209. #endif
  210.  
  211. public OnPlayerUpdate(playerid){
  212. new weaponid = GetPlayerWeapon(playerid), disparo = disparos[playerid][SlotsWeapons(weaponid)];
  213. if(weaponid != 0 && (weaponid != 16 || weaponid != 17 || weaponid != 18 || weaponid != 39 || weaponid != 40 ||
  214. weaponid != 41 || weaponid != 42 || weaponid != 43 || weaponid != 44 || weaponid != 45 || weaponid != 46)){
  215. if(weaponid > 0 && weaponid < 16)
  216. if(balas[playerid][SlotsWeapons(weaponid)] > 0){
  217. balas[playerid][SlotsWeapons(weaponid)] = 0;
  218. }
  219. if(disparo > ReturnWeaponLimitAmmo(weaponid)) disparos[playerid][SlotsWeapons(weaponid)] = ReturnWeaponLimitAmmo(weaponid);
  220. if(disparo == ReturnWeaponLimitAmmo(weaponid)){
  221. if(balas[playerid][SlotsWeapons(weaponid)] > 0)
  222. ReturnAnimationReload(playerid, weaponid);
  223. if(balas[playerid][SlotsWeapons(weaponid)] > 0 && balas[playerid][SlotsWeapons(weaponid)] < ReturnWeaponLimitAmmo(weaponid)){
  224. SetTimerEx("GivePlayerWeaponTimer", 50, 0, "ddd", playerid, weaponid, balas[playerid][SlotsWeapons(weaponid)]);
  225. balas[playerid][SlotsWeapons(weaponid)] = 0;
  226. }
  227. if(balas[playerid][SlotsWeapons(weaponid)] > ReturnWeaponLimitAmmo(weaponid)){
  228. SetTimerEx("GivePlayerWeaponTimer", 50, 0, "ddd", playerid, weaponid, ReturnWeaponLimitAmmo(weaponid));
  229. balas[playerid][SlotsWeapons(weaponid)] -= ReturnWeaponLimitAmmo(weaponid);
  230. }
  231. if(balas[playerid][SlotsWeapons(weaponid)] == ReturnWeaponLimitAmmo(weaponid)){
  232. SetTimerEx("GivePlayerWeaponTimer", 50, 0, "ddd", playerid, weaponid, ReturnWeaponLimitAmmo(weaponid));
  233. balas[playerid][SlotsWeapons(weaponid)] -= ReturnWeaponLimitAmmo(weaponid);
  234. }
  235. disparos[playerid][SlotsWeapons(weaponid)] = 0;
  236. return 1;
  237. }
  238. if(disparo > 0 && disparo < ReturnWeaponLimitAmmo(weaponid) && CheckWeaponAmmo(playerid, SlotsWeapons(weaponid))){
  239. if(balas[playerid][SlotsWeapons(weaponid)] > 0)
  240. ReturnAnimationReload(playerid, weaponid);
  241. if(balas[playerid][SlotsWeapons(weaponid)] > ReturnWeaponLimitAmmo(weaponid)){
  242. SetTimerEx("GivePlayerWeaponTimer", 50, 0, "ddd", playerid, weaponid, ReturnWeaponLimitAmmo(weaponid));
  243. balas[playerid][SlotsWeapons(weaponid)] -= ReturnWeaponLimitAmmo(weaponid);
  244. }
  245. if(balas[playerid][SlotsWeapons(weaponid)] > 0 && balas[playerid][SlotsWeapons(weaponid)] < ReturnWeaponLimitAmmo(weaponid)){
  246. SetTimerEx("GivePlayerWeaponTimer", 50, 0, "ddd", playerid, weaponid, balas[playerid][SlotsWeapons(weaponid)]);
  247. balas[playerid][SlotsWeapons(weaponid)] = 0;
  248. }
  249. if(balas[playerid][SlotsWeapons(weaponid)] == ReturnWeaponLimitAmmo(weaponid)){
  250. balas[playerid][SlotsWeapons(weaponid)] -= ReturnWeaponLimitAmmo(weaponid);
  251. SetTimerEx("GivePlayerWeaponTimer", 50, 0, "ddd", playerid, weaponid, balas[playerid][SlotsWeapons(weaponid)]);
  252. }
  253. disparos[playerid][SlotsWeapons(weaponid)] = 0;
  254. return 1;
  255. }
  256. ReajustWeaponAmmo(playerid);
  257. }
  258. #if defined hook_OnPlayerUpdate
  259. return hook_OnPlayerUpdate(playerid);
  260. #else
  261. return 1;
  262. #endif
  263. }
  264.  
  265. #if defined _ALS_OnPlayerUpdate
  266. #undef OnPlayerUpdate
  267. #else
  268. #define _ALS_OnPlayerUpdate
  269. #endif
  270. #define OnPlayerUpdate hook_OnPlayerUpdate
  271. #if defined hook_OnPlayerUpdate
  272. forward hook_OnPlayerUpdate(playerid);
  273. #endif
  274. //--------------------------------------------------------------------------------
  275. // CALLBACKS ---------------------------------------------------------------------
  276. FS_CALLBACK:WeaponCheck(playerid, weaponid, verification){
  277. if(verification == 0)
  278. if(balas[playerid][SlotsWeapons(weaponid)] < 1 && CheckWeaponAmmo(playerid, SlotsWeapons(weaponid))){
  279. disparos[playerid][SlotsWeapons(weaponid)] = 0;
  280. }
  281. if(verification == 1){
  282. if(CheckWeaponAmmo(playerid, SlotsWeapons(weaponid))){
  283. disparos[playerid][SlotsWeapons(weaponid)] = 0;
  284. }
  285. }
  286. return 1;
  287. }
  288.  
  289. FS_CALLBACK:UpdateWeapon(playerid){
  290. new string[28], weaponid = GetPlayerWeapon(playerid);
  291. PlayerTextDrawSetPreviewModel(playerid, WeaponAndAmmo[playerid][0], ReturnModelWeapon(GetPlayerWeapon(playerid)));
  292. PlayerTextDrawShow(playerid, WeaponAndAmmo[playerid][0]);
  293. if(weaponid > 0 && weaponid < 19 || weaponid == 32 || weaponid == 28 || (weaponid >= 35 && weaponid <= 37 ) || (weaponid >= 39 && weaponid <= 46))
  294. format(string, sizeof(string), "%d", GetPlayerAmmo(playerid));
  295. else if(weaponid != 0)
  296. format(string, sizeof(string), "%d-%d", balas[playerid][SlotsWeapons(GetPlayerWeapon(playerid))], GetPlayerAmmo(playerid));
  297. PlayerTextDrawSetString(playerid, WeaponAndAmmo[playerid][1], string);
  298. return 1;
  299. }
  300.  
  301. FS_CALLBACK:EncerrarTxd(playerid){
  302. DestroyTxd(playerid);
  303. for(new i = 0; i < 2; ++i) TextDrawHideForPlayer(playerid, FundoPlayer[i]);
  304. for(new i = 0; i < 2; ++i) PlayerTextDrawHide(playerid, WeaponAndAmmo[playerid][i]);
  305. return 1;
  306. }
  307.  
  308. FS_CALLBACK:CarregarTxd(playerid){
  309. CreateTxd(playerid);
  310. for(new i = 0; i < 2; ++i) TextDrawShowForPlayer(playerid, FundoPlayer[i]);
  311. for(new i = 0; i < 2; ++i) PlayerTextDrawShow(playerid, WeaponAndAmmo[playerid][i]);
  312. return 1;
  313. }
  314.  
  315. FS_CALLBACK:DestroyTxd(playerid){
  316. for(new i = 0; i < 2; ++i) PlayerTextDrawDestroy(playerid, WeaponAndAmmo[playerid][i]);
  317. return 1;
  318. }
  319.  
  320. FS_CALLBACK:CreateTxd(playerid){
  321. WeaponAndAmmo[playerid][0] = CreatePlayerTextDraw(playerid, 481.799926, 0.766670, "");
  322. PlayerTextDrawLetterSize(playerid, WeaponAndAmmo[playerid][0], 0.000000, 0.000000);
  323. PlayerTextDrawTextSize(playerid, WeaponAndAmmo[playerid][0], 85.000000, 126.000000);
  324. PlayerTextDrawAlignment(playerid, WeaponAndAmmo[playerid][0], 1);
  325. PlayerTextDrawColor(playerid, WeaponAndAmmo[playerid][0], -1);
  326. PlayerTextDrawSetShadow(playerid, WeaponAndAmmo[playerid][0], 0);
  327. PlayerTextDrawSetOutline(playerid, WeaponAndAmmo[playerid][0], 0);
  328. PlayerTextDrawBackgroundColor(playerid, WeaponAndAmmo[playerid][0], -256);
  329. PlayerTextDrawFont(playerid, WeaponAndAmmo[playerid][0], 5);
  330. PlayerTextDrawSetProportional(playerid, WeaponAndAmmo[playerid][0], 0);
  331. PlayerTextDrawSetShadow(playerid, WeaponAndAmmo[playerid][0], 0);
  332. PlayerTextDrawSetPreviewModel(playerid, WeaponAndAmmo[playerid][0], 348);
  333. PlayerTextDrawSetPreviewRot(playerid, WeaponAndAmmo[playerid][0], 0.000000, -30.00000, 0.000000, 2.200000);
  334.  
  335. WeaponAndAmmo[playerid][1] = CreatePlayerTextDraw(playerid, 516.400024, 73.022270, "0-0");
  336. PlayerTextDrawLetterSize(playerid, WeaponAndAmmo[playerid][1], 0.256799, 1.316267);
  337. PlayerTextDrawAlignment(playerid, WeaponAndAmmo[playerid][1], 2);
  338. PlayerTextDrawColor(playerid, WeaponAndAmmo[playerid][1], -98);
  339. PlayerTextDrawSetShadow(playerid, WeaponAndAmmo[playerid][1], 0);
  340. PlayerTextDrawSetOutline(playerid, WeaponAndAmmo[playerid][1], 1);
  341. PlayerTextDrawBackgroundColor(playerid, WeaponAndAmmo[playerid][1], 106);
  342. PlayerTextDrawFont(playerid, WeaponAndAmmo[playerid][1], 1);
  343. PlayerTextDrawSetProportional(playerid, WeaponAndAmmo[playerid][1], 1);
  344. PlayerTextDrawSetShadow(playerid, WeaponAndAmmo[playerid][1], 0);
  345. return 1;
  346. }
  347.  
  348. // FUNÇÕES ---------------------------------------------------------------------
  349.  
  350. stock GiveWeapon(playerid, weaponid, ammo){
  351. if(ReturnPlayerWeapon(playerid, weaponid)){
  352. balas[playerid][SlotsWeapons(weaponid)] = 0;
  353. RemoveWeaponPlayer(playerid, SlotsWeapons(weaponid));
  354. SetTimerEx("GivePlayerWeaponEx", 100, 0, "ddd", playerid, weaponid, ammo);
  355. }else{
  356. if(CheckWeapon(playerid, weaponid) && ReturnWeaponsNoReload(weaponid))
  357. GivePlayerWeapon(playerid, weaponid, ammo);
  358. else
  359. SetTimerEx("GivePlayerWeaponEx", 100, 0, "ddd", playerid, weaponid, ammo);
  360. }
  361. return 1;
  362. }
  363.  
  364. FS_CALLBACK:GivePlayerWeaponEx(playerid, weaponid, ammo){
  365. if(weaponid >= 16 && weaponid <= 18){
  366. GivePlayerWeapon(playerid, weaponid, ammo);
  367. return 1;
  368. }
  369. if(ammo > ReturnWeaponLimitAmmo(weaponid)){
  370. if(!CheckWeaponAmmo(playerid, SlotsWeapons(weaponid))){
  371. balas[playerid][SlotsWeapons(weaponid)] += ammo;
  372. }else{
  373. balas[playerid][SlotsWeapons(weaponid)] = ammo-ReturnWeaponLimitAmmo(weaponid);
  374. GivePlayerWeapon(playerid, weaponid, ReturnWeaponLimitAmmo(weaponid));
  375. }
  376. return 1;
  377. }else if(ammo < ReturnWeaponLimitAmmo(weaponid)){
  378. if(!CheckWeaponAmmo(playerid, SlotsWeapons(weaponid))){
  379. balas[playerid][SlotsWeapons(weaponid)] += ammo;
  380. }else{
  381. GivePlayerWeapon(playerid, weaponid, ammo);
  382. }
  383. return 1;
  384. }else if(ammo == ReturnWeaponLimitAmmo(weaponid)){
  385. if(!CheckWeaponAmmo(playerid, SlotsWeapons(weaponid))){
  386. balas[playerid][SlotsWeapons(weaponid)] += ReturnWeaponLimitAmmo(weaponid);
  387. }else{
  388. GivePlayerWeapon(playerid, weaponid, ReturnWeaponLimitAmmo(weaponid));
  389. }
  390. return 1;
  391. }
  392. return 1;
  393. }
  394.  
  395. FS_CALLBACK:GivePlayerWeaponTimer(playerid, weaponid, ammo){
  396. return GivePlayerWeapon(playerid, weaponid, ammo);
  397. }
  398.  
  399. FUNCTION ReturnWeaponsNoReload(weaponid){
  400. switch(weaponid){
  401. case 16, 17, 18, 28, 32, 35, 36, 37, 39, 41, 42, 43: return true;
  402. default: return false;
  403. }
  404. return false;
  405. }
  406.  
  407. FUNCTION ReajustWeaponAmmo(playerid){
  408. if(GetPlayerAmmo(playerid) > ReturnWeaponLimitAmmo(GetPlayerWeapon(playerid))){
  409. ReajustWeapon(playerid);
  410. return 1;
  411. }
  412. return 1;
  413. }
  414.  
  415. FUNCTION CheckWeapon(playerid, weaponid){
  416. new weapon, ammo;
  417. GetPlayerWeaponData(playerid, SlotsWeapons(weaponid), weapon, ammo);
  418. if(weaponid == weapon)
  419. return true;
  420. return false;
  421. }
  422.  
  423. FUNCTION CheckWeaponAmmo(playerid, slot){
  424. new weaponid, ammo;
  425. GetPlayerWeaponData(playerid, slot, weaponid, ammo);
  426. if(ammo == 0)
  427. return true;
  428. return false;
  429. }
  430.  
  431. FUNCTION ReajustWeapon(playerid){
  432. new armas[13][2];
  433. for(new i = 0; i < 13; i++){
  434. GetPlayerWeaponData(playerid, i, armas[i][0], armas[i][1]);
  435. }
  436. ResetPlayerWeapons(playerid);
  437. for(new i = 0; i < 13; i++){
  438. if(armas[i][1] > ReturnWeaponLimitAmmo(armas[i][0])){
  439. if(armas[i][1] > ReturnWeaponLimitAmmo(armas[i][0])){
  440. balas[playerid][i] = (armas[i][1] - ReturnWeaponLimitAmmo(armas[i][0]));
  441. GivePlayerWeapon(playerid, armas[i][0], ReturnWeaponLimitAmmo(armas[i][0]));
  442. disparos[playerid][SlotsWeapons(armas[i][0])] = 0;
  443. return 1;
  444. }
  445. }else{
  446. SetTimerEx("GivePlayerWeaponTimer", 50, 0, "ddd", playerid, armas[i][0], armas[i][1]);
  447. return 1;
  448. }
  449. }
  450. return 1;
  451. }
  452.  
  453. FUNCTION RemoveWeaponPlayer(playerid, slot){
  454. new weapons[13][2];
  455. for(new i = 0; i < 13; i++){
  456. new weapon, ammo;
  457. GetPlayerWeaponData(playerid, i, weapon, ammo);
  458. if(i != slot)
  459. GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
  460. }
  461. disparos[playerid][slot] = 0;
  462. ResetPlayerWeapons(playerid);
  463. for(new i = 0; i < 13; i++){
  464. GivePlayerWeapon(playerid, weapons[i][0], weapons[i][1]);
  465. }
  466. return 1;
  467. }
  468.  
  469. FUNCTION ReturnPlayerWeapon(playerid, weaponid){
  470. new weapons[13][2];
  471. for(new i = 0; i < 13; i++){
  472. GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
  473. if(SlotsWeapons(weaponid) == i && weapons[i][0] != weaponid)
  474. return true;
  475. }
  476. return false;
  477. }
  478.  
  479. FUNCTION ReturnModelWeapon(modelid)
  480. {
  481. new idweapon = 0;
  482. switch(modelid){
  483. // ID DAS ARMAS EM OBJETO
  484. case 1: idweapon = 331;
  485. case 2: idweapon = 333;
  486. case 3: idweapon = 334;
  487. case 4: idweapon = 335;
  488. case 5: idweapon = 336;
  489. case 6: idweapon = 337;
  490. case 7: idweapon = 338;
  491. case 8: idweapon = 339;
  492. case 9: idweapon = 341;
  493. case 10: idweapon = 321;
  494. case 14: idweapon = 325;
  495. case 15: idweapon = 326;
  496. case 16: idweapon = 342;
  497. case 17: idweapon = 343;
  498. case 18: idweapon = 344;
  499. case 22: idweapon = 346;
  500. case 23: idweapon = 347;
  501. case 24: idweapon = 348;
  502. case 25: idweapon = 349;
  503. case 26: idweapon = 350;
  504. case 27: idweapon = 351;
  505. case 28: idweapon = 352;
  506. case 29: idweapon = 353;
  507. case 30: idweapon = 355;
  508. case 31: idweapon = 356;
  509. case 32: idweapon = 372;
  510. case 33: idweapon = 357;
  511. case 34: idweapon = 358;
  512. case 35: idweapon = 359;
  513. case 36: idweapon = 360;
  514. case 37: idweapon = 361;
  515. case 38: idweapon = 362;
  516. case 39: idweapon = 363;
  517. case 40: idweapon = 364;
  518. case 41: idweapon = 365;
  519. case 42: idweapon = 366;
  520. case 43: idweapon = 367;
  521. case 44: idweapon = 368;
  522. case 45: idweapon = 369;
  523. case 46: idweapon = 371;
  524. default: idweapon = 9088;
  525. }
  526. return idweapon;
  527. }
  528.  
  529. FUNCTION SlotsWeapons(armaid){
  530. new slot;
  531. switch(armaid){
  532. case 0..1: slot = 0; // FIST
  533. case 2..9: slot = 1; // ARMA BRANCA
  534. case 10..15: slot = 10; // ARMAS SLAOQ
  535. case 16..18, 39: slot = 8; // EXPLOSIVOS
  536. case 22..24: slot = 2; // PISTOLAS
  537. case 25..27: slot = 3; // DOZES
  538. case 28..29, 32: slot = 4; // SUBS
  539. case 30..31: slot = 5; // FUZIS
  540. case 33..34: slot = 6; // SNIPERS
  541. case 35..38: slot = 7; // BAZUCAS
  542. case 40: slot = 12; // DETONADOR
  543. case 41..43: slot = 9; // SLAS
  544. case 44..46: slot = 11; // VISÃO
  545. }
  546. return slot;
  547. }
  548.  
  549. FUNCTION ReturnAnimationReload(playerid, weaponid){
  550. switch(weaponid){
  551. case 22:
  552. ApplyAnimation(playerid, "COLT45", "COLT45_RELOAD", 4.1, false, false, 1, false, 0, false);
  553. case 23:
  554. ApplyAnimation(playerid, "SILENCED", "SILENCE_RELOAD", 4.1, false, false, 1, false, 0, false);
  555. case 24:
  556. ApplyAnimation(playerid, "PYTHON", "PYTHON_RELOAD", 4.1, false, false, 1, false, 0, false);
  557. case 25:
  558. ApplyAnimation(playerid, "SHOTGUN", "SHOTGUN_FIRE_POOR", 4.1, false, false, 1, false, 0, false);
  559. case 26:
  560. ApplyAnimation(playerid, "COLT45", "SAWNOFF_RELOAD", 4.1, false, false, 1, false, 0, false);
  561. case 27:
  562. ApplyAnimation(playerid, "BUDDY", "buddy_reload", 4.1, false, false, 1, false, 0, false);
  563. case 29, 30, 31, 33, 34, 38:
  564. ApplyAnimation(playerid, "RIFLE", "RIFLE_LOAD", 4.1, false, false, 1, false, 0, false);
  565. case 28:
  566. ApplyAnimation(playerid, "UZI", "UZI_RELOAD", 4.1, false, false, 1, false, 0, false);
  567. case 32:
  568. ApplyAnimation(playerid, "TEC", "TEC_RELOAD", 4.1, false, false, 1, false, 0, false);
  569. }
  570. }
  571.  
  572. FUNCTION ReturnWeaponLimitAmmo(weaponid){
  573. new limit = 0;
  574. switch(weaponid){
  575. case 0..1, 25, 44..46: limit = 1;
  576. case 16..18, 28, 32, 35..37, 39, 40..43: limit = FINITO;
  577. case 22: limit = 34;
  578. case 23: limit = 17;
  579. case 24, 27: limit = 7;
  580. case 26: limit = 4;
  581. case 31: limit = 50;
  582. case 29, 30: limit = 30;
  583. case 33, 34: limit = 10;
  584. case 38: limit = 500;
  585. default: limit = 1;
  586. }
  587. return limit;
  588. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement