DiGiTaL_AnGeL

Attachments(a bit modified)

Feb 9th, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.06 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. // I(DiGiTaL AnGeL) edited it so now it won't print the code, it will save it in "scriptfiles\atatchments.txt"
  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. };
  256.  
  257. new AttachmentBones[][24] = {
  258. {"Spine"},
  259. {"Head"},
  260. {"Left upper arm"},
  261. {"Right upper arm"},
  262. {"Left hand"},
  263. {"Right hand"},
  264. {"Left thigh"},
  265. {"Right thigh"},
  266. {"Left foot"},
  267. {"Right foot"},
  268. {"Right calf"},
  269. {"Left calf"},
  270. {"Left forearm"},
  271. {"Right forearm"},
  272. {"Left clavicle"},
  273. {"Right clavicle"},
  274. {"Neck"},
  275. {"Jaw"}
  276. };
  277.  
  278. public OnPlayerCommandText(playerid, cmdtext[])
  279. {
  280.     if(!strcmp(cmdtext, "/attachments", true))
  281.     {
  282.         new string[128];
  283.         for(new x;x<MAX_PLAYER_ATTACHED_OBJECTS;x++)
  284.         {
  285.             if(IsPlayerAttachedObjectSlotUsed(playerid, x)) format(string, sizeof(string), "%s%d (Used)\n", string, x);
  286.             else format(string, sizeof(string), "%s%d\n", string, x);
  287.         }
  288.         ShowPlayerDialog(playerid, DIALOG_ATTACH_INDEX_SELECTION, DIALOG_STYLE_LIST, \
  289.         "{FF0000}Attachment Modification - Index Selection", string, "Select", "Cancel");
  290.         return 1;
  291.     }
  292.     return 0;
  293. }
  294.  
  295. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  296. {
  297.     switch(dialogid)
  298.     {
  299.         case DIALOG_ATTACH_INDEX_SELECTION:
  300.         {
  301.             if(response)
  302.             {
  303.                 if(IsPlayerAttachedObjectSlotUsed(playerid, listitem))
  304.                 {
  305.                     ShowPlayerDialog(playerid, DIALOG_ATTACH_EDITREPLACE, DIALOG_STYLE_MSGBOX, \
  306.                     "{FF0000}Attachment Modification", "Do you wish to edit the attachment in that slot, or delete it?", "Edit", "Delete");
  307.                 }
  308.                 else
  309.                 {
  310.                     new string[4000+1];
  311.                     for(new x;x<sizeof(AttachmentObjects);x++)
  312.                     {
  313.                         format(string, sizeof(string), "%s%s\n", string, AttachmentObjects[x][attachname]);
  314.                     }
  315.                     ShowPlayerDialog(playerid, DIALOG_ATTACH_MODEL_SELECTION, DIALOG_STYLE_LIST, \
  316.                     "{FF0000}Attachment Modification - Model Selection", string, "Select", "Cancel");
  317.                 }
  318.                 SetPVarInt(playerid, "AttachmentIndexSel", listitem);
  319.             }
  320.             return 1;
  321.         }
  322.         case DIALOG_ATTACH_EDITREPLACE:
  323.         {
  324.             if(response) EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  325.             else RemovePlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  326.             DeletePVar(playerid, "AttachmentIndexSel");
  327.             return 1;
  328.         }
  329.         case DIALOG_ATTACH_MODEL_SELECTION:
  330.         {
  331.             if(response)
  332.             {
  333.                 if(GetPVarInt(playerid, "AttachmentUsed") == 1) EditAttachedObject(playerid, listitem);
  334.                 else
  335.                 {
  336.                     SetPVarInt(playerid, "AttachmentModelSel", AttachmentObjects[listitem][attachmodel]);
  337.                     new string[256+1];
  338.                     for(new x;x<sizeof(AttachmentBones);x++)
  339.                     {
  340.                         format(string, sizeof(string), "%s%s\n", string, AttachmentBones[x]);
  341.                     }
  342.                     ShowPlayerDialog(playerid, DIALOG_ATTACH_BONE_SELECTION, DIALOG_STYLE_LIST, \
  343.                     "{FF0000}Attachment Modification - Bone Selection", string, "Select", "Cancel");
  344.                 }
  345.             }
  346.             else DeletePVar(playerid, "AttachmentIndexSel");
  347.             return 1;
  348.         }
  349.         case DIALOG_ATTACH_BONE_SELECTION:
  350.         {
  351.             if(response)
  352.             {
  353.                 SetPlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"), GetPVarInt(playerid, "AttachmentModelSel"), listitem+1);
  354.                 EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  355.                 SendClientMessage(playerid, 0xFFFFFFFF, "Hint: Use {FFFF00}~k~~PED_SPRINT~{FFFFFF} to look around.");
  356.             }
  357.             DeletePVar(playerid, "AttachmentIndexSel");
  358.             DeletePVar(playerid, "AttachmentModelSel");
  359.             return 1;
  360.         }
  361.     }
  362.     return 0;
  363. }
  364.  
  365. public OnPlayerEditAttachedObject( playerid, response, index, modelid, boneid,
  366.                                    Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,
  367.                                    Float:fRotX, Float:fRotY, Float:fRotZ,
  368.                                    Float:fScaleX, Float:fScaleY, Float:fScaleZ )
  369. {
  370.     new debug_string[256+1];
  371.     format(debug_string,256,"SetPlayerAttachedObject(playerid,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f)",
  372.         index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
  373.     new File:attachments = fopen("attachments.txt", io_append);
  374.     if(attachments)
  375.     {
  376.         fwrite(attachments, debug_string);
  377.         fclose(attachments);
  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