Advertisement
razvan_xd

Untitled

Feb 9th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.04 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. // ATASAMENTELE SE SALVEAZA IN SCRIPTFILES/ATASAMENTE.TXT
  11. //-------------------------------------------------
  12.  
  13. #include <a_samp>
  14.  
  15. #define DIALOG_ATTACH_INDEX             13500
  16. #define DIALOG_ATTACH_INDEX_SELECTION   DIALOG_ATTACH_INDEX+1
  17. #define DIALOG_ATTACH_EDITREPLACE       DIALOG_ATTACH_INDEX+2
  18. #define DIALOG_ATTACH_MODEL_SELECTION   DIALOG_ATTACH_INDEX+3
  19. #define DIALOG_ATTACH_BONE_SELECTION    DIALOG_ATTACH_INDEX+4
  20.  
  21. enum AttachmentEnum
  22. {
  23.     attachmodel,
  24.     attachname[24]
  25. }
  26.  
  27. new AttachmentObjects[][AttachmentEnum] = {
  28. {18632, "FishingRod"},
  29. {18633, "GTASAWrench1"},
  30. {18634, "GTASACrowbar1"},
  31. {18635, "GTASAHammer1"},
  32. {18636, "PoliceCap1"},
  33. {18637, "PoliceShield1"},
  34. {18638, "HardHat1"},
  35. {18639, "BlackHat1"},
  36. {18640, "Hair1"},
  37. {18975, "Hair2"},
  38. {19136, "Hair4"},
  39. {19274, "Hair5"},
  40. {18641, "Flashlight1"},
  41. {18642, "Taser1"},
  42. {18643, "LaserPointer1"},
  43. {19080, "LaserPointer2"},
  44. {19081, "LaserPointer3"},
  45. {19082, "LaserPointer4"},
  46. {19083, "LaserPointer5"},
  47. {19084, "LaserPointer6"},
  48. {18644, "Screwdriver1"},
  49. {18645, "MotorcycleHelmet1"},
  50. {18865, "MobilePhone1"},
  51. {18866, "MobilePhone2"},
  52. {18867, "MobilePhone3"},
  53. {18868, "MobilePhone4"},
  54. {18869, "MobilePhone5"},
  55. {18870, "MobilePhone6"},
  56. {18871, "MobilePhone7"},
  57. {18872, "MobilePhone8"},
  58. {18873, "MobilePhone9"},
  59. {18874, "MobilePhone10"},
  60. {18875, "Pager1"},
  61. {18890, "Rake1"},
  62. {18891, "Bandana1"},
  63. {18892, "Bandana2"},
  64. {18893, "Bandana3"},
  65. {18894, "Bandana4"},
  66. {18895, "Bandana5"},
  67. {18896, "Bandana6"},
  68. {18897, "Bandana7"},
  69. {18898, "Bandana8"},
  70. {18899, "Bandana9"},
  71. {18900, "Bandana10"},
  72. {18901, "Bandana11"},
  73. {18902, "Bandana12"},
  74. {18903, "Bandana13"},
  75. {18904, "Bandana14"},
  76. {18905, "Bandana15"},
  77. {18906, "Bandana16"},
  78. {18907, "Bandana17"},
  79. {18908, "Bandana18"},
  80. {18909, "Bandana19"},
  81. {18910, "Bandana20"},
  82. {18911, "Mask1"},
  83. {18912, "Mask2"},
  84. {18913, "Mask3"},
  85. {18914, "Mask4"},
  86. {18915, "Mask5"},
  87. {18916, "Mask6"},
  88. {18917, "Mask7"},
  89. {18918, "Mask8"},
  90. {18919, "Mask9"},
  91. {18920, "Mask10"},
  92. {18921, "Beret1"},
  93. {18922, "Beret2"},
  94. {18923, "Beret3"},
  95. {18924, "Beret4"},
  96. {18925, "Beret5"},
  97. {18926, "Hat1"},
  98. {18927, "Hat2"},
  99. {18928, "Hat3"},
  100. {18929, "Hat4"},
  101. {18930, "Hat5"},
  102. {18931, "Hat6"},
  103. {18932, "Hat7"},
  104. {18933, "Hat8"},
  105. {18934, "Hat9"},
  106. {18935, "Hat10"},
  107. {18936, "Helmet1"},
  108. {18937, "Helmet2"},
  109. {18938, "Helmet3"},
  110. {18939, "CapBack1"},
  111. {18940, "CapBack2"},
  112. {18941, "CapBack3"},
  113. {18942, "CapBack4"},
  114. {18943, "CapBack5"},
  115. {18944, "HatBoater1"},
  116. {18945, "HatBoater2"},
  117. {18946, "HatBoater3"},
  118. {18947, "HatBowler1"},
  119. {18948, "HatBowler2"},
  120. {18949, "HatBowler3"},
  121. {18950, "HatBowler4"},
  122. {18951, "HatBowler5"},
  123. {18952, "BoxingHelmet1"},
  124. {18953, "CapKnit1"},
  125. {18954, "CapKnit2"},
  126. {18955, "CapOverEye1"},
  127. {18956, "CapOverEye2"},
  128. {18957, "CapOverEye3"},
  129. {18958, "CapOverEye4"},
  130. {18959, "CapOverEye5"},
  131. {18960, "CapRimUp1"},
  132. {18961, "CapTrucker1"},
  133. {18962, "CowboyHat2"},
  134. {18963, "CJElvisHead"},
  135. {18964, "SkullyCap1"},
  136. {18965, "SkullyCap2"},
  137. {18966, "SkullyCap3"},
  138. {18967, "HatMan1"},
  139. {18968, "HatMan2"},
  140. {18969, "HatMan3"},
  141. {18970, "HatTiger1"},
  142. {18971, "HatCool1"},
  143. {18972, "HatCool2"},
  144. {18973, "HatCool3"},
  145. {18974, "MaskZorro1"},
  146. {18976, "MotorcycleHelmet2"},
  147. {18977, "MotorcycleHelmet3"},
  148. {18978, "MotorcycleHelmet4"},
  149. {18979, "MotorcycleHelmet5"},
  150. {19006, "GlassesType1"},
  151. {19007, "GlassesType2"},
  152. {19008, "GlassesType3"},
  153. {19009, "GlassesType4"},
  154. {19010, "GlassesType5"},
  155. {19011, "GlassesType6"},
  156. {19012, "GlassesType7"},
  157. {19013, "GlassesType8"},
  158. {19014, "GlassesType9"},
  159. {19015, "GlassesType10"},
  160. {19016, "GlassesType11"},
  161. {19017, "GlassesType12"},
  162. {19018, "GlassesType13"},
  163. {19019, "GlassesType14"},
  164. {19020, "GlassesType15"},
  165. {19021, "GlassesType16"},
  166. {19022, "GlassesType17"},
  167. {19023, "GlassesType18"},
  168. {19024, "GlassesType19"},
  169. {19025, "GlassesType20"},
  170. {19026, "GlassesType21"},
  171. {19027, "GlassesType22"},
  172. {19028, "GlassesType23"},
  173. {19029, "GlassesType24"},
  174. {19030, "GlassesType25"},
  175. {19031, "GlassesType26"},
  176. {19032, "GlassesType27"},
  177. {19033, "GlassesType28"},
  178. {19034, "GlassesType29"},
  179. {19035, "GlassesType30"},
  180. {19036, "HockeyMask1"},
  181. {19037, "HockeyMask2"},
  182. {19038, "HockeyMask3"},
  183. {19039, "WatchType1"},
  184. {19040, "WatchType2"},
  185. {19041, "WatchType3"},
  186. {19042, "WatchType4"},
  187. {19043, "WatchType5"},
  188. {19044, "WatchType6"},
  189. {19045, "WatchType7"},
  190. {19046, "WatchType8"},
  191. {19047, "WatchType9"},
  192. {19048, "WatchType10"},
  193. {19049, "WatchType11"},
  194. {19050, "WatchType12"},
  195. {19051, "WatchType13"},
  196. {19052, "WatchType14"},
  197. {19053, "WatchType15"},
  198. {19085, "EyePatch1"},
  199. {19086, "ChainsawDildo1"},
  200. {19090, "PomPomBlue"},
  201. {19091, "PomPomRed"},
  202. {19092, "PomPomGreen"},
  203. {19093, "HardHat2"},
  204. {19094, "BurgerShotHat1"},
  205. {19095, "CowboyHat1"},
  206. {19096, "CowboyHat3"},
  207. {19097, "CowboyHat4"},
  208. {19098, "CowboyHat5"},
  209. {19099, "PoliceCap2"},
  210. {19100, "PoliceCap3"},
  211. {19101, "ArmyHelmet1"},
  212. {19102, "ArmyHelmet2"},
  213. {19103, "ArmyHelmet3"},
  214. {19104, "ArmyHelmet4"},
  215. {19105, "ArmyHelmet5"},
  216. {19106, "ArmyHelmet6"},
  217. {19107, "ArmyHelmet7"},
  218. {19108, "ArmyHelmet8"},
  219. {19109, "ArmyHelmet9"},
  220. {19110, "ArmyHelmet10"},
  221. {19111, "ArmyHelmet11"},
  222. {19112, "ArmyHelmet12"},
  223. {19113, "SillyHelmet1"},
  224. {19114, "SillyHelmet2"},
  225. {19115, "SillyHelmet3"},
  226. {19116, "PlainHelmet1"},
  227. {19117, "PlainHelmet2"},
  228. {19118, "PlainHelmet3"},
  229. {19119, "PlainHelmet4"},
  230. {19120, "PlainHelmet5"},
  231. {19137, "CluckinBellHat1"},
  232. {19138, "PoliceGlasses1"},
  233. {19139, "PoliceGlasses2"},
  234. {19140, "PoliceGlasses3"},
  235. {19141, "SWATHelmet1"},
  236. {19142, "SWATArmour1"},
  237. {19160, "HardHat3"},
  238. {19161, "PoliceHat1"},
  239. {19162, "PoliceHat2"},
  240. {19163, "GimpMask1"},
  241. {19317, "bassguitar01"},
  242. {19318, "flyingv01"},
  243. {19319, "warlock01"},
  244. {19330, "fire_hat01"},
  245. {19331, "fire_hat02"},
  246. {19346, "hotdog01"},
  247. {19347, "badge01"},
  248. {19348, "cane01"},
  249. {19349, "monocle01"},
  250. {19350, "moustache01"},
  251. {19351, "moustache02"},
  252. {19352, "tophat01"},
  253. {19487, "tophat02"},
  254. {19488, "HatBowler6"},
  255. {19513, "whitephone"},
  256. {19515, "GreySwatArm"}
  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
  373.         debug_string[256+5+1],
  374.         fAtasamente = fopen ( "atasamente.txt", io_append )
  375.     ;
  376.  
  377.     format(debug_string,sizeof(debug_string),"SetPlayerAttachedObject(playerid,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f);\r\n",
  378.         index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
  379.  
  380.     fwrite ( fAtasamente, debug_string );
  381.  
  382.     fclose ( fAtasamente );
  383.    
  384.     SetPlayerAttachedObject(playerid,index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
  385.     SendClientMessage(playerid, 0xFFFFFFFF, "You finished editing an attached object");
  386.    
  387.     return 1;
  388. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement