Advertisement
Guest User

Untitled

a guest
Sep 27th, 2012
2,838
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.05 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_ini>
  3. #define PATH "/toys/%s.ini"
  4.  
  5. enum pInfo
  6. {
  7. pindex,
  8. pmodelid,
  9. pboneid,
  10. Float:pfOffsetX,
  11. Float:pfOffsetY,
  12. Float:pfOffsetZ,
  13. Float:pfRotX,
  14. Float:pfRotY,
  15. Float:pfRotZ,
  16. Float:pfScaleX,
  17. Float:pfScaleY,
  18. Float:pfScaleZ
  19. }
  20. new PlayerInfo[MAX_PLAYERS][pInfo];
  21. #define COL_GREEN2 "{33CC00}" //this is color
  22. #define COL_WHITE "{FFFFFF}" //this too
  23. #define DIALOG_ATTACH_INDEX 13500
  24. #define DIALOG_ATTACH_INDEX_SELECTION DIALOG_ATTACH_INDEX+1
  25. #define DIALOG_ATTACH_EDITREPLACE DIALOG_ATTACH_INDEX+2
  26. #define DIALOG_ATTACH_MODEL_SELECTION DIALOG_ATTACH_INDEX+3
  27. #define DIALOG_ATTACH_BONE_SELECTION DIALOG_ATTACH_INDEX+4
  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. {3044, "Cigar"},
  266. {1210, "Briefcase"}
  267. };
  268.  
  269. new AttachmentBones[][24] = {
  270. {"Spine"},
  271. {"Head"},
  272. {"Left upper arm"},
  273. {"Right upper arm"},
  274. {"Left hand"},
  275. {"Right hand"},
  276. {"Left thigh"},
  277. {"Right thigh"},
  278. {"Left foot"},
  279. {"Right foot"},
  280. {"Right calf"},
  281. {"Left calf"},
  282. {"Left forearm"},
  283. {"Right forearm"},
  284. {"Left clavicle"},
  285. {"Right clavicle"},
  286. {"Neck"},
  287. {"Jaw"}
  288. };
  289.  
  290. public OnPlayerDisconnect(playerid, reason)
  291. {
  292.  
  293. return 1;
  294. }
  295.  
  296. public OnPlayerSpawn(playerid)
  297. {
  298. OnPlayerLogin(playerid);
  299. // Attach a white hat to the head of the player and paint it green
  300. return 1;
  301. }
  302.  
  303. public OnPlayerCommandText(playerid, cmdtext[])
  304. {
  305.  
  306. if(strcmp(cmdtext, "/attachments", true) == 0)
  307. {
  308. new string[128];
  309. for(new x;x<MAX_PLAYER_ATTACHED_OBJECTS;x++)
  310. {
  311. if(IsPlayerAttachedObjectSlotUsed(playerid, x)) format(string, sizeof(string), "%s%d (Used)\n", string, x);
  312. else format(string, sizeof(string), "%s%d\n", string, x);
  313. }
  314. ShowPlayerDialog(playerid, DIALOG_ATTACH_INDEX_SELECTION, DIALOG_STYLE_LIST, \
  315. "{FF0000}Attachment Modification - Index Selection", string, "Select", "Cancel");
  316. return 1;
  317. }
  318.  
  319.  
  320. return 0;
  321. }
  322.  
  323. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  324. {
  325. switch(dialogid)
  326. {
  327. case DIALOG_ATTACH_INDEX_SELECTION:
  328. {
  329. if(response)
  330. {
  331. if(IsPlayerAttachedObjectSlotUsed(playerid, listitem))
  332. {
  333. ShowPlayerDialog(playerid, DIALOG_ATTACH_EDITREPLACE, DIALOG_STYLE_MSGBOX, \
  334. "{FF0000}Attachment Modification", "Do you wish to edit the attachment in that slot, or delete it?", "Edit", "Delete");
  335. }
  336. else
  337. {
  338. new string[4000+1];
  339. for(new x;x<sizeof(AttachmentObjects);x++)
  340. {
  341. format(string, sizeof(string), "%s%s\n", string, AttachmentObjects[x][attachname]);
  342. }
  343. ShowPlayerDialog(playerid, DIALOG_ATTACH_MODEL_SELECTION, DIALOG_STYLE_LIST, \
  344. "{FF0000}Attachment Modification - Model Selection", string, "Select", "Cancel");
  345. }
  346. SetPVarInt(playerid, "AttachmentIndexSel", listitem);
  347. }
  348. return 1;
  349. }
  350. case DIALOG_ATTACH_EDITREPLACE:
  351. {
  352. if(response) EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  353. else RemovePlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  354. DeletePVar(playerid, "AttachmentIndexSel");
  355. return 1;
  356. }
  357. case DIALOG_ATTACH_MODEL_SELECTION:
  358. {
  359. if(response)
  360. {
  361. if(GetPVarInt(playerid, "AttachmentUsed") == 1) EditAttachedObject(playerid, listitem);
  362. else
  363. {
  364. SetPVarInt(playerid, "AttachmentModelSel", AttachmentObjects[listitem][attachmodel]);
  365. new string[256+1];
  366. for(new x;x<sizeof(AttachmentBones);x++)
  367. {
  368. format(string, sizeof(string), "%s%s\n", string, AttachmentBones[x]);
  369. }
  370. ShowPlayerDialog(playerid, DIALOG_ATTACH_BONE_SELECTION, DIALOG_STYLE_LIST, \
  371. "{FF0000}Attachment Modification - Bone Selection", string, "Select", "Cancel");
  372. }
  373. }
  374. else DeletePVar(playerid, "AttachmentIndexSel");
  375. return 1;
  376. }
  377. case DIALOG_ATTACH_BONE_SELECTION:
  378. {
  379. if(response)
  380. {
  381. SetPlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"), GetPVarInt(playerid, "AttachmentModelSel"), listitem+1);
  382. EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  383. SendClientMessage(playerid, 0xFFFFFFFF, "Hint: Use {FFFF00}~k~~PED_SPRINT~{FFFFFF} to look around.");
  384. }
  385. DeletePVar(playerid, "AttachmentIndexSel");
  386. DeletePVar(playerid, "AttachmentModelSel");
  387. return 1;
  388. }
  389. }
  390. return 0;
  391. }
  392.  
  393.  
  394.  
  395. OnPlayerLogin(playerid)
  396. {
  397. new
  398. uFile[35];
  399. format(uFile, 35, PATH, GetName(playerid));
  400. INI_ParseFile(uFile, "LoadToys", .bExtra = true, .extra = playerid);
  401. SetPlayerAttachedObject(playerid,
  402. INT:PlayerInfo[playerid][pindex],
  403. INT:PlayerInfo[playerid][pmodelid],
  404. INT:PlayerInfo[playerid][pboneid],
  405. Float:PlayerInfo[playerid][pfOffsetX],
  406. Float:PlayerInfo[playerid][pfOffsetY],
  407. Float:PlayerInfo[playerid][pfOffsetZ],
  408. Float:PlayerInfo[playerid][pfRotX],
  409. Float:PlayerInfo[playerid][pfRotY],
  410. Float:PlayerInfo[playerid][pfRotZ],
  411. Float:PlayerInfo[playerid][pfScaleX],
  412. Float:PlayerInfo[playerid][pfScaleY],
  413. Float:PlayerInfo[playerid][pfScaleZ]);
  414. return 1;
  415. }
  416.  
  417.  
  418.  
  419. stock UserPath(playerid)
  420. {
  421. new string[128],playername[MAX_PLAYER_NAME];
  422. GetPlayerName(playerid,playername,sizeof(playername));
  423. format(string,sizeof(string),PATH,playername);
  424. return string;
  425. }
  426.  
  427. stock GetName(playerid) //function for getting player name, this is faster than GetPlayerName(I don't mean in miliseconds, just I don't need to create new variable and than use GetPlayerName, I just use this function
  428. { //opening barrel
  429. new
  430. pName[MAX_PLAYER_NAME]; //variable for player name, max.player name is 24
  431.  
  432. GetPlayerName(playerid, pName, MAX_PLAYER_NAME); //getting player name
  433. return pName; //returning player name;
  434. } //closing barrel
  435.  
  436. forward LoadToys(playerid,name[],value[]);
  437. public LoadToys(playerid,name[],value[])
  438. {
  439.  
  440. if (!strcmp(name, "sindex")){ PlayerInfo[playerid][pindex] = strval(value); }
  441. if (!strcmp(name, "pmodelid")){ PlayerInfo[playerid][pmodelid] = strval(value); }
  442. if (!strcmp(name, "pboneid")){ PlayerInfo[playerid][pboneid] = strval(value); }
  443. if (!strcmp(name, "pfOffsetX")){ PlayerInfo[playerid][pfOffsetX] = strval(value); }
  444. if (!strcmp(name, "pfOffsetY")){ PlayerInfo[playerid][pfOffsetY] = strval(value); }
  445. if (!strcmp(name, "pfOffsetY")){ PlayerInfo[playerid][pfOffsetZ] = strval(value); }
  446. if (!strcmp(name, "pfRotX")){ PlayerInfo[playerid][pfRotX] = strval(value); }
  447. if (!strcmp(name, "pfRotY")){ PlayerInfo[playerid][pfRotY] = strval(value); }
  448. if (!strcmp(name, "pfRotZ")){ PlayerInfo[playerid][pfRotZ] = strval(value); }
  449. if (!strcmp(name, "pfScaleX")){ PlayerInfo[playerid][pfScaleX] = strval(value); }
  450. if (!strcmp(name, "pfScaleY")){ PlayerInfo[playerid][pfScaleY] = strval(value); }
  451. if (!strcmp(name, "pfScaleZ")){ PlayerInfo[playerid][pfScaleZ] = strval(value); }
  452.  
  453. INI_Int("pindex",PlayerInfo[playerid][pindex]);
  454. INI_Int("pmodelid",PlayerInfo[playerid][pmodelid]);
  455. INI_Int("pboneid",PlayerInfo[playerid][pboneid]);
  456. INI_Float("pfOffsetX",PlayerInfo[playerid][pfOffsetX]);
  457. INI_Float("pfOffsetY",PlayerInfo[playerid][pfOffsetY]);
  458. INI_Float("pfOffsetZ",PlayerInfo[playerid][pfOffsetZ]);
  459. INI_Float("pfRotX",PlayerInfo[playerid][pfRotX]);
  460. INI_Float("pfRotY",PlayerInfo[playerid][pfRotY]);
  461. INI_Float("pfRotZ",PlayerInfo[playerid][pfRotZ]);
  462. INI_Float("pfScaleX",PlayerInfo[playerid][pfScaleX]);
  463. INI_Float("pfScaleY",PlayerInfo[playerid][pfScaleY]);
  464. INI_Float("pfScaleZ",PlayerInfo[playerid][pfScaleZ]);
  465.  
  466. return 1;
  467. }
  468.  
  469. public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid,Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,Float:fRotX, Float:fRotY, Float:fRotZ,Float:fScaleX, Float:fScaleY, Float:fScaleZ)
  470. {
  471.  
  472. new INI:File = INI_Open(UserPath(playerid));
  473. INI_WriteInt(File,"pindex",index);
  474. INI_WriteInt(File,"pmodelid",modelid);
  475. INI_WriteInt(File,"pboneid",boneid);
  476. INI_WriteFloat(File,"pfOffsetX",fOffsetX);
  477. INI_WriteFloat(File,"pfOffsetY",fOffsetY);
  478. INI_WriteFloat(File,"pfOffsetZ",fOffsetZ);
  479. INI_WriteFloat(File,"pfRotX",fRotX);
  480. INI_WriteFloat(File,"pfRotY",fRotY);
  481. INI_WriteFloat(File,"pfRotZ",fRotZ);
  482. INI_WriteFloat(File,"pfScaleX",fScaleX);
  483. INI_WriteFloat(File,"pfScaleY",fScaleY);
  484. INI_WriteFloat(File,"pfScaleZ",fScaleZ);
  485. INI_Close(File);
  486.  
  487. PlayerInfo[playerid][pindex] = index;
  488. PlayerInfo[playerid][pmodelid] = modelid;
  489. PlayerInfo[playerid][pboneid] = boneid;
  490. PlayerInfo[playerid][pfOffsetX] = fOffsetX;
  491. PlayerInfo[playerid][pfOffsetY] = fOffsetY;
  492. PlayerInfo[playerid][pfOffsetZ] = fOffsetZ;
  493. PlayerInfo[playerid][pfRotX] = fRotX;
  494. PlayerInfo[playerid][pfRotY] = fRotY;
  495. PlayerInfo[playerid][pfRotZ] = fRotZ;
  496. PlayerInfo[playerid][pfScaleX] = fScaleX;
  497. PlayerInfo[playerid][pfScaleY] = fScaleY;
  498. PlayerInfo[playerid][pfScaleZ] = fScaleZ;
  499.  
  500. SetPlayerAttachedObject(playerid,index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
  501. SendClientMessage(playerid, 0xFFFFFFFF, "You finished editing an attached object");
  502.  
  503. return 1;
  504. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement