Swit_Cj

[FS]AttachmentObjectsSave

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