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.

383 lines
11 KiB

  1. //-------------------------------------------------
  2. //
  3. // This is an example of using the EditAttachedObject functions
  4. // to allow the player to customize their character.
  5. //
  6. // h02 2012
  7. //
  8. // SA-MP 0.3e and above
  9. //
  10. //-------------------------------------------------
  11. #include <a_samp>
  12. #define DIALOG_ATTACH_INDEX 13500
  13. #define DIALOG_ATTACH_INDEX_SELECTION DIALOG_ATTACH_INDEX+1
  14. #define DIALOG_ATTACH_EDITREPLACE DIALOG_ATTACH_INDEX+2
  15. #define DIALOG_ATTACH_MODEL_SELECTION DIALOG_ATTACH_INDEX+3
  16. #define DIALOG_ATTACH_BONE_SELECTION DIALOG_ATTACH_INDEX+4
  17. enum AttachmentEnum
  18. {
  19. attachmodel,
  20. attachname[24]
  21. }
  22. new AttachmentObjects[][AttachmentEnum] = {
  23. {18632, "FishingRod"},
  24. {18633, "GTASAWrench1"},
  25. {18634, "GTASACrowbar1"},
  26. {18635, "GTASAHammer1"},
  27. {18636, "PoliceCap1"},
  28. {18637, "PoliceShield1"},
  29. {18638, "HardHat1"},
  30. {18639, "BlackHat1"},
  31. {18640, "Hair1"},
  32. {18975, "Hair2"},
  33. {19136, "Hair4"},
  34. {19274, "Hair5"},
  35. {18641, "Flashlight1"},
  36. {18642, "Taser1"},
  37. {18643, "LaserPointer1"},
  38. {19080, "LaserPointer2"},
  39. {19081, "LaserPointer3"},
  40. {19082, "LaserPointer4"},
  41. {19083, "LaserPointer5"},
  42. {19084, "LaserPointer6"},
  43. {18644, "Screwdriver1"},
  44. {18645, "MotorcycleHelmet1"},
  45. {18865, "MobilePhone1"},
  46. {18866, "MobilePhone2"},
  47. {18867, "MobilePhone3"},
  48. {18868, "MobilePhone4"},
  49. {18869, "MobilePhone5"},
  50. {18870, "MobilePhone6"},
  51. {18871, "MobilePhone7"},
  52. {18872, "MobilePhone8"},
  53. {18873, "MobilePhone9"},
  54. {18874, "MobilePhone10"},
  55. {18875, "Pager1"},
  56. {18890, "Rake1"},
  57. {18891, "Bandana1"},
  58. {18892, "Bandana2"},
  59. {18893, "Bandana3"},
  60. {18894, "Bandana4"},
  61. {18895, "Bandana5"},
  62. {18896, "Bandana6"},
  63. {18897, "Bandana7"},
  64. {18898, "Bandana8"},
  65. {18899, "Bandana9"},
  66. {18900, "Bandana10"},
  67. {18901, "Bandana11"},
  68. {18902, "Bandana12"},
  69. {18903, "Bandana13"},
  70. {18904, "Bandana14"},
  71. {18905, "Bandana15"},
  72. {18906, "Bandana16"},
  73. {18907, "Bandana17"},
  74. {18908, "Bandana18"},
  75. {18909, "Bandana19"},
  76. {18910, "Bandana20"},
  77. {18911, "Mask1"},
  78. {18912, "Mask2"},
  79. {18913, "Mask3"},
  80. {18914, "Mask4"},
  81. {18915, "Mask5"},
  82. {18916, "Mask6"},
  83. {18917, "Mask7"},
  84. {18918, "Mask8"},
  85. {18919, "Mask9"},
  86. {18920, "Mask10"},
  87. {18921, "Beret1"},
  88. {18922, "Beret2"},
  89. {18923, "Beret3"},
  90. {18924, "Beret4"},
  91. {18925, "Beret5"},
  92. {18926, "Hat1"},
  93. {18927, "Hat2"},
  94. {18928, "Hat3"},
  95. {18929, "Hat4"},
  96. {18930, "Hat5"},
  97. {18931, "Hat6"},
  98. {18932, "Hat7"},
  99. {18933, "Hat8"},
  100. {18934, "Hat9"},
  101. {18935, "Hat10"},
  102. {18936, "Helmet1"},
  103. {18937, "Helmet2"},
  104. {18938, "Helmet3"},
  105. {18939, "CapBack1"},
  106. {18940, "CapBack2"},
  107. {18941, "CapBack3"},
  108. {18942, "CapBack4"},
  109. {18943, "CapBack5"},
  110. {18944, "HatBoater1"},
  111. {18945, "HatBoater2"},
  112. {18946, "HatBoater3"},
  113. {18947, "HatBowler1"},
  114. {18948, "HatBowler2"},
  115. {18949, "HatBowler3"},
  116. {18950, "HatBowler4"},
  117. {18951, "HatBowler5"},
  118. {18952, "BoxingHelmet1"},
  119. {18953, "CapKnit1"},
  120. {18954, "CapKnit2"},
  121. {18955, "CapOverEye1"},
  122. {18956, "CapOverEye2"},
  123. {18957, "CapOverEye3"},
  124. {18958, "CapOverEye4"},
  125. {18959, "CapOverEye5"},
  126. {18960, "CapRimUp1"},
  127. {18961, "CapTrucker1"},
  128. {18962, "CowboyHat2"},
  129. {18963, "CJElvisHead"},
  130. {18964, "SkullyCap1"},
  131. {18965, "SkullyCap2"},
  132. {18966, "SkullyCap3"},
  133. {18967, "HatMan1"},
  134. {18968, "HatMan2"},
  135. {18969, "HatMan3"},
  136. {18970, "HatTiger1"},
  137. {18971, "HatCool1"},
  138. {18972, "HatCool2"},
  139. {18973, "HatCool3"},
  140. {18974, "MaskZorro1"},
  141. {18976, "MotorcycleHelmet2"},
  142. {18977, "MotorcycleHelmet3"},
  143. {18978, "MotorcycleHelmet4"},
  144. {18979, "MotorcycleHelmet5"},
  145. {19006, "GlassesType1"},
  146. {19007, "GlassesType2"},
  147. {19008, "GlassesType3"},
  148. {19009, "GlassesType4"},
  149. {19010, "GlassesType5"},
  150. {19011, "GlassesType6"},
  151. {19012, "GlassesType7"},
  152. {19013, "GlassesType8"},
  153. {19014, "GlassesType9"},
  154. {19015, "GlassesType10"},
  155. {19016, "GlassesType11"},
  156. {19017, "GlassesType12"},
  157. {19018, "GlassesType13"},
  158. {19019, "GlassesType14"},
  159. {19020, "GlassesType15"},
  160. {19021, "GlassesType16"},
  161. {19022, "GlassesType17"},
  162. {19023, "GlassesType18"},
  163. {19024, "GlassesType19"},
  164. {19025, "GlassesType20"},
  165. {19026, "GlassesType21"},
  166. {19027, "GlassesType22"},
  167. {19028, "GlassesType23"},
  168. {19029, "GlassesType24"},
  169. {19030, "GlassesType25"},
  170. {19031, "GlassesType26"},
  171. {19032, "GlassesType27"},
  172. {19033, "GlassesType28"},
  173. {19034, "GlassesType29"},
  174. {19035, "GlassesType30"},
  175. {19036, "HockeyMask1"},
  176. {19037, "HockeyMask2"},
  177. {19038, "HockeyMask3"},
  178. {19039, "WatchType1"},
  179. {19040, "WatchType2"},
  180. {19041, "WatchType3"},
  181. {19042, "WatchType4"},
  182. {19043, "WatchType5"},
  183. {19044, "WatchType6"},
  184. {19045, "WatchType7"},
  185. {19046, "WatchType8"},
  186. {19047, "WatchType9"},
  187. {19048, "WatchType10"},
  188. {19049, "WatchType11"},
  189. {19050, "WatchType12"},
  190. {19051, "WatchType13"},
  191. {19052, "WatchType14"},
  192. {19053, "WatchType15"},
  193. {19085, "EyePatch1"},
  194. {19086, "ChainsawDildo1"},
  195. {19090, "PomPomBlue"},
  196. {19091, "PomPomRed"},
  197. {19092, "PomPomGreen"},
  198. {19093, "HardHat2"},
  199. {19094, "BurgerShotHat1"},
  200. {19095, "CowboyHat1"},
  201. {19096, "CowboyHat3"},
  202. {19097, "CowboyHat4"},
  203. {19098, "CowboyHat5"},
  204. {19099, "PoliceCap2"},
  205. {19100, "PoliceCap3"},
  206. {19101, "ArmyHelmet1"},
  207. {19102, "ArmyHelmet2"},
  208. {19103, "ArmyHelmet3"},
  209. {19104, "ArmyHelmet4"},
  210. {19105, "ArmyHelmet5"},
  211. {19106, "ArmyHelmet6"},
  212. {19107, "ArmyHelmet7"},
  213. {19108, "ArmyHelmet8"},
  214. {19109, "ArmyHelmet9"},
  215. {19110, "ArmyHelmet10"},
  216. {19111, "ArmyHelmet11"},
  217. {19112, "ArmyHelmet12"},
  218. {19113, "SillyHelmet1"},
  219. {19114, "SillyHelmet2"},
  220. {19115, "SillyHelmet3"},
  221. {19116, "PlainHelmet1"},
  222. {19117, "PlainHelmet2"},
  223. {19118, "PlainHelmet3"},
  224. {19119, "PlainHelmet4"},
  225. {19120, "PlainHelmet5"},
  226. {19137, "CluckinBellHat1"},
  227. {19138, "PoliceGlasses1"},
  228. {19139, "PoliceGlasses2"},
  229. {19140, "PoliceGlasses3"},
  230. {19141, "SWATHelmet1"},
  231. {19142, "SWATArmour1"},
  232. {19160, "HardHat3"},
  233. {19161, "PoliceHat1"},
  234. {19162, "PoliceHat2"},
  235. {19163, "GimpMask1"},
  236. {19317, "bassguitar01"},
  237. {19318, "flyingv01"},
  238. {19319, "warlock01"},
  239. {19330, "fire_hat01"},
  240. {19331, "fire_hat02"},
  241. {19346, "hotdog01"},
  242. {19347, "badge01"},
  243. {19348, "cane01"},
  244. {19349, "monocle01"},
  245. {19350, "moustache01"},
  246. {19351, "moustache02"},
  247. {19352, "tophat01"},
  248. {19487, "tophat02"},
  249. {19488, "HatBowler6"},
  250. {19513, "whitephone"},
  251. {19578, "Banana"},
  252. {19418, "HandCuff"}
  253. };
  254. new AttachmentBones[][24] = {
  255. {"Spine"},
  256. {"Head"},
  257. {"Left upper arm"},
  258. {"Right upper arm"},
  259. {"Left hand"},
  260. {"Right hand"},
  261. {"Left thigh"},
  262. {"Right thigh"},
  263. {"Left foot"},
  264. {"Right foot"},
  265. {"Right calf"},
  266. {"Left calf"},
  267. {"Left forearm"},
  268. {"Right forearm"},
  269. {"Left clavicle"},
  270. {"Right clavicle"},
  271. {"Neck"},
  272. {"Jaw"}
  273. };
  274. public OnPlayerCommandText(playerid, cmdtext[])
  275. {
  276. if(!strcmp(cmdtext, "/attachments", true))
  277. {
  278. new string[128];
  279. for(new x;x<MAX_PLAYER_ATTACHED_OBJECTS;x++)
  280. {
  281. if(IsPlayerAttachedObjectSlotUsed(playerid, x)) format(string, sizeof(string), "%s%d (Used)\n", string, x);
  282. else format(string, sizeof(string), "%s%d\n", string, x);
  283. }
  284. ShowPlayerDialog(playerid, DIALOG_ATTACH_INDEX_SELECTION, DIALOG_STYLE_LIST, \
  285. "{FF0000}Attachment Modification - Index Selection", string, "Select", "Cancel");
  286. return 1;
  287. }
  288. return 0;
  289. }
  290. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  291. {
  292. switch(dialogid)
  293. {
  294. case DIALOG_ATTACH_INDEX_SELECTION:
  295. {
  296. if(response)
  297. {
  298. if(IsPlayerAttachedObjectSlotUsed(playerid, listitem))
  299. {
  300. ShowPlayerDialog(playerid, DIALOG_ATTACH_EDITREPLACE, DIALOG_STYLE_MSGBOX, \
  301. "{FF0000}Attachment Modification", "Do you wish to edit the attachment in that slot, or delete it?", "Edit", "Delete");
  302. }
  303. else
  304. {
  305. new string[4000+1];
  306. for(new x;x<sizeof(AttachmentObjects);x++)
  307. {
  308. format(string, sizeof(string), "%s%s\n", string, AttachmentObjects[x][attachname]);
  309. }
  310. ShowPlayerDialog(playerid, DIALOG_ATTACH_MODEL_SELECTION, DIALOG_STYLE_LIST, \
  311. "{FF0000}Attachment Modification - Model Selection", string, "Select", "Cancel");
  312. }
  313. SetPVarInt(playerid, "AttachmentIndexSel", listitem);
  314. }
  315. return 1;
  316. }
  317. case DIALOG_ATTACH_EDITREPLACE:
  318. {
  319. if(response) EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  320. else RemovePlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  321. DeletePVar(playerid, "AttachmentIndexSel");
  322. return 1;
  323. }
  324. case DIALOG_ATTACH_MODEL_SELECTION:
  325. {
  326. if(response)
  327. {
  328. if(GetPVarInt(playerid, "AttachmentUsed") == 1) EditAttachedObject(playerid, listitem);
  329. else
  330. {
  331. SetPVarInt(playerid, "AttachmentModelSel", AttachmentObjects[listitem][attachmodel]);
  332. new string[256+1];
  333. for(new x;x<sizeof(AttachmentBones);x++)
  334. {
  335. format(string, sizeof(string), "%s%s\n", string, AttachmentBones[x]);
  336. }
  337. ShowPlayerDialog(playerid, DIALOG_ATTACH_BONE_SELECTION, DIALOG_STYLE_LIST, \
  338. "{FF0000}Attachment Modification - Bone Selection", string, "Select", "Cancel");
  339. }
  340. }
  341. else DeletePVar(playerid, "AttachmentIndexSel");
  342. return 1;
  343. }
  344. case DIALOG_ATTACH_BONE_SELECTION:
  345. {
  346. if(response)
  347. {
  348. SetPlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"), GetPVarInt(playerid, "AttachmentModelSel"), listitem+1);
  349. EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  350. SendClientMessage(playerid, 0xFFFFFFFF, "Hint: Use {FFFF00}~k~~PED_SPRINT~{FFFFFF} to look around.");
  351. }
  352. DeletePVar(playerid, "AttachmentIndexSel");
  353. DeletePVar(playerid, "AttachmentModelSel");
  354. return 1;
  355. }
  356. }
  357. return 0;
  358. }
  359. public OnPlayerEditAttachedObject( playerid, response, index, modelid, boneid,
  360. Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,
  361. Float:fRotX, Float:fRotY, Float:fRotZ,
  362. Float:fScaleX, Float:fScaleY, Float:fScaleZ )
  363. {
  364. new debug_string[256+1];
  365. format(debug_string,256,"SetPlayerAttachedObject(playerid,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f)",
  366. index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
  367. print(debug_string);
  368. SendClientMessage(playerid, 0xFFFFFFFF, debug_string);
  369. SetPlayerAttachedObject(playerid,index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
  370. SendClientMessage(playerid, 0xFFFFFFFF, "You finished editing an attached object");
  371. return 1;
  372. }