SAMP Gitlab CI Test
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

371 lines
11 KiB

5 years ago
  1. //-------------------------------------------------
  2. //
  3. // Generic Special Actions And Anims
  4. // kyeman 2007
  5. //
  6. //-------------------------------------------------
  7. #include <a_samp>
  8. #include <core>
  9. #include <float>
  10. #pragma tabsize 0
  11. #include "../include/gl_common.inc"
  12. new gPlayerUsingLoopingAnim[MAX_PLAYERS];
  13. new gPlayerAnimLibsPreloaded[MAX_PLAYERS];
  14. new Text:txtAnimHelper;
  15. //-------------------------------------------------
  16. OnePlayAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
  17. {
  18. ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp);
  19. }
  20. //-------------------------------------------------
  21. LoopingAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
  22. {
  23. gPlayerUsingLoopingAnim[playerid] = 1;
  24. ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp);
  25. TextDrawShowForPlayer(playerid,txtAnimHelper);
  26. }
  27. //-------------------------------------------------
  28. StopLoopingAnim(playerid)
  29. {
  30. gPlayerUsingLoopingAnim[playerid] = 0;
  31. ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0);
  32. }
  33. //-------------------------------------------------
  34. PreloadAnimLib(playerid, animlib[])
  35. {
  36. ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
  37. }
  38. //-------------------------------------------------
  39. // ********** CALLBACKS **********
  40. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  41. {
  42. if(!gPlayerUsingLoopingAnim[playerid]) return;
  43. if(IsKeyJustDown(KEY_SPRINT,newkeys,oldkeys)) {
  44. StopLoopingAnim(playerid);
  45. TextDrawHideForPlayer(playerid,txtAnimHelper);
  46. }
  47. }
  48. //------------------------------------------------
  49. public OnPlayerDeath(playerid, killerid, reason)
  50. {
  51. // if they die whilst performing a looping anim, we should reset the state
  52. if(gPlayerUsingLoopingAnim[playerid]) {
  53. gPlayerUsingLoopingAnim[playerid] = 0;
  54. TextDrawHideForPlayer(playerid,txtAnimHelper);
  55. }
  56. return 1;
  57. }
  58. //-------------------------------------------------
  59. public OnPlayerSpawn(playerid)
  60. {
  61. if(!gPlayerAnimLibsPreloaded[playerid]) {
  62. PreloadAnimLib(playerid,"BOMBER");
  63. PreloadAnimLib(playerid,"RAPPING");
  64. PreloadAnimLib(playerid,"SHOP");
  65. PreloadAnimLib(playerid,"BEACH");
  66. PreloadAnimLib(playerid,"SMOKING");
  67. PreloadAnimLib(playerid,"FOOD");
  68. PreloadAnimLib(playerid,"ON_LOOKERS");
  69. PreloadAnimLib(playerid,"DEALER");
  70. PreloadAnimLib(playerid,"CRACK");
  71. PreloadAnimLib(playerid,"CARRY");
  72. PreloadAnimLib(playerid,"COP_AMBIENT");
  73. PreloadAnimLib(playerid,"PARK");
  74. PreloadAnimLib(playerid,"INT_HOUSE");
  75. PreloadAnimLib(playerid,"FOOD");
  76. gPlayerAnimLibsPreloaded[playerid] = 1;
  77. }
  78. return 1;
  79. }
  80. //-------------------------------------------------
  81. public OnPlayerConnect(playerid)
  82. {
  83. gPlayerUsingLoopingAnim[playerid] = 0;
  84. gPlayerAnimLibsPreloaded[playerid] = 0;
  85. return 1;
  86. }
  87. //-------------------------------------------------
  88. public OnFilterScriptInit()
  89. {
  90. // Init our text display
  91. txtAnimHelper = TextDrawCreate(610.0, 400.0,
  92. "~r~~k~~PED_SPRINT~ ~w~to stop the animation");
  93. TextDrawUseBox(txtAnimHelper, 0);
  94. TextDrawFont(txtAnimHelper, 2);
  95. TextDrawSetShadow(txtAnimHelper,0); // no shadow
  96. TextDrawSetOutline(txtAnimHelper,1); // thickness 1
  97. TextDrawBackgroundColor(txtAnimHelper,0x000000FF);
  98. TextDrawColor(txtAnimHelper,0xFFFFFFFF);
  99. TextDrawAlignment(txtAnimHelper,3); // align right
  100. }
  101. //-------------------------------------------------
  102. public OnPlayerCommandText(playerid, cmdtext[])
  103. {
  104. new cmd[256];
  105. new idx;
  106. new dancestyle;
  107. cmd = strtok(cmdtext, idx);
  108. if(strcmp(cmd,"/animlist",true)==0)
  109. {
  110. SendClientMessage(playerid,0xAFAFAFAA,"Available Animations:");
  111. SendClientMessage(playerid,0xAFAFAFAA,"/handsup /drunk /bomb /getarrested /laugh /lookout /robman");
  112. SendClientMessage(playerid,0xAFAFAFAA,"/crossarms /lay /hide /vomit /eat /wave /taichi");
  113. SendClientMessage(playerid,0xAFAFAFAA,"/deal /crack /smokem /smokef /groundsit /chat /dance /f**ku");
  114. }
  115. if(strcmp(cmd, "/amcuffed", true) == 0) {
  116. // note: the cuffs have not been scaled for all player models
  117. SetPlayerAttachedObject(playerid,8,19418,6,-0.031999,0.024000,-0.024000,-7.900000,-32.000011,-72.299987,1.115998,1.322000,1.406000);
  118. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CUFFED);
  119. return 1;
  120. }
  121. if(strcmp(cmd, "/uncuffme", true) == 0) {
  122. if(IsPlayerAttachedObjectSlotUsed(playerid, 8)) {
  123. RemovePlayerAttachedObject(playerid, 8);
  124. }
  125. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
  126. return 1;
  127. }
  128. // We don't handle anything else after this that can be used in vehicles
  129. if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) {
  130. return 0;
  131. }
  132. // HANDSUP
  133. if(strcmp(cmd, "/handsup", true) == 0) {
  134. SetPlayerSpecialAction(playerid,SPECIAL_ACTION_HANDSUP);
  135. return 1;
  136. }
  137. // CELLPHONE IN
  138. if(strcmp(cmd, "/cellin", true) == 0) {
  139. SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USECELLPHONE);
  140. return 1;
  141. }
  142. // CELLPHONE OUT
  143. if(strcmp(cmd, "/cellout", true) == 0) {
  144. SetPlayerSpecialAction(playerid,SPECIAL_ACTION_STOPUSECELLPHONE);
  145. return 1;
  146. }
  147. // Drunk
  148. if(strcmp(cmd, "/drunk", true) == 0) {
  149. LoopingAnim(playerid,"PED","WALK_DRUNK",4.0,1,1,1,1,0);
  150. return 1;
  151. }
  152. // Place a Bomb
  153. if (strcmp("/bomb", cmdtext, true) == 0) {
  154. ClearAnimations(playerid);
  155. OnePlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0); // Place Bomb
  156. return 1;
  157. }
  158. // Police Arrest
  159. if (strcmp("/getarrested", cmdtext, true, 7) == 0) {
  160. LoopingAnim(playerid,"ped", "ARRESTgun", 4.0, 0, 1, 1, 1, -1); // Gun Arrest
  161. return 1;
  162. }
  163. // Laugh
  164. if (strcmp("/laugh", cmdtext, true) == 0) {
  165. OnePlayAnim(playerid, "RAPPING", "Laugh_01", 4.0, 0, 0, 0, 0, 0); // Laugh
  166. return 1;
  167. }
  168. // Rob Lookout
  169. if (strcmp("/lookout", cmdtext, true) == 0) {
  170. OnePlayAnim(playerid, "SHOP", "ROB_Shifty", 4.0, 0, 0, 0, 0, 0); // Rob Lookout
  171. return 1;
  172. }
  173. // Rob Threat
  174. if (strcmp("/robman", cmdtext, true) == 0) {
  175. LoopingAnim(playerid, "SHOP", "ROB_Loop_Threat", 4.0, 1, 0, 0, 0, 0); // Rob
  176. return 1;
  177. }
  178. // Arms crossed
  179. if (strcmp("/crossarms", cmdtext, true) == 0) {
  180. LoopingAnim(playerid, "COP_AMBIENT", "Coplook_loop", 4.0, 0, 1, 1, 1, -1); // Arms crossed
  181. return 1;
  182. }
  183. // Lay Down
  184. if (strcmp("/lay", cmdtext, true, 6) == 0) {
  185. LoopingAnim(playerid,"BEACH", "bather", 4.0, 1, 0, 0, 0, 0); // Lay down
  186. return 1;
  187. }
  188. // Take Cover
  189. if (strcmp("/hide", cmdtext, true, 3) == 0) {
  190. LoopingAnim(playerid, "ped", "cower", 3.0, 1, 0, 0, 0, 0); // Taking Cover
  191. return 1;
  192. }
  193. // Vomit
  194. if (strcmp("/vomit", cmdtext, true) == 0) {
  195. OnePlayAnim(playerid, "FOOD", "EAT_Vomit_P", 3.0, 0, 0, 0, 0, 0); // Vomit BAH!
  196. return 1;
  197. }
  198. // Eat Burger
  199. if (strcmp("/eat", cmdtext, true) == 0) {
  200. OnePlayAnim(playerid, "FOOD", "EAT_Burger", 3.0, 0, 0, 0, 0, 0); // Eat Burger
  201. return 1;
  202. }
  203. // Wave
  204. if (strcmp("/wave", cmdtext, true) == 0) {
  205. LoopingAnim(playerid, "ON_LOOKERS", "wave_loop", 4.0, 1, 0, 0, 0, 0); // Wave
  206. return 1;
  207. }
  208. // Slap Ass
  209. if (strcmp("/slapass", cmdtext, true) == 0) {
  210. OnePlayAnim(playerid, "SWEET", "sweet_ass_slap", 4.0, 0, 0, 0, 0, 0); // Ass Slapping
  211. return 1;
  212. }
  213. // Dealer
  214. if (strcmp("/deal", cmdtext, true) == 0) {
  215. OnePlayAnim(playerid, "DEALER", "DEALER_DEAL", 4.0, 0, 0, 0, 0, 0); // Deal Drugs
  216. return 1;
  217. }
  218. // Crack Dieing
  219. if (strcmp("/crack", cmdtext, true, 6) == 0) {
  220. LoopingAnim(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0); // Dieing of Crack
  221. return 1;
  222. }
  223. // Male Smoking
  224. if (strcmp("/smokem", cmdtext, true, 4) == 0) {
  225. LoopingAnim(playerid,"SMOKING", "M_smklean_loop", 4.0, 1, 0, 0, 0, 0); // Smoke
  226. return 1;
  227. }
  228. // Female Smoking
  229. if (strcmp("/smokef", cmdtext, true) == 0) {
  230. LoopingAnim(playerid, "SMOKING", "F_smklean_loop", 4.0, 1, 0, 0, 0, 0); // Female Smoking
  231. return 1;
  232. }
  233. // Sit
  234. if (strcmp("/groundsit", cmdtext, true, 4) == 0) {
  235. LoopingAnim(playerid,"BEACH", "ParkSit_M_loop", 4.0, 1, 0, 0, 0, 0); // Sit
  236. return 1;
  237. }
  238. // Idle Chat
  239. if(strcmp(cmd, "/chat", true) == 0) {
  240. OnePlayAnim(playerid,"PED","IDLE_CHAT",4.0,0,0,0,0,0);
  241. return 1;
  242. }
  243. // Fucku
  244. if(strcmp(cmd, "/fucku", true) == 0) {
  245. OnePlayAnim(playerid,"PED","fucku",4.0,0,0,0,0,0);
  246. return 1;
  247. }
  248. // TaiChi
  249. if(strcmp(cmd, "/taichi", true) == 0) {
  250. LoopingAnim(playerid,"PARK","Tai_Chi_Loop",4.0,1,0,0,0,0);
  251. return 1;
  252. }
  253. // ChairSit
  254. if(strcmp(cmd, "/chairsit", true) == 0) {
  255. LoopingAnim(playerid,"BAR","dnk_stndF_loop",4.0,1,0,0,0,0);
  256. return 1;
  257. }
  258. // Collapse
  259. if(strcmp(cmd, "/collapse", true) == 0) {
  260. LoopingAnim(playerid,"PED","FALL_COLLAPSE",4.0,1,0,0,0,0);
  261. return 1;
  262. }
  263. // fall
  264. if(strcmp(cmd, "/fallover", true) == 0) {
  265. LoopingAnim(playerid,"PED","FALL_FALL",4.0,1,0,0,0,0);
  266. return 1;
  267. }
  268. // ko
  269. if(strcmp(cmd, "/ko1", true) == 0) {
  270. LoopingAnim(playerid,"PED","KO_SHOT_STOM",200.0, 0, 1, 1, 1, -1);
  271. return 1;
  272. }
  273. // ko
  274. if(strcmp(cmd, "/ko2", true) == 0) {
  275. LoopingAnim(playerid,"PED","KO_SHOT_FACE",4.0, 0, 1, 1, 1, -1);
  276. return 1;
  277. }
  278. if(strcmp(cmd, "/floorhit", true) == 0) {
  279. ApplyAnimation(playerid,"PED", "FLOOR_hit_f", 4.1, 0, 0, 0, 1, 0);
  280. return 1;
  281. }
  282. /* Would allow people to troll... but would be cool as a script
  283. controlled function
  284. // Bed Sleep R
  285. if(strcmp(cmd, "/inbedright", true) == 0) {
  286. LoopingAnim(playerid,"INT_HOUSE","BED_Loop_R",4.0,1,0,0,0,0);
  287. return 1;
  288. }
  289. // Bed Sleep L
  290. if(strcmp(cmd, "/inbedleft", true) == 0) {
  291. LoopingAnim(playerid,"INT_HOUSE","BED_Loop_L",4.0,1,0,0,0,0);
  292. return 1;
  293. }*/
  294. // START DANCING
  295. if(strcmp(cmd, "/dance", true) == 0) {
  296. new tmp[256];
  297. // Get the dance style param
  298. tmp = strtok(cmdtext, idx);
  299. if(!strlen(tmp) || strlen(tmp) > 2) {
  300. SendClientMessage(playerid,0xFF0000FF,"USAGE: /dance [style 1-4]");
  301. return 1;
  302. }
  303. dancestyle = strval(tmp);
  304. if(dancestyle < 1 || dancestyle > 4) {
  305. SendClientMessage(playerid,0xFF0000FF,"USAGE: /dance [style 1-4]");
  306. return 1;
  307. }
  308. if(dancestyle == 1) {
  309. SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE1);
  310. } else if(dancestyle == 2) {
  311. SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE2);
  312. } else if(dancestyle == 3) {
  313. SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE3);
  314. } else if(dancestyle == 4) {
  315. SetPlayerSpecialAction(playerid,SPECIAL_ACTION_DANCE4);
  316. }
  317. return 1;
  318. }
  319. return 0;
  320. }
  321. //-------------------------------------------------
  322. // EOF