Advertisement
Guest User

123

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