Advertisement
Guest User

Excel Att. System - Fix2

a guest
May 21st, 2014
2,770
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.94 KB | None | 0 0
  1. //Player Attachments system by Excel
  2. //==============================================================================
  3. #include <a_samp>
  4. #include <mSelection>
  5. #include <sscanf2>
  6. #include <dini>
  7. #include <zcmd>
  8. //==============================================================================
  9. #define DIALOG_ATTACH_INDEX 13500
  10. #define DIALOG_ATTACH_INDEX_SELECTION DIALOG_ATTACH_INDEX+1
  11. #define DIALOG_ATTACH_EDITREPLACE DIALOG_ATTACH_INDEX+2
  12. #define DIALOG_ATTACH_MODEL_SELECTION DIALOG_ATTACH_INDEX+3
  13. #define DIALOG_ATTACH_BONE_SELECTION DIALOG_ATTACH_INDEX+4
  14. #define DIALOG_ATTACH_OBJECT_SELECTION DIALOG_ATTACH_INDEX+5
  15. #define DIALOG_ATTACH_OBJECT2_SELECTION DIALOG_ATTACH_INDEX+6
  16. //==============================================================================
  17. #define MAX_OSLOTS MAX_PLAYER_ATTACHED_OBJECTS
  18. //==============================================================================
  19. #define COL_WHITE "{FFFFFF}"
  20. #define COL_BLACK "{0E0101}"
  21. #define COL_GREY "{C3C3C3}"
  22. #define COL_GREEN "{6EF83C}"
  23. #define COL_RED "{F81414}"
  24. #define COL_YELLOW "{F3FF02}"
  25. #define COL_ORANGE "{FFAF00}"
  26. #define COL_LIME "{B7FF00}"
  27. #define COL_CYAN "{00FFEE}"
  28. #define COL_BLUE "{0049FF}"
  29. #define COL_MAGENTA "{F300FF}"
  30. #define COL_VIOLET "{B700FF}"
  31. #define COL_PINK "{FF00EA}"
  32. #define COL_MARONE "{A90202}"
  33. //==============================================================================
  34. new AttachmentObjectsList[] = {
  35. 18632,
  36. 18633,
  37. 18634,
  38. 18635,
  39. 18636,
  40. 18637,
  41. 18638,
  42. 18639,
  43. 18640,
  44. 18975,
  45. 19136,
  46. 19274,
  47. 18641,
  48. 18642,
  49. 18643,
  50. 18644,
  51. 18645,
  52. 18865,
  53. 18866,
  54. 18867,
  55. 18868,
  56. 18869,
  57. 18870,
  58. 18871,
  59. 18872,
  60. 18873,
  61. 18874,
  62. 18875,
  63. 18890,
  64. 18891,
  65. 18892,
  66. 18893,
  67. 18894,
  68. 18895,
  69. 18896,
  70. 18897,
  71. 18898,
  72. 18899,
  73. 18900,
  74. 18901,
  75. 18902,
  76. 18903,
  77. 18904,
  78. 18905,
  79. 18906,
  80. 18907,
  81. 18908,
  82. 18909,
  83. 18910,
  84. 18911,
  85. 18912,
  86. 18913,
  87. 18914,
  88. 18915,
  89. 18916,
  90. 18917,
  91. 18918,
  92. 18919,
  93. 18920,
  94. 18921,
  95. 18922,
  96. 18923,
  97. 18924,
  98. 18925,
  99. 18926,
  100. 18927,
  101. 18928,
  102. 18929,
  103. 18930,
  104. 18931,
  105. 18932,
  106. 18933,
  107. 18934,
  108. 18935,
  109. 18936,
  110. 18937,
  111. 18938,
  112. 18939,
  113. 18940,
  114. 18941,
  115. 18942,
  116. 18943,
  117. 18944,
  118. 18945,
  119. 18946,
  120. 18947,
  121. 18948,
  122. 18949,
  123. 18950,
  124. 18951,
  125. 18952,
  126. 18953,
  127. 18954,
  128. 18955,
  129. 18956,
  130. 18957,
  131. 18958,
  132. 18959,
  133. 18960,
  134. 18961,
  135. 18962,
  136. 18963,
  137. 18964,
  138. 18965,
  139. 18966,
  140. 18967,
  141. 18968,
  142. 18969,
  143. 18970,
  144. 18971,
  145. 18972,
  146. 18973,
  147. 18974,
  148. 18976,
  149. 18977,
  150. 18978,
  151. 18979,
  152. 19006,
  153. 19007,
  154. 19008,
  155. 19009,
  156. 19010,
  157. 19011,
  158. 19012,
  159. 19013,
  160. 19014,
  161. 19015,
  162. 19016,
  163. 19017,
  164. 19018,
  165. 19019,
  166. 19020,
  167. 19021,
  168. 19022,
  169. 19023,
  170. 19024,
  171. 19025,
  172. 19026,
  173. 19027,
  174. 19028,
  175. 19029,
  176. 19030,
  177. 19031,
  178. 19032,
  179. 19033,
  180. 19034,
  181. 19035,
  182. 19036,
  183. 19037,
  184. 19038,
  185. 19039,
  186. 19040,
  187. 19041,
  188. 19042,
  189. 19043,
  190. 19044,
  191. 19045,
  192. 19046,
  193. 19047,
  194. 19048,
  195. 19049,
  196. 19050,
  197. 19051,
  198. 19052,
  199. 19053,
  200. 19085,
  201. 19086,
  202. 19090,
  203. 19091,
  204. 19092,
  205. 19093,
  206. 19094,
  207. 19095,
  208. 19096,
  209. 19097,
  210. 19098,
  211. 19099,
  212. 19100,
  213. 19101,
  214. 19102,
  215. 19103,
  216. 19104,
  217. 19105,
  218. 19106,
  219. 19107,
  220. 19108,
  221. 19109,
  222. 19110,
  223. 19111,
  224. 19112,
  225. 19113,
  226. 19114,
  227. 19115,
  228. 19116,
  229. 19117,
  230. 19118,
  231. 19119,
  232. 19120,
  233. 19137,
  234. 19138,
  235. 19139,
  236. 19140,
  237. 19141,
  238. 19142,
  239. 19160,
  240. 19161,
  241. 19162,
  242. 19163,
  243. 19317,
  244. 19318,
  245. 19319,
  246. 19330,
  247. 19331,
  248. 19346,
  249. 19347,
  250. 19348,
  251. 19349,
  252. 19350,
  253. 19351,
  254. 19352,
  255. 19487,
  256. 19488,
  257. 19513,
  258. 19515,
  259. 331,
  260. 333,
  261. 334,
  262. 335,
  263. 336,
  264. 337,
  265. 338,
  266. 339,
  267. 341,
  268. 321,
  269. 322,
  270. 323,
  271. 324,
  272. 325,
  273. 326,
  274. 343,
  275. 346,
  276. 347,
  277. 348,
  278. 349,
  279. 350,
  280. 351,
  281. 352,
  282. 353,
  283. 355,
  284. 356,
  285. 372,
  286. 357,
  287. 358,
  288. 361,
  289. 363,
  290. 364,
  291. 365,
  292. 366,
  293. 367,
  294. 368,
  295. 369,
  296. 371
  297. };
  298. //==============================================================================
  299. new AttachmentBones[][24] = {
  300. {"Spine"},
  301. {"Head"},
  302. {"Left upper arm"},
  303. {"Right upper arm"},
  304. {"Left hand"},
  305. {"Right hand"},
  306. {"Left thigh"},
  307. {"Right thigh"},
  308. {"Left foot"},
  309. {"Right foot"},
  310. {"Right calf"},
  311. {"Left calf"},
  312. {"Left forearm"},
  313. {"Right forearm"},
  314. {"Left clavicle"},
  315. {"Right clavicle"},
  316. {"Neck"},
  317. {"Jaw"}
  318. };
  319. //==============================================================================
  320. CMD:o(playerid,params[])
  321. {
  322. new string[128];
  323. new dialog[500];
  324. for(new x;x<MAX_OSLOTS;x++)
  325. {
  326. if(IsPlayerAttachedObjectSlotUsed(playerid, x))
  327. { format(string, sizeof(string), ""COL_WHITE"Slot:%d :: "COL_GREEN"Used Slot\n", x); }
  328. else format(string, sizeof(string), ""COL_WHITE"Slot:%d\n", x);
  329. strcat(dialog,string);
  330. }
  331. ShowPlayerDialog(playerid, DIALOG_ATTACH_INDEX_SELECTION, DIALOG_STYLE_LIST,"Player Objects/Attachment: (Select Slot)", dialog, "Select", "Close(X)");
  332. return 1;
  333. }
  334. CMD:att(playerid,params[])
  335. {
  336. return cmd_o(playerid,params);
  337. }
  338. CMD:attachments(playerid,params[])
  339. {
  340. return cmd_o(playerid,params);
  341. }
  342. //==============================================================================
  343. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  344. {
  345. switch(dialogid)
  346. {
  347. case DIALOG_ATTACH_INDEX_SELECTION:
  348. {
  349. if(response)
  350. {
  351. if(IsPlayerAttachedObjectSlotUsed(playerid, listitem))
  352. {
  353. ShowPlayerDialog(playerid, DIALOG_ATTACH_EDITREPLACE, DIALOG_STYLE_MSGBOX, \
  354. "Player Objects/Attachment: (Delete/Edit)", ""COL_WHITE"Do you wish to edit the attachment in that slot, or delete it?", "Edit(!)", "Delete(X)");
  355. }
  356. else
  357. {
  358. ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT_SELECTION,DIALOG_STYLE_LIST,"Player Objects/Attachment: (Select Object Path)","Path:1 :: "COL_GREY"Server Objects Menu\n"COL_WHITE"Path:2 :: "COL_GREY"Custom Object","Next(>>)","Back(<<)");
  359. }
  360. SetPVarInt(playerid, "AttachmentIndexSel", listitem);
  361. }
  362. return 1;
  363. }
  364. case DIALOG_ATTACH_OBJECT_SELECTION:
  365. {
  366. if(!response)
  367. {
  368. cmd_o(playerid,"");
  369. }
  370. if(response)
  371. {
  372. if(listitem==0) ShowModelSelectionMenuEx(playerid, AttachmentObjectsList, 228+38, "Player Objects", DIALOG_ATTACH_MODEL_SELECTION, 0.0, 0.0, 0.0, 1.0, 0x00000099, 0x000000EE, 0xACCBF1FF);
  373. if(listitem==1) ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT2_SELECTION,DIALOG_STYLE_INPUT,"Player Objects/Attachment: (Insert objectid)",""COL_WHITE"Put your custom objectid below, You can also take help from ''http://wiki.sa-mp.com''.","Edit","Back(<<)");
  374. }
  375. }
  376. case DIALOG_ATTACH_OBJECT2_SELECTION:
  377. {
  378. if(!response)
  379. { ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT_SELECTION,DIALOG_STYLE_LIST,"Player Objects/Attachment: (Select Object Path)","Path:1 :: "COL_GREY"Server Objects Menu\n"COL_WHITE"Path:2 :: "COL_GREY"Custom Object","Next(>>)","Back(<<)"); }
  380. if(response)
  381. {
  382. if(!strlen(inputtext))return SendClientMessage(playerid,-1,"PLAYER: You can't leave the coloumn blank."),ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT2_SELECTION,DIALOG_STYLE_INPUT,"Player Objects/Attachment: (Insert objectid)",""COL_WHITE"Put your custom objectid below, You can also take help from ''http://wiki.sa-mp.com''.","Edit","Back(<<)");
  383. if(!IsNumeric(inputtext)) return SendClientMessage(playerid,-1,"PLAYER: You can't fill a object name, only object id's allowed."),ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT2_SELECTION,DIALOG_STYLE_INPUT,"Player Objects/Attachment: (Insert objectid)",""COL_WHITE"Put your custom objectid below, You can also take help from ''http://wiki.sa-mp.com''.","Edit","Back(<<)");
  384. new obj;
  385. if(!sscanf(inputtext, "i", obj))
  386. {
  387. if(GetPVarInt(playerid, "AttachmentUsed") == 1) EditAttachedObject(playerid, obj);
  388. else
  389. {
  390. SetPVarInt(playerid, "AttachmentModelSel", obj);
  391. new string[256+1];
  392. new dialog[500];
  393. for(new x;x<sizeof(AttachmentBones);x++)
  394. {
  395. format(string, sizeof(string), "Bone:%s\n", AttachmentBones[x]);
  396. strcat(dialog,string);
  397. }
  398. ShowPlayerDialog(playerid, DIALOG_ATTACH_BONE_SELECTION, DIALOG_STYLE_LIST, \
  399. "{FF0000}Attachment Modification - Bone Selection", dialog, "Select", "Cancel");
  400. }
  401. }
  402. }
  403. }
  404. case DIALOG_ATTACH_EDITREPLACE:
  405. {
  406. if(response) EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  407. else
  408. {
  409. RemovePlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  410. new file[256];
  411. new name[24];
  412. new x=GetPVarInt(playerid, "AttachmentIndexSel");
  413. new f1[15],f2[15],f3[15],f4[15],f5[15],f6[15],f7[15],f8[15],f9[15],f10[15],f11[15];
  414. GetPlayerName(playerid,name,24);
  415. format(file,sizeof(file),"Player Objects/%s.ini",name);
  416. if(!dini_Exists(file)) return 1;
  417. format(f1,15,"O_Model_%d",x);
  418. format(f2,15,"O_Bone_%d",x);
  419. format(f3,15,"O_OffX_%d",x);
  420. format(f4,15,"O_OffY_%d",x);
  421. format(f5,15,"O_OffZ_%d",x);
  422. format(f6,15,"O_RotX_%d",x);
  423. format(f7,15,"O_RotY_%d",x);
  424. format(f8,15,"O_RotZ_%d",x);
  425. format(f9,15,"O_ScaleX_%d",x);
  426. format(f10,15,"O_ScaleY_%d",x);
  427. format(f11,15,"O_ScaleZ_%d",x);
  428. dini_Unset(file,f1);
  429. dini_Unset(file,f2);
  430. dini_Unset(file,f3);
  431. dini_Unset(file,f4);
  432. dini_Unset(file,f5);
  433. dini_Unset(file,f6);
  434. dini_Unset(file,f7);
  435. dini_Unset(file,f8);
  436. dini_Unset(file,f9);
  437. dini_Unset(file,f10);
  438. dini_Unset(file,f11);
  439. DeletePVar(playerid, "AttachmentIndexSel");
  440. }
  441. return 1;
  442. }
  443. case DIALOG_ATTACH_BONE_SELECTION:
  444. {
  445. if(response)
  446. {
  447. SetPlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"), GetPVarInt(playerid, "AttachmentModelSel"), listitem+1);
  448. EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  449. SendClientMessage(playerid, 0xFFFFFFFF, "PLAYER: You can also hold SPAWN and use MOUSE to view from either sides.");
  450. }
  451. DeletePVar(playerid, "AttachmentIndexSel");
  452. DeletePVar(playerid, "AttachmentModelSel");
  453. return 1;
  454. }
  455. }
  456. return 0;
  457. }
  458. //==============================================================================
  459. public OnPlayerEditAttachedObject( playerid, response, index, modelid, boneid,
  460. Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,
  461. Float:fRotX, Float:fRotY, Float:fRotZ,
  462. Float:fScaleX, Float:fScaleY, Float:fScaleZ )
  463. {
  464. /*new debug_string[256+1];
  465. format(debug_string,256,"SetPlayerAttachedObject(playerid,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f)",
  466. index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);*/
  467.  
  468. SetPlayerAttachedObject(playerid,index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
  469. SendClientMessage(playerid, 0xFFFFFFFF, "PLAYER: You have finished editing attachments, it has been saved to your database.");
  470.  
  471. new file[256];
  472. new name[24];
  473. new f1[15],f2[15],f3[15],f4[15],f5[15],f6[15],f7[15],f8[15],f9[15],f10[15],f11[15];
  474. GetPlayerName(playerid,name,24);
  475. format(file,sizeof(file),"Player Objects/%s.ini",name);
  476. if(!dini_Exists(file)) return 1;
  477. format(f1,15,"O_Model_%d",index);
  478. format(f2,15,"O_Bone_%d",index);
  479. format(f3,15,"O_OffX_%d",index);
  480. format(f4,15,"O_OffY_%d",index);
  481. format(f5,15,"O_OffZ_%d",index);
  482. format(f6,15,"O_RotX_%d",index);
  483. format(f7,15,"O_RotY_%d",index);
  484. format(f8,15,"O_RotZ_%d",index);
  485. format(f9,15,"O_ScaleX_%d",index);
  486. format(f10,15,"O_ScaleY_%d",index);
  487. format(f11,15,"O_ScaleZ_%d",index);
  488. dini_IntSet(file,f1,modelid);
  489. dini_IntSet(file,f2,boneid);
  490. dini_FloatSet(file,f3,fOffsetX);
  491. dini_FloatSet(file,f4,fOffsetY);
  492. dini_FloatSet(file,f5,fOffsetZ);
  493. dini_FloatSet(file,f6,fRotX);
  494. dini_FloatSet(file,f7,fRotY);
  495. dini_FloatSet(file,f8,fRotZ);
  496. dini_FloatSet(file,f9,fScaleX);
  497. dini_FloatSet(file,f10,fScaleY);
  498. dini_FloatSet(file,f11,fScaleZ);
  499. return 1;
  500. }
  501. //==============================================================================
  502. public OnPlayerConnect(playerid)
  503. {
  504. new file[256];
  505. new name[24];
  506. new f1[15],f2[15],f3[15],f4[15],f5[15],f6[15],f7[15],f8[15],f9[15],f10[15],f11[15];
  507. GetPlayerName(playerid,name,24);
  508. format(file,sizeof(file),"Player Objects/%s.ini",name);
  509. if(!dini_Exists(file))
  510. {
  511. dini_Create(file);
  512. for(new x;x<MAX_OSLOTS;x++)
  513. {
  514. if(IsPlayerAttachedObjectSlotUsed(playerid, x))
  515. {
  516. format(f1,15,"O_Model_%d",x);
  517. format(f2,15,"O_Bone_%d",x);
  518. format(f3,15,"O_OffX_%d",x);
  519. format(f4,15,"O_OffY_%d",x);
  520. format(f5,15,"O_OffZ_%d",x);
  521. format(f6,15,"O_RotX_%d",x);
  522. format(f7,15,"O_RotY_%d",x);
  523. format(f8,15,"O_RotZ_%d",x);
  524. format(f9,15,"O_ScaleX_%d",x);
  525. format(f10,15,"O_ScaleY_%d",x);
  526. format(f11,15,"O_ScaleZ_%d",x);
  527. dini_IntSet(file,f1,0);
  528. dini_IntSet(file,f2,0);
  529. dini_FloatSet(file,f3,0.0);
  530. dini_FloatSet(file,f4,0.0);
  531. dini_FloatSet(file,f5,0.0);
  532. dini_FloatSet(file,f6,0.0);
  533. dini_FloatSet(file,f7,0.0);
  534. dini_FloatSet(file,f8,0.0);
  535. dini_FloatSet(file,f9,0.0);
  536. dini_FloatSet(file,f10,0.0);
  537. dini_FloatSet(file,f11,0.0);
  538. }
  539. }
  540. }
  541. }
  542. //==============================================================================
  543. public OnPlayerSpawn(playerid)
  544. {
  545. new file[256];
  546. new name[24];
  547. new f1[15],f2[15],f3[15],f4[15],f5[15],f6[15],f7[15],f8[15],f9[15],f10[15],f11[15];
  548. GetPlayerName(playerid,name,24);
  549. format(file,sizeof(file),"Player Objects/%s.ini",name);
  550. if(!dini_Exists(file)) return 1;
  551. for(new x;x<MAX_OSLOTS;x++)
  552. {
  553. format(f1,15,"O_Model_%d",x);
  554. format(f2,15,"O_Bone_%d",x);
  555. format(f3,15,"O_OffX_%d",x);
  556. format(f4,15,"O_OffY_%d",x);
  557. format(f5,15,"O_OffZ_%d",x);
  558. format(f6,15,"O_RotX_%d",x);
  559. format(f7,15,"O_RotY_%d",x);
  560. format(f8,15,"O_RotZ_%d",x);
  561. format(f9,15,"O_ScaleX_%d",x);
  562. format(f10,15,"O_ScaleY_%d",x);
  563. format(f11,15,"O_ScaleZ_%d",x);
  564. if(dini_Int(file,f1)!=0)
  565. {
  566. SetPlayerAttachedObject(playerid,x,dini_Int(file,f1),dini_Int(file,f2),dini_Float(file,f3),dini_Float(file,f4),dini_Float(file,f5),dini_Float(file,f6),dini_Float(file,f7),dini_Float(file,f8),dini_Float(file,f9),dini_Float(file,f10),dini_Float(file,f11));
  567. }
  568. }
  569. return 1;
  570. }
  571. //==============================================================================
  572. public OnPlayerModelSelectionEx(playerid, response, extraid, modelid)
  573. {
  574. if(extraid==DIALOG_ATTACH_MODEL_SELECTION)
  575. {
  576. if(!response)
  577. { ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT_SELECTION,DIALOG_STYLE_LIST,"Player Objects/Attachment: (Select Object Path)","Path:1 :: "COL_GREY"Server Objects Menu\n"COL_WHITE"Path:2 :: "COL_GREY"Custom Object","Next(>>)","Back(<<)"); }
  578. if(response)
  579. {
  580. if(GetPVarInt(playerid, "AttachmentUsed") == 1) EditAttachedObject(playerid, modelid);
  581. else
  582. {
  583. SetPVarInt(playerid, "AttachmentModelSel", modelid);
  584. new string[256+1];
  585. new dialog[500];
  586. for(new x;x<sizeof(AttachmentBones);x++)
  587. {
  588. format(string, sizeof(string), "Bone:%s\n", AttachmentBones[x]);
  589. strcat(dialog,string);
  590. }
  591. ShowPlayerDialog(playerid, DIALOG_ATTACH_BONE_SELECTION, DIALOG_STYLE_LIST, \
  592. "{FF0000}Attachment Modification - Bone Selection", dialog, "Select", "Cancel");
  593. }//else DeletePVar(playerid, "AttachmentIndexSel");
  594. }
  595. }
  596. return 1;
  597. }
  598. //==============================================================================
  599. stock IsNumeric(string[])
  600. {
  601. for (new i = 0, j = strlen(string); i < j; i++)
  602. {
  603. if (string[i] > '9' || string[i] < '0') return 0;
  604. }
  605. return 1;
  606. }
  607. //==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement