Guest User

GYM SYSTEM

a guest
Apr 6th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.55 KB | None | 0 0
  1. #include <a_samp>
  2. #include <progress>
  3.  
  4. //DEFINES ______________________
  5. #define BENCH_PRESS_INDEX (1)
  6. #define VER_IN "0.143 beta"
  7. #define BUILD_TM "29.03.2013"
  8. //Location & data
  9. //RUNNY MACHINE
  10.  
  11.  
  12.  
  13. stock static Float:
  14. run_machine_pos[ ][ ] =
  15. {
  16. { 773.4922, -2.6016,1000.7209 ,180.00000 }, // Los Santos Gym's bench.
  17. { 759.6328, -48.1250, 1000.7209,180.00000}, // San Fierro Gym's bench.
  18. { 758.3828, -65.5078, 1000.7209,180.00000} // Las Venturas Gym's bench
  19. };
  20. //BIKE
  21. stock static Float:
  22. bike_pos[ ][ ] =
  23. {
  24. {772.172,9.41406,1000.0,90.0}, // Los Santos Gym's Bake
  25. {769.242,-47.8984,1000.0,90.0}, // San Fierro Gym's Bake
  26. {774.625,-68.6406,1000.0,90.0} // Las Venturas Gym's Bake
  27. };
  28.  
  29. //Bench
  30. stock static Float:
  31. bench_pos[ ][ ] =
  32. {
  33. { 773.0491,1.4285,1000.7209, 269.2024 }, // Los Santos Gym's bench.
  34. { 766.3170,-47.3574,1000.5859, 179.2983 }, // San Fierro Gym's bench.
  35. { 764.9001,-60.5580,1000.6563, 1.9500 } // Las Venturas Gym's bench
  36. };
  37. stock static Float:
  38. barbell_pos[ ][ ] =
  39. {
  40. { 774.42907715,1.88309872,1000.48834229,0.00000000,270.00000000,87.99966431 }, // Los Santos Gym's BarBell
  41. { 765.85528564,-48.86857224,1000.64093018,0.00000000,89.49993896,0.00000000 }, // San Fierro Gym's BarBell.
  42. { 765.34039307,-59.18271637,1000.63793945,0.00000000,89.49993896,181.25012207 } // Las Venturas Gym's BarBell
  43. };
  44.  
  45. //Advanced Parts
  46. stock static Float:
  47. dumb_pos[ ][ ] =
  48. {
  49. {772.992,5.38281,999.727,270.0}, // Los Santos Gym's dumb
  50. {756.406,-47.9219,999.727,90.0}, // San Fierro Gym's dumb.
  51. {759.18,-60.0625,999.727,90.0} // Las Venturas Gym's dumb
  52. };
  53.  
  54. stock static Float:
  55. dumb_bell_right_pos[ ][ ] =
  56. {
  57. {772.992,5.18281,999.927,0.0,90.0,90.0} // Los Santos Gym's dumb right
  58. // {759.18,-60.0625,999.727,90} // Las Venturas Gym's dumb
  59. };
  60.  
  61. stock static Float:
  62. dumb_bell_left_pos[ ][ ] =
  63. {
  64. {772.992,5.62738,999.927,0.0,90.0,90.0} // Los Santos Gym's dumb left
  65. // {759.18,-60.0625,999.727,90} // Las Venturas Gym's dumb
  66. };
  67.  
  68.  
  69.  
  70. //BOOLS
  71. //____TREAM
  72. new bool:TREAM_IN_USE[sizeof run_machine_pos]=false;
  73. new PLAYER_CURRECT_TREAD[MAX_PLAYERS],
  74. bool:PLAYER_INTREAM[MAX_PLAYERS]=false;
  75. //____BIKE___
  76. new bool:BIKE_IN_USE[sizeof bike_pos]=false;
  77. new PLAYER_CURRECT_BIKE[MAX_PLAYERS],
  78. bool:PLAYER_INBIKE[MAX_PLAYERS]=false;
  79. //___BENCH___
  80. new bool:BENCH_IN_USE[sizeof bench_pos]=false;
  81. new PLAYER_CURRECT_BENCH[MAX_PLAYERS],
  82. bool:PLAYER_INBENCH[MAX_PLAYERS]=false;
  83. //___DUMB_BELL___
  84. new bool:DUMB_IN_USE[sizeof bench_pos]=false;
  85. new PLAYER_CURRECT_DUMB[MAX_PLAYERS],
  86. bool:PLAYER_INDUMB[MAX_PLAYERS]=false;
  87.  
  88. //Gobale
  89. new bool:BAR_CAN_BE_USED[MAX_PLAYERS]=false;
  90. new barbell_objects[sizeof barbell_pos];
  91. new dumbell_right_objects[sizeof dumb_bell_right_pos];
  92. new dumbell_left_objects[sizeof dumb_bell_left_pos];
  93. //TEXTDRAWS
  94. new Bar:player_gym_progress[MAX_PLAYERS];
  95. new Text:gym_power[ MAX_PLAYERS ];
  96. new Text:gym_des[MAX_PLAYERS];
  97. new Text:gym_deslabel[MAX_PLAYERS];
  98. new Text:gym_repslabel[MAX_PLAYERS];
  99. //TIMERS
  100. //________TREAD____________________
  101. new PLAYER_TREAD_TIMER[MAX_PLAYERS];
  102. //________BIKE_____________________
  103. new PLAYER_BIKE_TIMER[MAX_PLAYERS];
  104. //________BENCH____________________
  105. new PLAYER_BENCH_TIMER[MAX_PLAYERS];
  106. //________DUMB_BELL_____________
  107. new PLAYER_DUMB_TIMER[MAX_PLAYERS];
  108.  
  109. //VALUES
  110. //________TREAD____________________
  111. new PLAYER_TREAM_DIS_COUNT[MAX_PLAYERS];
  112. //________BIKE_____________________
  113. new PLAYER_BIKE_DIS_COUNT[MAX_PLAYERS];
  114. //_______BENCH___________________
  115. new PLAYER_BENCH_COUNT[MAX_PLAYERS];
  116. //________DUMB_BELL_____________
  117. new PLAYER_DUMB_COUNT[MAX_PLAYERS];
  118.  
  119. public OnPlayerConnect( playerid )
  120. {
  121.  
  122. // ApplyAnimation( playerid, "GYMNASIUM", "null", 1, 0, 0, 0, 1, 0, 1 );
  123. player_gym_progress[playerid]=CreateProgressBar( 550.000000, 166.000000, .color = 0x00F900FF );
  124.  
  125. gym_power[ playerid ] = TextDrawCreate(426.000000, 158.000000, "POWER:");
  126. TextDrawBackgroundColor(gym_power[ playerid ], 255);
  127. TextDrawFont(gym_power[ playerid ], 2);
  128. TextDrawLetterSize(gym_power[ playerid ], 0.400000, 1.800000);
  129. TextDrawColor(gym_power[ playerid ], -1);
  130. TextDrawSetOutline(gym_power[ playerid ], 0);
  131. TextDrawSetProportional(gym_power[ playerid ], 1);
  132. TextDrawSetShadow(gym_power[ playerid ], 1);
  133.  
  134. gym_des[ playerid ] = TextDrawCreate(426.000000, 203.000000, "DISTANCE:");
  135. TextDrawBackgroundColor(gym_des[ playerid ], 255);
  136. TextDrawFont(gym_des[ playerid ], 2);
  137. TextDrawLetterSize(gym_des[ playerid ], 0.509999, 1.800000);
  138. TextDrawColor(gym_des[ playerid ], -1);
  139. TextDrawSetOutline(gym_des[ playerid ], 0);
  140. TextDrawSetProportional(gym_des[ playerid ], 1);
  141. TextDrawSetShadow(gym_des[ playerid ], 1);
  142.  
  143. gym_repslabel[ playerid ] = TextDrawCreate(426.000000, 203.000000, "REPS:");
  144. TextDrawBackgroundColor(gym_repslabel[ playerid ], 255);
  145. TextDrawFont(gym_repslabel[ playerid ], 2);
  146. TextDrawLetterSize(gym_repslabel[ playerid ], 0.509999, 1.800000);
  147. TextDrawColor(gym_repslabel[ playerid ], -1);
  148. TextDrawSetOutline(gym_repslabel[ playerid ], 0);
  149. TextDrawSetProportional(gym_repslabel[ playerid ], 1);
  150. TextDrawSetShadow(gym_repslabel[ playerid ], 1);
  151.  
  152.  
  153.  
  154. gym_deslabel[ playerid ] = TextDrawCreate(557.000000, 203.000000, "0");
  155. TextDrawBackgroundColor(gym_deslabel[ playerid ], 255);
  156. TextDrawFont(gym_deslabel[ playerid ], 2);
  157. TextDrawLetterSize(gym_deslabel[ playerid ], 0.509999, 1.800000);
  158. TextDrawColor(gym_deslabel[ playerid ], -1);
  159. TextDrawSetOutline(gym_deslabel[ playerid ], 0);
  160. TextDrawSetProportional(gym_deslabel[ playerid ], 1);
  161. TextDrawSetShadow(gym_deslabel[ playerid ], 1);
  162.  
  163.  
  164.  
  165.  
  166. return true;
  167. }
  168.  
  169. public OnFilterScriptInit()
  170. {
  171. print("\n_______[GYM SYSTEM]_________");
  172.  
  173. print("[VERSION]: "VER_IN"\t[BUILD TIME]: "BUILD_TM"");
  174. print("[PROGRAM BY]: EPISODES (KEN CAI) 2013");
  175. print("______________________________\n");
  176. for( new o; o != sizeof barbell_pos; ++ o )
  177. {
  178. barbell_objects[o] = CreateObject( 2913, barbell_pos[ o ][ 0 ], barbell_pos[ o ][ 1 ], barbell_pos[ o ][ 2 ], barbell_pos[ o ][ 3 ], barbell_pos[ o ][ 4 ], barbell_pos[ o ][ 5 ] );
  179. dumbell_right_objects[o] = CreateObject(3071,dumb_bell_right_pos[o][0],dumb_bell_right_pos[o][1],dumb_bell_right_pos[o][2],dumb_bell_right_pos[o][3],dumb_bell_right_pos[o][4],dumb_bell_right_pos[o][5]);
  180. dumbell_left_objects[o] = CreateObject(3072,dumb_bell_left_pos[o][0],dumb_bell_left_pos[o][1],dumb_bell_left_pos[o][2],dumb_bell_left_pos[o][3],dumb_bell_left_pos[o][4],dumb_bell_left_pos[o][5]);
  181. }
  182.  
  183. }
  184.  
  185. public OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
  186. {
  187.  
  188. if ( ( newkeys & KEY_SECONDARY_ATTACK ) && !( oldkeys & KEY_SECONDARY_ATTACK ) )
  189. {
  190. if(PLAYER_INTREAM[playerid]==true && BAR_CAN_BE_USED[playerid]==true)
  191. {
  192. KillTimer(PLAYER_TREAD_TIMER[playerid]);
  193. GetOffTread(playerid);
  194. }
  195.  
  196. if(PLAYER_INBIKE[playerid]==true && BAR_CAN_BE_USED[playerid]==true)
  197. {
  198. KillTimer(PLAYER_BIKE_TIMER[playerid]);
  199. GetOffBIKE(playerid);
  200. }
  201.  
  202. if(PLAYER_INBENCH[playerid]==true && BAR_CAN_BE_USED[playerid]==true)
  203. {
  204. KillTimer(PLAYER_BENCH_TIMER[playerid]);
  205. GetOffBENCH(playerid);
  206.  
  207. }
  208.  
  209. if(PLAYER_INDUMB[playerid]==true && BAR_CAN_BE_USED[playerid]==true)
  210. {
  211. KillTimer(PLAYER_DUMB_TIMER[playerid]);
  212. PutDownDUMB(playerid);
  213.  
  214. }
  215.  
  216. }
  217.  
  218.  
  219. if ( ( newkeys & KEY_SECONDARY_ATTACK ) && !( oldkeys & KEY_SECONDARY_ATTACK ))
  220. {
  221. for( new o; o != sizeof run_machine_pos; o ++ )
  222. {
  223. if( IsPlayerInRangeOfPoint( playerid, 2.0, run_machine_pos[ o ][ 0 ], run_machine_pos[ o ][ 1 ], run_machine_pos[ o ][ 2 ] ) )
  224. {
  225. if(TREAM_IN_USE[o]==false && PLAYER_INTREAM[playerid]==false)
  226. {
  227. //bool
  228. PLAYER_INTREAM[playerid]=true;
  229. TREAM_IN_USE[o]=true;
  230. PLAYER_CURRECT_TREAD[playerid]=o;
  231. //clearn values
  232. PLAYER_TREAM_DIS_COUNT[playerid]=0;
  233. //Set Player Pos
  234. SetPlayerPos( playerid, run_machine_pos[ o ][ 0 ], run_machine_pos[ o ][ 1 ]+1.3, run_machine_pos[ o ][ 2 ] );
  235. SetPlayerFacingAngle( playerid, run_machine_pos[ o ][ 3 ] );
  236. TogglePlayerControllable( playerid, 0 );//Disable Control
  237. ApplyAnimation( playerid, "GYMNASIUM", "gym_tread_geton", 1, 0, 0, 0, 1, 0, 1 );
  238. SetTimerEx( "TREAM_START", 2000, false, "ii", playerid);
  239.  
  240. //SETVALUES
  241. SetProgressBarValue(player_gym_progress[playerid],50);
  242.  
  243. //Set Camera pos
  244. SetPlayerCameraPos( playerid, run_machine_pos[ o ][ 0 ] +2, run_machine_pos[ o ][ 1 ] -2, run_machine_pos[ o ][ 2 ] + 0.5 );
  245. SetPlayerCameraLookAt( playerid, run_machine_pos[ o ][ 0 ], run_machine_pos[ o ][ 1 ], run_machine_pos[ o ][ 2 ]);
  246.  
  247. }else{
  248. GameTextForPlayer(playerid,"Sorry This Machine is currectly in used", 5000, 4);
  249. }
  250.  
  251.  
  252. }
  253.  
  254. }
  255.  
  256. for( new b; b != sizeof bike_pos; b ++ )
  257. {
  258. if( IsPlayerInRangeOfPoint( playerid, 2.0, bike_pos[ b ][ 0 ], bike_pos[ b ][ 1 ], bike_pos[ b ][ 2 ] ) )
  259. {
  260. if(BIKE_IN_USE[b]==false && PLAYER_INBIKE[playerid]==false)
  261. {
  262. //Bool Here
  263. BIKE_IN_USE[b]=true;
  264. PLAYER_INBIKE[playerid]=true;
  265. PLAYER_CURRECT_BIKE[playerid]=b;
  266. //clearn values
  267. PLAYER_BIKE_DIS_COUNT[playerid]=0;
  268. //SETVALUES
  269. SetProgressBarValue(player_gym_progress[playerid],0);
  270.  
  271. //SetPlayerPos
  272. SetPlayerPos( playerid, bike_pos[ b ][ 0 ]+0.5, bike_pos[ b ][ 1 ]-0.5, bike_pos[ b ][ 2 ] );
  273. SetPlayerFacingAngle( playerid, bike_pos[ b ][ 3 ] );
  274. TogglePlayerControllable( playerid, 0 );
  275. ApplyAnimation( playerid, "GYMNASIUM", "gym_bike_geton", 1, 0, 0, 0, 1, 0, 1 );
  276. //Set Timer
  277. SetTimerEx( "BIKE_START", 2000, false, "i", playerid);
  278. //SetCaremaPos
  279. SetPlayerCameraPos( playerid, bike_pos[ b ][ 0 ] +2, bike_pos[ b ][ 1 ] -2, bike_pos[ b ][ 2 ] + 0.5 );
  280. SetPlayerCameraLookAt( playerid, bike_pos[ b ][ 0 ], bike_pos[ b ][ 1 ], bike_pos[ b ][ 2 ]+0.5);
  281.  
  282. }else{
  283. GameTextForPlayer(playerid,"Sorry This Machine is currectly in used", 5000, 4);
  284. }
  285.  
  286. }
  287.  
  288. }
  289. for (new g; g != sizeof bench_pos; g ++)
  290. {
  291. if( IsPlayerInRangeOfPoint( playerid, 2.0, bench_pos[ g ][ 0 ], bench_pos[ g ][ 1 ], bench_pos[ g ][ 2 ] ) )
  292. {
  293. if(BENCH_IN_USE[g]==false && PLAYER_INBENCH[playerid]==false)
  294. {
  295. BENCH_IN_USE[g]=true;
  296. PLAYER_INBENCH[playerid]=true;
  297. PLAYER_CURRECT_BENCH[playerid]=g;
  298. //clearn values
  299. PLAYER_BENCH_COUNT[playerid]=0;
  300. //SETVALUES
  301. SetProgressBarValue(player_gym_progress[playerid],0);
  302. //SET POS NOW
  303. TogglePlayerControllable( playerid, 0 );
  304. SetPlayerPos( playerid, bench_pos[ g ][ 0 ], bench_pos[ g ][ 1 ], bench_pos[ g ][ 2 ] );
  305. SetPlayerFacingAngle( playerid, bench_pos[ g ][ 3 ] );
  306. ApplyAnimation( playerid, "benchpress", "gym_bp_geton", 1, 0, 0, 0, 1, 0, 1 );
  307.  
  308. SetTimerEx( "BENCH_START", 3800, 0, "ii", playerid,g);
  309. SetPlayerCameraPos( playerid, bench_pos[ g ][ 0 ]-1.5, bench_pos[ g ][ 1 ]+1.5, bench_pos[ g ][ 2 ] + 0.5 );
  310. SetPlayerCameraLookAt( playerid, bench_pos[ g ][ 0 ], bench_pos[ g ][ 1 ], bench_pos[ g ][ 2 ]);
  311.  
  312.  
  313. }else{
  314. GameTextForPlayer(playerid,"Sorry This Machine is currectly in used", 5000, 4);
  315. }
  316.  
  317.  
  318.  
  319. }
  320.  
  321. }
  322.  
  323. for (new d; d != sizeof dumb_pos; d ++)
  324. {
  325. if( IsPlayerInRangeOfPoint( playerid, 2.0, dumb_pos[ d ][ 0 ], dumb_pos[ d ][ 1 ], dumb_pos[ d ][ 2 ] ) )
  326. {
  327. if(DUMB_IN_USE[d]==false && PLAYER_INDUMB[playerid]==false)
  328. {
  329. DUMB_IN_USE[d]=true;
  330. PLAYER_INDUMB[playerid]=true;
  331. PLAYER_CURRECT_DUMB[playerid]=d;
  332. //clearn values
  333. PLAYER_DUMB_COUNT[playerid]=0;
  334. SetProgressBarValue(player_gym_progress[playerid],0);
  335.  
  336. //SET POS NOW
  337. TogglePlayerControllable( playerid, 0 );
  338. SetPlayerPos( playerid, dumb_pos[ d ][ 0 ]-1, dumb_pos[ d ][ 1 ], dumb_pos[ d ][ 2 ] +1);
  339. SetPlayerFacingAngle( playerid, dumb_pos[ d ][ 3 ] );
  340. ApplyAnimation( playerid, "Freeweights", "gym_free_pickup", 1, 0, 0, 0, 1, 0, 1 );
  341.  
  342. SetTimerEx( "DUMB_START", 2500, 0, "ii", playerid);
  343.  
  344. SetPlayerCameraPos( playerid, dumb_pos[ d ][ 0 ]+2.3, dumb_pos[ d ][ 1 ], dumb_pos[ d ][ 2 ]+0.3 );
  345. SetPlayerCameraLookAt( playerid, dumb_pos[ d ][ 0 ], dumb_pos[ d ][ 1 ], dumb_pos[ d ][ 2 ]+0.5);
  346. }
  347.  
  348. }
  349.  
  350. }
  351.  
  352.  
  353.  
  354. }
  355.  
  356. if ( ( newkeys & KEY_SPRINT ) && !( oldkeys & KEY_SPRINT ) )
  357. {
  358. if(PLAYER_INTREAM[playerid]==true && BAR_CAN_BE_USED[playerid]==true)
  359. {
  360. //Update Bar
  361. SetProgressBarValue( player_gym_progress[playerid], GetProgressBarValue( player_gym_progress[playerid] ) + 5 );
  362. UpdateProgressBar( player_gym_progress[playerid], playerid );
  363. //Anoynned Part
  364. new LocalLabel[10];
  365. PLAYER_TREAM_DIS_COUNT[playerid]++;
  366. format(LocalLabel,sizeof(LocalLabel),"%d",PLAYER_TREAM_DIS_COUNT[playerid]);
  367. TextDrawSetString(gym_deslabel[playerid],LocalLabel);
  368.  
  369.  
  370.  
  371. }
  372.  
  373. if(PLAYER_INBIKE[playerid]==true && BAR_CAN_BE_USED[playerid]==true)
  374. {
  375. SetProgressBarValue(player_gym_progress[playerid], GetProgressBarValue(player_gym_progress[playerid] ) + 5 );
  376. UpdateProgressBar( player_gym_progress[playerid], playerid );
  377. //Math Stuffs
  378. new LocalLabel[10];
  379. PLAYER_BIKE_DIS_COUNT[playerid]++;
  380. format(LocalLabel,sizeof(LocalLabel),"%d",PLAYER_BIKE_DIS_COUNT[playerid]);
  381. TextDrawSetString(gym_deslabel[playerid],LocalLabel);
  382.  
  383. }
  384.  
  385. //Do update player bench vaules here
  386. if(PLAYER_INBENCH[playerid]==true && BAR_CAN_BE_USED[playerid]==true)
  387. {
  388. SetProgressBarValue(player_gym_progress[playerid], GetProgressBarValue(player_gym_progress[playerid] ) + 5 );
  389. UpdateProgressBar( player_gym_progress[playerid], playerid );
  390.  
  391. }
  392.  
  393. if(PLAYER_INDUMB[playerid]==true && BAR_CAN_BE_USED[playerid]==true)
  394. {
  395. SetProgressBarValue(player_gym_progress[playerid], GetProgressBarValue(player_gym_progress[playerid] ) + 5 );
  396. UpdateProgressBar( player_gym_progress[playerid], playerid );
  397.  
  398. }
  399.  
  400. }
  401.  
  402. return 1;
  403. }
  404. forward DUMB_START(playerid);
  405. public DUMB_START(playerid)
  406. {
  407. BAR_CAN_BE_USED[playerid]=true;
  408. //SET ATATCH OBJECTS
  409. SetPlayerAttachedObject(playerid,1, 3072, 5);//left hand
  410. SetPlayerAttachedObject(playerid,2, 3071, 6);//right hand
  411.  
  412. DestroyObject(dumbell_right_objects[PLAYER_CURRECT_DUMB[playerid]]);
  413. DestroyObject(dumbell_left_objects[PLAYER_CURRECT_DUMB[playerid]]);
  414.  
  415. //SHOW PROGRESS BAR
  416. ShowProgressBarForPlayer( playerid,player_gym_progress[playerid]);
  417. TextDrawShowForPlayer( playerid, gym_power[ playerid ] );
  418. TextDrawShowForPlayer( playerid, gym_repslabel[ playerid ] );
  419. TextDrawShowForPlayer( playerid, gym_deslabel[ playerid ] );
  420. PLAYER_DUMB_TIMER[playerid]=SetTimerEx( "GYM_CHECK", 500,true,"i", playerid );
  421.  
  422.  
  423.  
  424. }
  425.  
  426. forward BIKE_START(playerid);
  427. public BIKE_START(playerid)
  428. {
  429. BAR_CAN_BE_USED[playerid]=true;
  430. ApplyAnimation( playerid, "GYMNASIUM", "bike_start", 1, 1, 0, 0, 1, 0, 1);
  431. //Show Progress Bar Now
  432. ShowProgressBarForPlayer( playerid,player_gym_progress[playerid]);
  433. TextDrawShowForPlayer( playerid, gym_power[ playerid ] );
  434. TextDrawShowForPlayer( playerid, gym_des[ playerid ] );
  435. TextDrawShowForPlayer( playerid, gym_deslabel[ playerid ] );
  436. //Created Second Timer For Check
  437. PLAYER_BIKE_TIMER[playerid]=SetTimerEx( "GYM_CHECK", 500, 1, "i", playerid );
  438.  
  439.  
  440.  
  441. }
  442. forward TREAM_START(playerid);
  443. public TREAM_START(playerid)
  444. {
  445.  
  446. BAR_CAN_BE_USED[playerid]=true;
  447. //Make Player Run
  448. ApplyAnimation( playerid, "GYMNASIUM", "gym_tread_sprint", 1, 1, 0, 0, 1, 0, 1);
  449. //Show Progress Bar Now
  450. ShowProgressBarForPlayer( playerid,player_gym_progress[playerid]);
  451. TextDrawShowForPlayer( playerid, gym_power[ playerid ] );
  452. TextDrawShowForPlayer( playerid, gym_des[ playerid ] );
  453. TextDrawShowForPlayer( playerid, gym_deslabel[ playerid ] );
  454. //Created Second Timer For Check
  455. PLAYER_TREAD_TIMER[playerid]=SetTimerEx( "GYM_CHECK", 500, 1, "i", playerid );
  456.  
  457. }
  458. forward BENCH_START(playerid,OBJ_INDEX);
  459. public BENCH_START(playerid,OBJ_INDEX)
  460. {
  461. BAR_CAN_BE_USED[playerid]=true;
  462. //SET ATATCH OBJECTS
  463. SetPlayerAttachedObject(playerid, BENCH_PRESS_INDEX, 2913, 6);
  464. DestroyObject(barbell_objects[OBJ_INDEX]);
  465. //SHOW PROGRESS BAR
  466. ShowProgressBarForPlayer( playerid,player_gym_progress[playerid]);
  467. TextDrawShowForPlayer( playerid, gym_power[ playerid ] );
  468. TextDrawShowForPlayer( playerid, gym_repslabel[ playerid ] );
  469. TextDrawShowForPlayer( playerid, gym_deslabel[ playerid ] );
  470. PLAYER_BENCH_TIMER[playerid]=SetTimerEx( "GYM_CHECK", 500,true,"i", playerid );
  471.  
  472. }
  473.  
  474. forward GYM_CHECK(playerid);
  475.  
  476. public GYM_CHECK(playerid)
  477. {
  478. if(PLAYER_INTREAM[playerid]==true)
  479. {
  480. TREAM_CHECK(playerid);
  481.  
  482. }
  483.  
  484. if(PLAYER_INBIKE[playerid]==true)
  485. {
  486. BIKE_CHECK(playerid);
  487.  
  488. }
  489.  
  490. if(PLAYER_INBENCH[playerid]==true)
  491. {
  492. BENCH_CHECK(playerid);
  493.  
  494. }
  495. if(PLAYER_INDUMB[playerid]==true)
  496. {
  497. DUMB_CHECK(playerid);
  498.  
  499. }
  500.  
  501. }
  502. DUMB_CHECK(playerid)
  503. {
  504. SetProgressBarValue( player_gym_progress[playerid], GetProgressBarValue( player_gym_progress[playerid] ) - 2 );
  505. UpdateProgressBar( player_gym_progress[playerid], playerid );
  506.  
  507. if(GetProgressBarValue( player_gym_progress[playerid] ) >=90)
  508. {
  509.  
  510. //random select a amation for player
  511. switch( random( 2 ) )
  512. {
  513. case 0: ApplyAnimation( playerid, "freeweights", "gym_free_A", 1, 0, 0, 0, 1, 0, 1 );
  514. case 1: ApplyAnimation( playerid, "freeweights", "gym_free_B", 1, 0, 0, 0, 1, 0, 1 );
  515. }
  516. new LocalLabel[10];
  517. PLAYER_DUMB_COUNT[playerid]++;
  518. format(LocalLabel,sizeof(LocalLabel),"%d",PLAYER_DUMB_COUNT[playerid]);
  519. TextDrawSetString(gym_deslabel[playerid],LocalLabel);
  520.  
  521. SetProgressBarValue(player_gym_progress[playerid],0);
  522. SetTimerEx( "DUMB_SET_AIMSTOP",2000, false, "i", playerid);
  523.  
  524.  
  525. }
  526.  
  527. }
  528. BENCH_CHECK(playerid)
  529. {
  530. SetProgressBarValue( player_gym_progress[playerid], GetProgressBarValue( player_gym_progress[playerid] ) - 2 );
  531. UpdateProgressBar( player_gym_progress[playerid], playerid );
  532.  
  533. if(GetProgressBarValue( player_gym_progress[playerid] ) >=90)
  534. {
  535.  
  536. //random select a amation for player
  537. switch( random( 2 ) )
  538. {
  539. case 0: ApplyAnimation( playerid, "benchpress", "gym_bp_up_A", 1, 0, 0, 0, 1, 0, 1 );
  540. case 1: ApplyAnimation( playerid, "benchpress", "gym_bp_up_B", 1, 0, 0, 0, 1, 0, 1 );
  541. }
  542. new LocalLabel[10];
  543. PLAYER_BENCH_COUNT[playerid]++;
  544. format(LocalLabel,sizeof(LocalLabel),"%d",PLAYER_BENCH_COUNT[playerid]);
  545. TextDrawSetString(gym_deslabel[playerid],LocalLabel);
  546.  
  547. SetProgressBarValue(player_gym_progress[playerid],0);
  548. SetTimerEx( "BENCH_SET_AIMSTOP",2000, false, "i", playerid);
  549.  
  550.  
  551. }
  552.  
  553. }
  554.  
  555. forward DUMB_SET_AIMSTOP(playerid);
  556. public DUMB_SET_AIMSTOP(playerid)
  557. {
  558. //Apply Player pull down aim
  559. ApplyAnimation( playerid, "freeweights", "gym_free_down", 1, 0, 0, 0, 1, 0, 1 );
  560. //Reset the progress bar values
  561. UpdateProgressBar(player_gym_progress[playerid],playerid);
  562.  
  563. }
  564.  
  565. forward BENCH_SET_AIMSTOP(playerid);
  566. public BENCH_SET_AIMSTOP(playerid)
  567. {
  568. //Apply Player pull down aim
  569. ApplyAnimation( playerid, "benchpress", "gym_bp_down", 1, 0, 0, 0, 1, 0, 1 );
  570. //Reset the progress bar values
  571.  
  572. UpdateProgressBar(player_gym_progress[playerid],playerid);
  573.  
  574. }
  575.  
  576. BIKE_CHECK(playerid)
  577. {
  578. SetProgressBarValue( player_gym_progress[playerid], GetProgressBarValue( player_gym_progress[playerid] ) - 8 );
  579. UpdateProgressBar( player_gym_progress[playerid], playerid );
  580. //ApplyAnimation( playerid, "GYMNASIUM", "gym_bike_fast", 1, 0, 0, 0, 1, 0, 1 );
  581.  
  582. if(GetProgressBarValue( player_gym_progress[playerid] ) <=0)
  583. {
  584. ApplyAnimation( playerid, "GYMNASIUM", "gym_bike_still", 1, 1, 0, 0, 1, 0, 1);
  585. }else{
  586. ApplyAnimation( playerid, "GYMNASIUM", "gym_bike_fast", 1, 1, 0, 0, 1, 0, 1 );
  587. }
  588. //SetProgressBarValue( player_bike_progress[playerid],50);
  589.  
  590.  
  591. }
  592. TREAM_CHECK(playerid)
  593. {
  594. SetProgressBarValue( player_gym_progress[playerid], GetProgressBarValue( player_gym_progress[playerid] ) - 8 );
  595. UpdateProgressBar( player_gym_progress[playerid], playerid );
  596. //Check If Player Gonna Fall
  597. if(GetProgressBarValue( player_gym_progress[playerid] ) <=0)
  598. {
  599. KillTimer(PLAYER_TREAD_TIMER[playerid]);
  600. //then we can use our custom function
  601. FallOffTread(playerid);
  602.  
  603.  
  604. }
  605.  
  606. }
  607.  
  608. FallOffTread(playerid)
  609. {
  610.  
  611. //Disabled Bar
  612. BAR_CAN_BE_USED[playerid]=false;
  613. //This one is for when player fall off the machine (when power < 0)
  614. ApplyAnimation( playerid, "GYMNASIUM", "gym_tread_falloff", 1, 0, 0, 0, 1, 0, 1 );
  615. //Hide textdraw
  616. HideProgressBarForPlayer( playerid,player_gym_progress[playerid]);
  617. TextDrawHideForPlayer( playerid, gym_power[ playerid ] );
  618. TextDrawHideForPlayer( playerid, gym_des[ playerid ] );
  619. TextDrawHideForPlayer( playerid, gym_deslabel[ playerid ] );
  620. SetTimerEx( "REST_PLAYER", 2000, false, "i", playerid);
  621.  
  622.  
  623.  
  624. }
  625. GetOffTread(playerid)
  626. {
  627.  
  628. BAR_CAN_BE_USED[playerid]=false;
  629. ApplyAnimation( playerid, "GYMNASIUM", "gym_tread_getoff", 1, 0, 0, 0, 1, 0, 1 );
  630. HideProgressBarForPlayer( playerid,player_gym_progress[playerid]);
  631. TextDrawHideForPlayer( playerid, gym_power[ playerid ] );
  632. TextDrawHideForPlayer( playerid, gym_des[ playerid ] );
  633. TextDrawHideForPlayer( playerid, gym_deslabel[ playerid ] );
  634.  
  635. SetTimerEx( "REST_PLAYER", 3500, false, "i", playerid);
  636.  
  637.  
  638. }
  639.  
  640. GetOffBENCH(playerid)
  641. {
  642. BAR_CAN_BE_USED[playerid]=false;
  643. ApplyAnimation(playerid, "benchpress", "gym_bp_getoff", 1, 0, 0, 0, 1, 0, 1 );
  644. HideProgressBarForPlayer( playerid,player_gym_progress[playerid]);
  645. //Do something here....
  646. TextDrawHideForPlayer( playerid, gym_power[ playerid ] );
  647. TextDrawHideForPlayer( playerid, gym_repslabel[ playerid ] );
  648. TextDrawHideForPlayer( playerid, gym_deslabel[ playerid ] );
  649. SetTimerEx( "REST_PLAYER", 5000, false, "i", playerid);
  650.  
  651. }
  652.  
  653. PutDownDUMB(playerid)
  654. {
  655. BAR_CAN_BE_USED[playerid]=false;
  656. ApplyAnimation(playerid, "freeweights", "gym_free_putdown", 1, 0, 0, 0, 1, 0, 1 );
  657. HideProgressBarForPlayer( playerid,player_gym_progress[playerid]);
  658. //Do something here....
  659. TextDrawHideForPlayer( playerid, gym_power[ playerid ] );
  660. TextDrawHideForPlayer( playerid, gym_repslabel[ playerid ] );
  661. TextDrawHideForPlayer( playerid, gym_deslabel[ playerid ] );
  662. SetTimerEx( "REST_PLAYER",3000, false, "i", playerid);
  663.  
  664. }
  665. GetOffBIKE(playerid)
  666. {
  667. BAR_CAN_BE_USED[playerid]=false;
  668. ApplyAnimation( playerid, "GYMNASIUM", "gym_bike_getoff", 1, 0, 0, 0, 1, 0, 1 );
  669. HideProgressBarForPlayer( playerid,player_gym_progress[playerid]);
  670. TextDrawHideForPlayer( playerid, gym_power[ playerid ] );
  671. TextDrawHideForPlayer( playerid, gym_des[ playerid ] );
  672. TextDrawHideForPlayer( playerid, gym_deslabel[ playerid ] );
  673. SetTimerEx( "REST_PLAYER", 2000, false, "i", playerid);
  674. }
  675.  
  676. forward REST_PLAYER(playerid);
  677. public REST_PLAYER(playerid)
  678. {
  679.  
  680. //Rest Staus
  681. ClearAnimations( playerid, 1 );
  682. SetCameraBehindPlayer( playerid );
  683. TogglePlayerControllable( playerid, 1 );
  684. BAR_CAN_BE_USED[playerid]=false;
  685. //Reset Bool
  686.  
  687. if(PLAYER_INTREAM[playerid]==true)
  688. {
  689. PLAYER_INTREAM[playerid]=false;
  690. TREAM_IN_USE[PLAYER_CURRECT_TREAD[playerid]]=false;
  691. }
  692. if(PLAYER_INBIKE[playerid]==true)
  693. {
  694. PLAYER_INBIKE[playerid]=false;
  695. BIKE_IN_USE[PLAYER_CURRECT_BIKE[playerid]]=false;
  696. }
  697. if(PLAYER_INBENCH[playerid]==true)
  698. {
  699. PLAYER_INBENCH[playerid]=false;
  700. BENCH_IN_USE[PLAYER_CURRECT_BENCH[playerid]]=false;
  701. barbell_objects[PLAYER_CURRECT_BENCH[playerid]] = CreateObject( 2913, barbell_pos[PLAYER_CURRECT_BENCH[playerid]][ 0 ], barbell_pos[PLAYER_CURRECT_BENCH[playerid]][ 1 ], barbell_pos[PLAYER_CURRECT_BENCH[playerid]][ 2 ], barbell_pos[PLAYER_CURRECT_BENCH[playerid]][ 3 ], barbell_pos[PLAYER_CURRECT_BENCH[playerid]][ 4 ], barbell_pos[PLAYER_CURRECT_BENCH[playerid]][ 5 ] );
  702. RemovePlayerAttachedObject( playerid, BENCH_PRESS_INDEX );
  703. }
  704.  
  705. if(PLAYER_INDUMB[playerid]==true)
  706. {
  707. PLAYER_INDUMB[playerid]=false;
  708. DUMB_IN_USE[PLAYER_CURRECT_DUMB[playerid]]=false;
  709. dumbell_right_objects[PLAYER_CURRECT_DUMB[playerid]] = CreateObject(3071,dumb_bell_right_pos[PLAYER_CURRECT_DUMB[playerid]][0],dumb_bell_right_pos[PLAYER_CURRECT_DUMB[playerid]][1],dumb_bell_right_pos[PLAYER_CURRECT_DUMB[playerid]][2],dumb_bell_right_pos[PLAYER_CURRECT_DUMB[playerid]][3],dumb_bell_right_pos[PLAYER_CURRECT_DUMB[playerid]][4],dumb_bell_right_pos[PLAYER_CURRECT_DUMB[playerid]][5]);
  710. dumbell_left_objects[PLAYER_CURRECT_DUMB[playerid]] = CreateObject(3072,dumb_bell_left_pos[PLAYER_CURRECT_DUMB[playerid]][0],dumb_bell_left_pos[PLAYER_CURRECT_DUMB[playerid]][1],dumb_bell_left_pos[PLAYER_CURRECT_DUMB[playerid]][2],dumb_bell_left_pos[PLAYER_CURRECT_DUMB[playerid]][3],dumb_bell_left_pos[PLAYER_CURRECT_DUMB[playerid]][4],dumb_bell_left_pos[PLAYER_CURRECT_DUMB[playerid]][5]);
  711. RemovePlayerAttachedObject( playerid,1);
  712. RemovePlayerAttachedObject( playerid,2);
  713. }
  714.  
  715. }
  716.  
  717. //ANTI DISCONNECT BUG
  718. public OnPlayerDisconnect(playerid, reason)
  719. {
  720. //Check if player disconnect wihout press F
  721. REST_PLAYER(playerid);
  722.  
  723. HideProgressBarForPlayer( playerid,player_gym_progress[playerid]);
  724. TextDrawHideForPlayer( playerid, gym_power[ playerid ] );
  725. TextDrawHideForPlayer( playerid, gym_des[ playerid ] );
  726. TextDrawHideForPlayer( playerid, gym_deslabel[ playerid ] );
  727. TextDrawHideForPlayer( playerid, gym_repslabel[ playerid ] );
  728. return 1;
  729. }
Add Comment
Please, Sign In to add comment