Advertisement
Guest User

Excel Att. system - Fix2

a guest
May 21st, 2014
2,613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.29 KB | None | 0 0
  1. //Player Attachments system by Excel
  2. //==============================================================================
  3. #include <a_samp>
  4. #include <sscanf2>
  5. #include <dini>
  6. #include <zcmd>
  7. //==============================================================================
  8. #define DIALOG_ATTACH_INDEX 13500
  9. #define DIALOG_ATTACH_INDEX_SELECTION DIALOG_ATTACH_INDEX+1
  10. #define DIALOG_ATTACH_EDITREPLACE DIALOG_ATTACH_INDEX+2
  11. #define DIALOG_ATTACH_MODEL_SELECTION DIALOG_ATTACH_INDEX+3
  12. #define DIALOG_ATTACH_BONE_SELECTION DIALOG_ATTACH_INDEX+4
  13. #define DIALOG_ATTACH_OBJECT_SELECTION DIALOG_ATTACH_INDEX+5
  14. #define DIALOG_ATTACH_OBJECT2_SELECTION DIALOG_ATTACH_INDEX+6
  15. //==============================================================================
  16. #define MAX_OSLOTS MAX_PLAYER_ATTACHED_OBJECTS
  17. //==============================================================================
  18. #define COL_WHITE "{FFFFFF}"
  19. #define COL_BLACK "{0E0101}"
  20. #define COL_GREY "{C3C3C3}"
  21. #define COL_GREEN "{6EF83C}"
  22. #define COL_RED "{F81414}"
  23. #define COL_YELLOW "{F3FF02}"
  24. #define COL_ORANGE "{FFAF00}"
  25. #define COL_LIME "{B7FF00}"
  26. #define COL_CYAN "{00FFEE}"
  27. #define COL_BLUE "{0049FF}"
  28. #define COL_MAGENTA "{F300FF}"
  29. #define COL_VIOLET "{B700FF}"
  30. #define COL_PINK "{FF00EA}"
  31. #define COL_MARONE "{A90202}"
  32. //==============================================================================
  33. //-----[ mSelection ]-----
  34. // settings static lists
  35. #define mS_TOTAL_ITEMS 1000 // Max amount of items from all lists
  36. #define mS_TOTAL_LISTS 20 // Max amount of lists
  37. #define mS_TOTAL_ROT_ZOOM 100 // Max amount of items using extra information like zoom or rotations
  38.  
  39. // settings dynamic per player lists
  40. #define mS_CUSTOM_MAX_ITEMS 2000
  41. new gCustomList[MAX_PLAYERS][mS_CUSTOM_MAX_ITEMS];
  42.  
  43. #define mS_INVALID_LISTID mS_TOTAL_LISTS
  44. #define mS_CUSTOM_LISTID (mS_TOTAL_LISTS+1)
  45.  
  46. #define mS_NEXT_TEXT "Next"
  47. #define mS_PREV_TEXT "Prev"
  48. #define mS_CANCEL_TEXT "Cancel"
  49.  
  50. #define mS_SELECTION_ITEMS 21
  51. #define mS_ITEMS_PER_LINE 7
  52. #define mS_DIALOG_BASE_X 75.0
  53. #define mS_DIALOG_BASE_Y 130.0
  54. #define mS_DIALOG_WIDTH 550.0
  55. #define mS_DIALOG_HEIGHT 180.0
  56. #define mS_SPRITE_DIM_X 60.0
  57. #define mS_SPRITE_DIM_Y 70.0
  58. //----------------------
  59. //==============================================================================
  60. new AttachmentObjectsList[] = {
  61. 18632,
  62. 18633,
  63. 18634,
  64. 18635,
  65. 18636,
  66. 18637,
  67. 18638,
  68. 18639,
  69. 18640,
  70. 18975,
  71. 19136,
  72. 19274,
  73. 18641,
  74. 18642,
  75. 18643,
  76. 18644,
  77. 18645,
  78. 18865,
  79. 18866,
  80. 18867,
  81. 18868,
  82. 18869,
  83. 18870,
  84. 18871,
  85. 18872,
  86. 18873,
  87. 18874,
  88. 18875,
  89. 18890,
  90. 18891,
  91. 18892,
  92. 18893,
  93. 18894,
  94. 18895,
  95. 18896,
  96. 18897,
  97. 18898,
  98. 18899,
  99. 18900,
  100. 18901,
  101. 18902,
  102. 18903,
  103. 18904,
  104. 18905,
  105. 18906,
  106. 18907,
  107. 18908,
  108. 18909,
  109. 18910,
  110. 18911,
  111. 18912,
  112. 18913,
  113. 18914,
  114. 18915,
  115. 18916,
  116. 18917,
  117. 18918,
  118. 18919,
  119. 18920,
  120. 18921,
  121. 18922,
  122. 18923,
  123. 18924,
  124. 18925,
  125. 18926,
  126. 18927,
  127. 18928,
  128. 18929,
  129. 18930,
  130. 18931,
  131. 18932,
  132. 18933,
  133. 18934,
  134. 18935,
  135. 18936,
  136. 18937,
  137. 18938,
  138. 18939,
  139. 18940,
  140. 18941,
  141. 18942,
  142. 18943,
  143. 18944,
  144. 18945,
  145. 18946,
  146. 18947,
  147. 18948,
  148. 18949,
  149. 18950,
  150. 18951,
  151. 18952,
  152. 18953,
  153. 18954,
  154. 18955,
  155. 18956,
  156. 18957,
  157. 18958,
  158. 18959,
  159. 18960,
  160. 18961,
  161. 18962,
  162. 18963,
  163. 18964,
  164. 18965,
  165. 18966,
  166. 18967,
  167. 18968,
  168. 18969,
  169. 18970,
  170. 18971,
  171. 18972,
  172. 18973,
  173. 18974,
  174. 18976,
  175. 18977,
  176. 18978,
  177. 18979,
  178. 19006,
  179. 19007,
  180. 19008,
  181. 19009,
  182. 19010,
  183. 19011,
  184. 19012,
  185. 19013,
  186. 19014,
  187. 19015,
  188. 19016,
  189. 19017,
  190. 19018,
  191. 19019,
  192. 19020,
  193. 19021,
  194. 19022,
  195. 19023,
  196. 19024,
  197. 19025,
  198. 19026,
  199. 19027,
  200. 19028,
  201. 19029,
  202. 19030,
  203. 19031,
  204. 19032,
  205. 19033,
  206. 19034,
  207. 19035,
  208. 19036,
  209. 19037,
  210. 19038,
  211. 19039,
  212. 19040,
  213. 19041,
  214. 19042,
  215. 19043,
  216. 19044,
  217. 19045,
  218. 19046,
  219. 19047,
  220. 19048,
  221. 19049,
  222. 19050,
  223. 19051,
  224. 19052,
  225. 19053,
  226. 19085,
  227. 19086,
  228. 19090,
  229. 19091,
  230. 19092,
  231. 19093,
  232. 19094,
  233. 19095,
  234. 19096,
  235. 19097,
  236. 19098,
  237. 19099,
  238. 19100,
  239. 19101,
  240. 19102,
  241. 19103,
  242. 19104,
  243. 19105,
  244. 19106,
  245. 19107,
  246. 19108,
  247. 19109,
  248. 19110,
  249. 19111,
  250. 19112,
  251. 19113,
  252. 19114,
  253. 19115,
  254. 19116,
  255. 19117,
  256. 19118,
  257. 19119,
  258. 19120,
  259. 19137,
  260. 19138,
  261. 19139,
  262. 19140,
  263. 19141,
  264. 19142,
  265. 19160,
  266. 19161,
  267. 19162,
  268. 19163,
  269. 19317,
  270. 19318,
  271. 19319,
  272. 19330,
  273. 19331,
  274. 19346,
  275. 19347,
  276. 19348,
  277. 19349,
  278. 19350,
  279. 19351,
  280. 19352,
  281. 19487,
  282. 19488,
  283. 19513,
  284. 19515,
  285. 331,
  286. 333,
  287. 334,
  288. 335,
  289. 336,
  290. 337,
  291. 338,
  292. 339,
  293. 341,
  294. 321,
  295. 322,
  296. 323,
  297. 324,
  298. 325,
  299. 326,
  300. 343,
  301. 346,
  302. 347,
  303. 348,
  304. 349,
  305. 350,
  306. 351,
  307. 352,
  308. 353,
  309. 355,
  310. 356,
  311. 372,
  312. 357,
  313. 358,
  314. 361,
  315. 363,
  316. 364,
  317. 365,
  318. 366,
  319. 367,
  320. 368,
  321. 369,
  322. 371
  323. };
  324. //==============================================================================
  325. new AttachmentBones[][24] = {
  326. {"Spine"},
  327. {"Head"},
  328. {"Left upper arm"},
  329. {"Right upper arm"},
  330. {"Left hand"},
  331. {"Right hand"},
  332. {"Left thigh"},
  333. {"Right thigh"},
  334. {"Left foot"},
  335. {"Right foot"},
  336. {"Right calf"},
  337. {"Left calf"},
  338. {"Left forearm"},
  339. {"Right forearm"},
  340. {"Left clavicle"},
  341. {"Right clavicle"},
  342. {"Neck"},
  343. {"Jaw"}
  344. };
  345. //==============================================================================
  346. //-----[ mSelection ]-----
  347. new PlayerText:gCurrentPageTextDrawId[MAX_PLAYERS];
  348. new PlayerText:gHeaderTextDrawId[MAX_PLAYERS];
  349. new PlayerText:gBackgroundTextDrawId[MAX_PLAYERS];
  350. new PlayerText:gNextButtonTextDrawId[MAX_PLAYERS];
  351. new PlayerText:gPrevButtonTextDrawId[MAX_PLAYERS];
  352. new PlayerText:gCancelButtonTextDrawId[MAX_PLAYERS];
  353. new PlayerText:gSelectionItems[MAX_PLAYERS][mS_SELECTION_ITEMS];
  354. new gSelectionItemsTag[MAX_PLAYERS][mS_SELECTION_ITEMS];
  355. new gItemAt[MAX_PLAYERS];
  356.  
  357. #define mS_LIST_START 0
  358. #define mS_LIST_END 1
  359. new gLists[mS_TOTAL_LISTS][2]; // list information start/end index
  360.  
  361. #define mS_ITEM_MODEL 0
  362. #define mS_ITEM_ROT_ZOOM_ID 1
  363. new gItemList[mS_TOTAL_ITEMS][2];
  364.  
  365. new Float:gRotZoom[mS_TOTAL_ROT_ZOOM][4]; // Array for saving rotation and zoom info
  366. new gItemAmount = 0; // Amount of items used
  367. new gListAmount = 0; // Amount of lists used
  368. new gRotZoomAmount = 0; // Amount of Rotation/Zoom informations used
  369. //----------------------
  370. //==============================================================================
  371. //-----[ mSelection ]-----
  372. /*Functions to be used
  373. LoadModelSelectionMenu(f_name[])
  374. HideModelSelectionMenu(playerid)
  375. ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
  376. ShowModelSelectionMenuEx(playerid, items_array[], item_amount, header_text[], extraid, Float:Xrot = 0.0, Float:Yrot = 0.0, Float:Zrot = 0.0, Float:mZoom = 1.0, dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
  377. */
  378. // Callbacks
  379. forward OnPlayerModelSelection(playerid, response, listid, modelid2);
  380. forward OnPlayerModelSelectionEx(playerid, response, extraid, modelid2);
  381. //----------------------
  382. //==============================================================================
  383. CMD:o(playerid,params[])
  384. {
  385. new string[128];
  386. new dialog[500];
  387. for(new x;x<MAX_OSLOTS;x++)
  388. {
  389. if(IsPlayerAttachedObjectSlotUsed(playerid, x))
  390. { format(string, sizeof(string), ""COL_WHITE"Slot:%d :: "COL_GREEN"Used Slot\n", x); }
  391. else format(string, sizeof(string), ""COL_WHITE"Slot:%d\n", x);
  392. strcat(dialog,string);
  393. }
  394. ShowPlayerDialog(playerid, DIALOG_ATTACH_INDEX_SELECTION, DIALOG_STYLE_LIST,"Player Objects/Attachment: (Select Slot)", dialog, "Select", "Close(X)");
  395. return 1;
  396. }
  397. CMD:att(playerid,params[])
  398. {
  399. return cmd_o(playerid,params);
  400. }
  401. CMD:attachments(playerid,params[])
  402. {
  403. return cmd_o(playerid,params);
  404. }
  405. //==============================================================================
  406. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  407. {
  408. switch(dialogid)
  409. {
  410. case DIALOG_ATTACH_INDEX_SELECTION:
  411. {
  412. if(response)
  413. {
  414. if(IsPlayerAttachedObjectSlotUsed(playerid, listitem))
  415. {
  416. ShowPlayerDialog(playerid, DIALOG_ATTACH_EDITREPLACE, DIALOG_STYLE_MSGBOX, \
  417. "Player Objects/Attachment: (Delete/Edit)", ""COL_WHITE"Do you wish to edit the attachment in that slot, or delete it?", "Edit(!)", "Delete(X)");
  418. }
  419. else
  420. {
  421. 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(<<)");
  422. }
  423. SetPVarInt(playerid, "AttachmentIndexSel", listitem);
  424. }
  425. return 1;
  426. }
  427. case DIALOG_ATTACH_OBJECT_SELECTION:
  428. {
  429. if(!response)
  430. {
  431. cmd_o(playerid,"");
  432. }
  433. if(response)
  434. {
  435. 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);
  436. 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(<<)");
  437. }
  438. }
  439. case DIALOG_ATTACH_OBJECT2_SELECTION:
  440. {
  441. if(!response)
  442. { 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(<<)"); }
  443. if(response)
  444. {
  445. 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(<<)");
  446. 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(<<)");
  447. new obj;
  448. if(!sscanf(inputtext, "i", obj))
  449. {
  450. if(GetPVarInt(playerid, "AttachmentUsed") == 1) EditAttachedObject(playerid, obj);
  451. else
  452. {
  453. SetPVarInt(playerid, "AttachmentModelSel", obj);
  454. new string[256+1];
  455. new dialog[500];
  456. for(new x;x<sizeof(AttachmentBones);x++)
  457. {
  458. format(string, sizeof(string), "Bone:%s\n", AttachmentBones[x]);
  459. strcat(dialog,string);
  460. }
  461. ShowPlayerDialog(playerid, DIALOG_ATTACH_BONE_SELECTION, DIALOG_STYLE_LIST, \
  462. "{FF0000}Attachment Modification - Bone Selection", dialog, "Select", "Cancel");
  463. }
  464. }
  465. }
  466. }
  467. case DIALOG_ATTACH_EDITREPLACE:
  468. {
  469. if(response) EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  470. else
  471. {
  472. RemovePlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  473. new file[256];
  474. new name[24];
  475. new x=GetPVarInt(playerid, "AttachmentIndexSel");
  476. new f1[15],f2[15],f3[15],f4[15],f5[15],f6[15],f7[15],f8[15],f9[15],f10[15],f11[15];
  477. GetPlayerName(playerid,name,24);
  478. format(file,sizeof(file),"Player Objects/%s.ini",name);
  479. if(!dini_Exists(file)) return 1;
  480. format(f1,15,"O_Model_%d",x);
  481. format(f2,15,"O_Bone_%d",x);
  482. format(f3,15,"O_OffX_%d",x);
  483. format(f4,15,"O_OffY_%d",x);
  484. format(f5,15,"O_OffZ_%d",x);
  485. format(f6,15,"O_RotX_%d",x);
  486. format(f7,15,"O_RotY_%d",x);
  487. format(f8,15,"O_RotZ_%d",x);
  488. format(f9,15,"O_ScaleX_%d",x);
  489. format(f10,15,"O_ScaleY_%d",x);
  490. format(f11,15,"O_ScaleZ_%d",x);
  491. dini_Unset(file,f1);
  492. dini_Unset(file,f2);
  493. dini_Unset(file,f3);
  494. dini_Unset(file,f4);
  495. dini_Unset(file,f5);
  496. dini_Unset(file,f6);
  497. dini_Unset(file,f7);
  498. dini_Unset(file,f8);
  499. dini_Unset(file,f9);
  500. dini_Unset(file,f10);
  501. dini_Unset(file,f11);
  502. DeletePVar(playerid, "AttachmentIndexSel");
  503. }
  504. return 1;
  505. }
  506. case DIALOG_ATTACH_BONE_SELECTION:
  507. {
  508. if(response)
  509. {
  510. SetPlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"), GetPVarInt(playerid, "AttachmentModelSel"), listitem+1);
  511. EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  512. SendClientMessage(playerid, 0xFFFFFFFF, "PLAYER: You can also hold SPAWN and use MOUSE to view from either sides.");
  513. }
  514. DeletePVar(playerid, "AttachmentIndexSel");
  515. DeletePVar(playerid, "AttachmentModelSel");
  516. return 1;
  517. }
  518. }
  519. return 0;
  520. }
  521. //==============================================================================
  522. public OnPlayerEditAttachedObject( playerid, response, index, modelid, boneid,
  523. Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,
  524. Float:fRotX, Float:fRotY, Float:fRotZ,
  525. Float:fScaleX, Float:fScaleY, Float:fScaleZ )
  526. {
  527. /*new debug_string[256+1];
  528. format(debug_string,256,"SetPlayerAttachedObject(playerid,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f)",
  529. index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);*/
  530.  
  531. SetPlayerAttachedObject(playerid,index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
  532. SendClientMessage(playerid, 0xFFFFFFFF, "PLAYER: You have finished editing attachments, it has been saved to your database.");
  533.  
  534. new file[256];
  535. new name[24];
  536. new f1[15],f2[15],f3[15],f4[15],f5[15],f6[15],f7[15],f8[15],f9[15],f10[15],f11[15];
  537. GetPlayerName(playerid,name,24);
  538. format(file,sizeof(file),"Player Objects/%s.ini",name);
  539. if(!dini_Exists(file)) return 1;
  540. format(f1,15,"O_Model_%d",index);
  541. format(f2,15,"O_Bone_%d",index);
  542. format(f3,15,"O_OffX_%d",index);
  543. format(f4,15,"O_OffY_%d",index);
  544. format(f5,15,"O_OffZ_%d",index);
  545. format(f6,15,"O_RotX_%d",index);
  546. format(f7,15,"O_RotY_%d",index);
  547. format(f8,15,"O_RotZ_%d",index);
  548. format(f9,15,"O_ScaleX_%d",index);
  549. format(f10,15,"O_ScaleY_%d",index);
  550. format(f11,15,"O_ScaleZ_%d",index);
  551. dini_IntSet(file,f1,modelid);
  552. dini_IntSet(file,f2,boneid);
  553. dini_FloatSet(file,f3,fOffsetX);
  554. dini_FloatSet(file,f4,fOffsetY);
  555. dini_FloatSet(file,f5,fOffsetZ);
  556. dini_FloatSet(file,f6,fRotX);
  557. dini_FloatSet(file,f7,fRotY);
  558. dini_FloatSet(file,f8,fRotZ);
  559. dini_FloatSet(file,f9,fScaleX);
  560. dini_FloatSet(file,f10,fScaleY);
  561. dini_FloatSet(file,f11,fScaleZ);
  562. return 1;
  563. }
  564. //==============================================================================
  565. public OnPlayerConnect(playerid)
  566. {
  567. //-----[ mSelection ]-----
  568. // Init all of the textdraw related globals
  569. gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  570. gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  571. gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  572. gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  573. gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  574. gCancelButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  575.  
  576. for(new x=0; x < mS_SELECTION_ITEMS; x++) {
  577. gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
  578. }
  579.  
  580. gItemAt[playerid] = 0;
  581. //----------------------
  582.  
  583. new file[256];
  584. new name[24];
  585. new f1[15],f2[15],f3[15],f4[15],f5[15],f6[15],f7[15],f8[15],f9[15],f10[15],f11[15];
  586. GetPlayerName(playerid,name,24);
  587. format(file,sizeof(file),"Player Objects/%s.ini",name);
  588. if(!dini_Exists(file))
  589. {
  590. dini_Create(file);
  591. for(new x;x<MAX_OSLOTS;x++)
  592. {
  593. if(IsPlayerAttachedObjectSlotUsed(playerid, x))
  594. {
  595. format(f1,15,"O_Model_%d",x);
  596. format(f2,15,"O_Bone_%d",x);
  597. format(f3,15,"O_OffX_%d",x);
  598. format(f4,15,"O_OffY_%d",x);
  599. format(f5,15,"O_OffZ_%d",x);
  600. format(f6,15,"O_RotX_%d",x);
  601. format(f7,15,"O_RotY_%d",x);
  602. format(f8,15,"O_RotZ_%d",x);
  603. format(f9,15,"O_ScaleX_%d",x);
  604. format(f10,15,"O_ScaleY_%d",x);
  605. format(f11,15,"O_ScaleZ_%d",x);
  606. dini_IntSet(file,f1,0);
  607. dini_IntSet(file,f2,0);
  608. dini_FloatSet(file,f3,0.0);
  609. dini_FloatSet(file,f4,0.0);
  610. dini_FloatSet(file,f5,0.0);
  611. dini_FloatSet(file,f6,0.0);
  612. dini_FloatSet(file,f7,0.0);
  613. dini_FloatSet(file,f8,0.0);
  614. dini_FloatSet(file,f9,0.0);
  615. dini_FloatSet(file,f10,0.0);
  616. dini_FloatSet(file,f11,0.0);
  617. }
  618. }
  619. }
  620. }
  621. //==============================================================================
  622. public OnPlayerSpawn(playerid)
  623. {
  624. new file[256];
  625. new name[24];
  626. new f1[15],f2[15],f3[15],f4[15],f5[15],f6[15],f7[15],f8[15],f9[15],f10[15],f11[15];
  627. GetPlayerName(playerid,name,24);
  628. format(file,sizeof(file),"Player Objects/%s.ini",name);
  629. if(!dini_Exists(file)) return 1;
  630. for(new x;x<MAX_OSLOTS;x++)
  631. {
  632. format(f1,15,"O_Model_%d",x);
  633. format(f2,15,"O_Bone_%d",x);
  634. format(f3,15,"O_OffX_%d",x);
  635. format(f4,15,"O_OffY_%d",x);
  636. format(f5,15,"O_OffZ_%d",x);
  637. format(f6,15,"O_RotX_%d",x);
  638. format(f7,15,"O_RotY_%d",x);
  639. format(f8,15,"O_RotZ_%d",x);
  640. format(f9,15,"O_ScaleX_%d",x);
  641. format(f10,15,"O_ScaleY_%d",x);
  642. format(f11,15,"O_ScaleZ_%d",x);
  643. if(dini_Int(file,f1)!=0)
  644. {
  645. 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));
  646. }
  647. }
  648. return 1;
  649. }
  650. //==============================================================================
  651. public OnPlayerModelSelectionEx(playerid, response, extraid, modelid2)
  652. {
  653. if(extraid==DIALOG_ATTACH_MODEL_SELECTION)
  654. {
  655. if(!response)
  656. { 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(<<)"); }
  657. if(response)
  658. {
  659. if(GetPVarInt(playerid, "AttachmentUsed") == 1) EditAttachedObject(playerid, modelid2);
  660. else
  661. {
  662. SetPVarInt(playerid, "AttachmentModelSel", modelid2);
  663. new string[256+1];
  664. new dialog[500];
  665. for(new x;x<sizeof(AttachmentBones);x++)
  666. {
  667. format(string, sizeof(string), "Bone:%s\n", AttachmentBones[x]);
  668. strcat(dialog,string);
  669. }
  670. ShowPlayerDialog(playerid, DIALOG_ATTACH_BONE_SELECTION, DIALOG_STYLE_LIST, \
  671. "{FF0000}Attachment Modification - Bone Selection", dialog, "Select", "Cancel");
  672. }//else DeletePVar(playerid, "AttachmentIndexSel");
  673. }
  674. }
  675. return 1;
  676. }
  677. //==============================================================================
  678. stock IsNumeric(string[])
  679. {
  680. for (new i = 0, j = strlen(string); i < j; i++)
  681. {
  682. if (string[i] > '9' || string[i] < '0') return 0;
  683. }
  684. return 1;
  685. }
  686. //==============================================================================
  687. //-----[ mSelection ]-----
  688. stock SetPlayerPosEx(playerid,Float:x,Float:y,Float:z)
  689. {
  690. TogglePlayerControllable(playerid,false);
  691. SetPlayerPos(playerid,x,y,z);
  692. KillTimer(spawntimer[playerid]);
  693. spawntimer[playerid] = SetTimerEx("Unfreeze",2000,0,"i",playerid);
  694. }
  695. stock mS_GetNumberOfPages(ListID)
  696. {
  697. new ItemAmount = mS_GetAmountOfListItems(ListID);
  698. if((ItemAmount >= mS_SELECTION_ITEMS) && (ItemAmount % mS_SELECTION_ITEMS) == 0)
  699. {
  700. return (ItemAmount / mS_SELECTION_ITEMS);
  701. }
  702. else return (ItemAmount / mS_SELECTION_ITEMS) + 1;
  703. }
  704. stock mS_GetNumberOfPagesEx(playerid)
  705. {
  706. new ItemAmount = mS_GetAmountOfListItemsEx(playerid);
  707. if((ItemAmount >= mS_SELECTION_ITEMS) && (ItemAmount % mS_SELECTION_ITEMS) == 0)
  708. {
  709. return (ItemAmount / mS_SELECTION_ITEMS);
  710. }
  711. else return (ItemAmount / mS_SELECTION_ITEMS) + 1;
  712. }
  713. stock mS_GetAmountOfListItems(ListID)
  714. {
  715. return (gLists[ListID][mS_LIST_END] - gLists[ListID][mS_LIST_START])+1;
  716. }
  717. stock mS_GetAmountOfListItemsEx(playerid)
  718. {
  719. return GetPVarInt(playerid, "mS_custom_item_amount");
  720. }
  721. stock mS_GetPlayerCurrentListID(playerid)
  722. {
  723. if(GetPVarInt(playerid, "mS_list_active") == 1) return GetPVarInt(playerid, "mS_list_id");
  724. else return mS_INVALID_LISTID;
  725. }
  726. stock PlayerText:mS_CreateCurrentPageTextDraw(playerid, Float:Xpos, Float:Ypos)
  727. {
  728. new PlayerText:txtInit;
  729. txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, "0/0");
  730. PlayerTextDrawUseBox(playerid, txtInit, 0);
  731. PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
  732. PlayerTextDrawFont(playerid, txtInit, 1);
  733. PlayerTextDrawSetShadow(playerid, txtInit, 0);
  734. PlayerTextDrawSetOutline(playerid, txtInit, 1);
  735. PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
  736. PlayerTextDrawShow(playerid, txtInit);
  737. return txtInit;
  738. }
  739. stock PlayerText:mS_CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, button_text[])
  740. {
  741. new PlayerText:txtInit;
  742. txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, button_text);
  743. PlayerTextDrawUseBox(playerid, txtInit, 1);
  744. PlayerTextDrawBoxColor(playerid, txtInit, 0x000000FF);
  745. PlayerTextDrawBackgroundColor(playerid, txtInit, 0x000000FF);
  746. PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
  747. PlayerTextDrawFont(playerid, txtInit, 1);
  748. PlayerTextDrawSetShadow(playerid, txtInit, 0); // no shadow
  749. PlayerTextDrawSetOutline(playerid, txtInit, 0);
  750. PlayerTextDrawColor(playerid, txtInit, 0x4A5A6BFF);
  751. PlayerTextDrawSetSelectable(playerid, txtInit, 1);
  752. PlayerTextDrawAlignment(playerid, txtInit, 2);
  753. PlayerTextDrawTextSize(playerid, txtInit, Height, Width); // The width and height are reversed for centering.. something the game does <g>
  754. PlayerTextDrawShow(playerid, txtInit);
  755. return txtInit;
  756. }
  757. stock PlayerText:mS_CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, header_text[])
  758. {
  759. new PlayerText:txtInit;
  760. txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, header_text);
  761. PlayerTextDrawUseBox(playerid, txtInit, 0);
  762. PlayerTextDrawLetterSize(playerid, txtInit, 1.25, 3.0);
  763. PlayerTextDrawFont(playerid, txtInit, 0);
  764. PlayerTextDrawSetShadow(playerid, txtInit, 0);
  765. PlayerTextDrawSetOutline(playerid, txtInit, 1);
  766. PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
  767. PlayerTextDrawShow(playerid, txtInit);
  768. return txtInit;
  769. }
  770. stock PlayerText:mS_CreatePlayerBGTextDraw(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, bgcolor)
  771. {
  772. new PlayerText:txtBackground = CreatePlayerTextDraw(playerid, Xpos, Ypos," ~n~"); // enough space for everyone
  773. PlayerTextDrawUseBox(playerid, txtBackground, 1);
  774. PlayerTextDrawBoxColor(playerid, txtBackground, bgcolor);
  775. PlayerTextDrawLetterSize(playerid, txtBackground, 5.0, 5.0);
  776. PlayerTextDrawFont(playerid, txtBackground, 0);
  777. PlayerTextDrawSetShadow(playerid, txtBackground, 0);
  778. PlayerTextDrawSetOutline(playerid, txtBackground, 0);
  779. PlayerTextDrawColor(playerid, txtBackground,0x000000FF);
  780. PlayerTextDrawTextSize(playerid, txtBackground, Width, Height);
  781. PlayerTextDrawBackgroundColor(playerid, txtBackground, bgcolor);
  782. PlayerTextDrawShow(playerid, txtBackground);
  783. return txtBackground;
  784. }
  785. stock PlayerText:mS_CreateMPTextDraw(playerid, modelindex, Float:Xpos, Float:Ypos, Float:Xrot, Float:Yrot, Float:Zrot, Float:mZoom, Float:width, Float:height, bgcolor)
  786. {
  787. new PlayerText:txtPlayerSprite = CreatePlayerTextDraw(playerid, Xpos, Ypos, ""); // it has to be set with SetText later
  788. PlayerTextDrawFont(playerid, txtPlayerSprite, TEXT_DRAW_FONT_MODEL_PREVIEW);
  789. PlayerTextDrawColor(playerid, txtPlayerSprite, 0xFFFFFFFF);
  790. PlayerTextDrawBackgroundColor(playerid, txtPlayerSprite, bgcolor);
  791. PlayerTextDrawTextSize(playerid, txtPlayerSprite, width, height); // Text size is the Width:Height
  792. PlayerTextDrawSetPreviewModel(playerid, txtPlayerSprite, modelindex);
  793. PlayerTextDrawSetPreviewRot(playerid,txtPlayerSprite, Xrot, Yrot, Zrot, mZoom);
  794. PlayerTextDrawSetSelectable(playerid, txtPlayerSprite, 1);
  795. PlayerTextDrawShow(playerid,txtPlayerSprite);
  796. return txtPlayerSprite;
  797. }
  798. stock mS_DestroyPlayerMPs(playerid)
  799. {
  800. new x=0;
  801. while(x != mS_SELECTION_ITEMS) {
  802. if(gSelectionItems[playerid][x] != PlayerText:INVALID_TEXT_DRAW) {
  803. PlayerTextDrawDestroy(playerid, gSelectionItems[playerid][x]);
  804. gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
  805. }
  806. x++;
  807. }
  808. }
  809. stock mS_ShowPlayerMPs(playerid)
  810. {
  811. new bgcolor = GetPVarInt(playerid, "mS_previewBGcolor");
  812. new x=0;
  813. new Float:BaseX = mS_DIALOG_BASE_X;
  814. new Float:BaseY = mS_DIALOG_BASE_Y - (mS_SPRITE_DIM_Y * 0.33); // down a bit
  815. new linetracker = 0;
  816.  
  817. new mS_listID = mS_GetPlayerCurrentListID(playerid);
  818. if(mS_listID == mS_CUSTOM_LISTID)
  819. {
  820. new itemat = (GetPVarInt(playerid, "mS_list_page") * mS_SELECTION_ITEMS);
  821. new Float:rotzoom[4];
  822. rotzoom[0] = GetPVarFloat(playerid, "mS_custom_Xrot");
  823. rotzoom[1] = GetPVarFloat(playerid, "mS_custom_Yrot");
  824. rotzoom[2] = GetPVarFloat(playerid, "mS_custom_Zrot");
  825. rotzoom[3] = GetPVarFloat(playerid, "mS_custom_Zoom");
  826. new itemamount = mS_GetAmountOfListItemsEx(playerid);
  827. // Destroy any previous ones created
  828. mS_DestroyPlayerMPs(playerid);
  829.  
  830. while(x != mS_SELECTION_ITEMS && itemat < (itemamount)) {
  831. if(linetracker == 0) {
  832. BaseX = mS_DIALOG_BASE_X + 25.0; // in a bit from the box
  833. BaseY += mS_SPRITE_DIM_Y + 1.0; // move on the Y for the next line
  834. }
  835. gSelectionItems[playerid][x] = mS_CreateMPTextDraw(playerid, gCustomList[playerid][itemat], BaseX, BaseY, rotzoom[0], rotzoom[1], rotzoom[2], rotzoom[3], mS_SPRITE_DIM_X, mS_SPRITE_DIM_Y, bgcolor);
  836. gSelectionItemsTag[playerid][x] = gCustomList[playerid][itemat];
  837. BaseX += mS_SPRITE_DIM_X + 1.0; // move on the X for the next sprite
  838. linetracker++;
  839. if(linetracker == mS_ITEMS_PER_LINE) linetracker = 0;
  840. itemat++;
  841. x++;
  842. }
  843. }
  844. else
  845. {
  846. new itemat = (gLists[mS_listID][mS_LIST_START] + (GetPVarInt(playerid, "mS_list_page") * mS_SELECTION_ITEMS));
  847.  
  848. // Destroy any previous ones created
  849. mS_DestroyPlayerMPs(playerid);
  850.  
  851. while(x != mS_SELECTION_ITEMS && itemat < (gLists[mS_listID][mS_LIST_END]+1)) {
  852. if(linetracker == 0) {
  853. BaseX = mS_DIALOG_BASE_X + 25.0; // in a bit from the box
  854. BaseY += mS_SPRITE_DIM_Y + 1.0; // move on the Y for the next line
  855. }
  856. new rzID = gItemList[itemat][mS_ITEM_ROT_ZOOM_ID]; // avoid long line
  857. if(rzID > -1) gSelectionItems[playerid][x] = mS_CreateMPTextDraw(playerid, gItemList[itemat][mS_ITEM_MODEL], BaseX, BaseY, gRotZoom[rzID][0], gRotZoom[rzID][1], gRotZoom[rzID][2], gRotZoom[rzID][3], mS_SPRITE_DIM_X, mS_SPRITE_DIM_Y, bgcolor);
  858. else gSelectionItems[playerid][x] = mS_CreateMPTextDraw(playerid, gItemList[itemat][mS_ITEM_MODEL], BaseX, BaseY, 0.0, 0.0, 0.0, 1.0, mS_SPRITE_DIM_X, mS_SPRITE_DIM_Y, bgcolor);
  859. gSelectionItemsTag[playerid][x] = gItemList[itemat][mS_ITEM_MODEL];
  860. BaseX += mS_SPRITE_DIM_X + 1.0; // move on the X for the next sprite
  861. linetracker++;
  862. if(linetracker == mS_ITEMS_PER_LINE) linetracker = 0;
  863. itemat++;
  864. x++;
  865. }
  866. }
  867. }
  868. stock mS_UpdatePageTextDraw(playerid)
  869. {
  870. new PageText[64+1];
  871. new listID = mS_GetPlayerCurrentListID(playerid);
  872. if(listID == mS_CUSTOM_LISTID)
  873. {
  874. format(PageText, 64, "%d/%d", GetPVarInt(playerid,"mS_list_page") + 1, mS_GetNumberOfPagesEx(playerid));
  875. PlayerTextDrawSetString(playerid, gCurrentPageTextDrawId[playerid], PageText);
  876. }
  877. else
  878. {
  879. format(PageText, 64, "%d/%d", GetPVarInt(playerid,"mS_list_page") + 1, mS_GetNumberOfPages(listID));
  880. PlayerTextDrawSetString(playerid, gCurrentPageTextDrawId[playerid], PageText);
  881. }
  882. }
  883. stock ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
  884. {
  885. if(!(0 <= ListID < mS_TOTAL_LISTS && gLists[ListID][mS_LIST_START] != gLists[ListID][mS_LIST_END])) return 0;
  886. mS_DestroySelectionMenu(playerid);
  887. SetPVarInt(playerid, "mS_list_page", 0);
  888. SetPVarInt(playerid, "mS_list_id", ListID);
  889. SetPVarInt(playerid, "mS_list_active", 1);
  890. SetPVarInt(playerid, "mS_list_time", GetTickCount());
  891.  
  892. gBackgroundTextDrawId[playerid] = mS_CreatePlayerBGTextDraw(playerid, mS_DIALOG_BASE_X, mS_DIALOG_BASE_Y + 20.0, mS_DIALOG_WIDTH, mS_DIALOG_HEIGHT, dialogBGcolor);
  893. gHeaderTextDrawId[playerid] = mS_CreatePlayerHeaderTextDraw(playerid, mS_DIALOG_BASE_X, mS_DIALOG_BASE_Y, header_text);
  894. gCurrentPageTextDrawId[playerid] = mS_CreateCurrentPageTextDraw(playerid, mS_DIALOG_WIDTH - 30.0, mS_DIALOG_BASE_Y + 15.0);
  895. gNextButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 30.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_NEXT_TEXT);
  896. gPrevButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 90.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_PREV_TEXT);
  897. //gCancelButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 150.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_CANCEL_TEXT);
  898.  
  899. SetPVarInt(playerid, "mS_previewBGcolor", previewBGcolor);
  900. mS_ShowPlayerMPs(playerid);
  901. mS_UpdatePageTextDraw(playerid);
  902.  
  903. SelectTextDraw(playerid, tdSelectionColor);
  904. return 1;
  905. }
  906. stock ShowModelSelectionMenuEx(playerid, items_array[], item_amount, header_text[], extraid, Float:Xrot = 0.0, Float:Yrot = 0.0, Float:Zrot = 0.0, Float:mZoom = 1.0, dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
  907. {
  908. mS_DestroySelectionMenu(playerid);
  909. if(item_amount > mS_CUSTOM_MAX_ITEMS)
  910. {
  911. item_amount = mS_CUSTOM_MAX_ITEMS;
  912. print("-mSelection- WARNING: Too many items given to \"ShowModelSelectionMenuEx\", increase \"mS_CUSTOM_MAX_ITEMS\" to fix this");
  913. }
  914. if(item_amount > 0)
  915. {
  916. for(new i=0;i<item_amount;i++)
  917. {
  918. gCustomList[playerid][i] = items_array[i];
  919. }
  920. SetPVarInt(playerid, "mS_list_page", 0);
  921. SetPVarInt(playerid, "mS_list_id", mS_CUSTOM_LISTID);
  922. SetPVarInt(playerid, "mS_list_active", 1);
  923. SetPVarInt(playerid, "mS_list_time", GetTickCount());
  924.  
  925. SetPVarInt(playerid, "mS_custom_item_amount", item_amount);
  926. SetPVarFloat(playerid, "mS_custom_Xrot", Xrot);
  927. SetPVarFloat(playerid, "mS_custom_Yrot", Yrot);
  928. SetPVarFloat(playerid, "mS_custom_Zrot", Zrot);
  929. SetPVarFloat(playerid, "mS_custom_Zoom", mZoom);
  930. SetPVarInt(playerid, "mS_custom_extraid", extraid);
  931.  
  932.  
  933. gBackgroundTextDrawId[playerid] = mS_CreatePlayerBGTextDraw(playerid, mS_DIALOG_BASE_X, mS_DIALOG_BASE_Y + 20.0, mS_DIALOG_WIDTH, mS_DIALOG_HEIGHT, dialogBGcolor);
  934. gHeaderTextDrawId[playerid] = mS_CreatePlayerHeaderTextDraw(playerid, mS_DIALOG_BASE_X, mS_DIALOG_BASE_Y, header_text);
  935. gCurrentPageTextDrawId[playerid] = mS_CreateCurrentPageTextDraw(playerid, mS_DIALOG_WIDTH - 30.0, mS_DIALOG_BASE_Y + 15.0);
  936. gNextButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 30.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_NEXT_TEXT);
  937. gPrevButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 90.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_PREV_TEXT);
  938. gCancelButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 150.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_CANCEL_TEXT);
  939.  
  940. SetPVarInt(playerid, "mS_previewBGcolor", previewBGcolor);
  941. mS_ShowPlayerMPs(playerid);
  942. mS_UpdatePageTextDraw(playerid);
  943.  
  944. SelectTextDraw(playerid, tdSelectionColor);
  945. return 1;
  946. }
  947. return 0;
  948. }
  949. stock HideModelSelectionMenu(playerid)
  950. {
  951. mS_DestroySelectionMenu(playerid);
  952. SetPVarInt(playerid, "mS_ignore_next_esc", 1);
  953. CancelSelectTextDraw(playerid);
  954. return 1;
  955. }
  956. stock mS_DestroySelectionMenu(playerid)
  957. {
  958. if(GetPVarInt(playerid, "mS_list_active") == 1)
  959. {
  960. if(mS_GetPlayerCurrentListID(playerid) == mS_CUSTOM_LISTID)
  961. {
  962. DeletePVar(playerid, "mS_custom_Xrot");
  963. DeletePVar(playerid, "mS_custom_Yrot");
  964. DeletePVar(playerid, "mS_custom_Zrot");
  965. DeletePVar(playerid, "mS_custom_Zoom");
  966. DeletePVar(playerid, "mS_custom_extraid");
  967. DeletePVar(playerid, "mS_custom_item_amount");
  968. }
  969. DeletePVar(playerid, "mS_list_time");
  970. SetPVarInt(playerid, "mS_list_active", 0);
  971. mS_DestroyPlayerMPs(playerid);
  972.  
  973. PlayerTextDrawDestroy(playerid, gHeaderTextDrawId[playerid]);
  974. PlayerTextDrawDestroy(playerid, gBackgroundTextDrawId[playerid]);
  975. PlayerTextDrawDestroy(playerid, gCurrentPageTextDrawId[playerid]);
  976. PlayerTextDrawDestroy(playerid, gNextButtonTextDrawId[playerid]);
  977. PlayerTextDrawDestroy(playerid, gPrevButtonTextDrawId[playerid]);
  978. PlayerTextDrawDestroy(playerid, gCancelButtonTextDrawId[playerid]);
  979.  
  980. gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  981. gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  982. gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  983. gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  984. gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  985. gCancelButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  986. }
  987. }
  988. // Even though only Player* textdraws are used in this script,
  989. // OnPlayerClickTextDraw is still required to handle ESC
  990. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  991. {
  992. if(GetPVarInt(playerid, "mS_ignore_next_esc") == 1) {
  993. SetPVarInt(playerid, "mS_ignore_next_esc", 0);
  994. return CallLocalFunction("MP_OPCTD", "ii", playerid, _:clickedid);
  995. }
  996. if(GetPVarInt(playerid, "mS_list_active") == 0) return CallLocalFunction("MP_OPCTD", "ii", playerid, _:clickedid);
  997.  
  998. // Handle: They cancelled (with ESC)
  999. if(clickedid == Text:INVALID_TEXT_DRAW) {
  1000. new listid = mS_GetPlayerCurrentListID(playerid);
  1001. if(listid == mS_CUSTOM_LISTID)
  1002. {
  1003. new extraid = GetPVarInt(playerid, "mS_custom_extraid");
  1004. mS_DestroySelectionMenu(playerid);
  1005. CallLocalFunction("OnPlayerModelSelectionEx", "dddd", playerid, 0, extraid, -1);
  1006. PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  1007. }
  1008. else
  1009. {
  1010. mS_DestroySelectionMenu(playerid);
  1011. CallLocalFunction("OnPlayerModelSelection", "dddd", playerid, 0, listid, -1);
  1012. PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  1013. }
  1014. return 1;
  1015. }
  1016.  
  1017. return CallLocalFunction("MP_OPCTD", "ii", playerid, _:clickedid);
  1018. }
  1019. #if defined _ALS_OnPlayerClickTextDraw
  1020. #undef OnPlayerClickTextDraw
  1021. #else
  1022. #define _ALS_OnPlayerClickTextDraw
  1023. #endif
  1024. #define OnPlayerClickTextDraw MP_OPCTD
  1025. forward MP_OPCTD(playerid, Text:clickedid);
  1026. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  1027. {
  1028. if(GetPVarInt(playerid, "mS_list_active") == 0 || (GetTickCount()-GetPVarInt(playerid, "mS_list_time")) < 200 /* Disable instant selection */) return CallLocalFunction("MP_OPCPTD", "ii", playerid, _:playertextid);
  1029.  
  1030. new curpage = GetPVarInt(playerid, "mS_list_page");
  1031.  
  1032. // Handle: cancel button
  1033. if(playertextid == gCancelButtonTextDrawId[playerid]) {
  1034. new listID = mS_GetPlayerCurrentListID(playerid);
  1035. if(listID == mS_CUSTOM_LISTID)
  1036. {
  1037. new extraid = GetPVarInt(playerid, "mS_custom_extraid");
  1038. HideModelSelectionMenu(playerid);
  1039. CallLocalFunction("OnPlayerModelSelectionEx", "dddd", playerid, 0, extraid, -1);
  1040. PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  1041. }
  1042. else
  1043. {
  1044. HideModelSelectionMenu(playerid);
  1045. CallLocalFunction("OnPlayerModelSelection", "dddd", playerid, 0, listID, -1);
  1046. PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  1047. }
  1048. return 1;
  1049. }
  1050.  
  1051. // Handle: next button
  1052. if(playertextid == gNextButtonTextDrawId[playerid]) {
  1053. new listID = mS_GetPlayerCurrentListID(playerid);
  1054. if(listID == mS_CUSTOM_LISTID)
  1055. {
  1056. if(curpage < (mS_GetNumberOfPagesEx(playerid) - 1)) {
  1057. SetPVarInt(playerid, "mS_list_page", curpage + 1);
  1058. mS_ShowPlayerMPs(playerid);
  1059. mS_UpdatePageTextDraw(playerid);
  1060. PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  1061. } else {
  1062. PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  1063. }
  1064. }
  1065. else
  1066. {
  1067. if(curpage < (mS_GetNumberOfPages(listID) - 1)) {
  1068. SetPVarInt(playerid, "mS_list_page", curpage + 1);
  1069. mS_ShowPlayerMPs(playerid);
  1070. mS_UpdatePageTextDraw(playerid);
  1071. PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  1072. } else {
  1073. PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  1074. }
  1075. }
  1076. return 1;
  1077. }
  1078.  
  1079. // Handle: previous button
  1080. if(playertextid == gPrevButtonTextDrawId[playerid]) {
  1081. if(curpage > 0) {
  1082. SetPVarInt(playerid, "mS_list_page", curpage - 1);
  1083. mS_ShowPlayerMPs(playerid);
  1084. mS_UpdatePageTextDraw(playerid);
  1085. PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
  1086. } else {
  1087. PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  1088. }
  1089. return 1;
  1090. }
  1091.  
  1092. // Search in the array of textdraws used for the items
  1093. new x=0;
  1094. while(x != mS_SELECTION_ITEMS) {
  1095. if(playertextid == gSelectionItems[playerid][x]) {
  1096. new listID = mS_GetPlayerCurrentListID(playerid);
  1097. if(listID == mS_CUSTOM_LISTID)
  1098. {
  1099. PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  1100. new item_id = gSelectionItemsTag[playerid][x];
  1101. new extraid = GetPVarInt(playerid, "mS_custom_extraid");
  1102. HideModelSelectionMenu(playerid);
  1103. CallLocalFunction("OnPlayerModelSelectionEx", "dddd", playerid, 1, extraid, item_id);
  1104. return 1;
  1105. }
  1106. else
  1107. {
  1108. PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  1109. new item_id = gSelectionItemsTag[playerid][x];
  1110. HideModelSelectionMenu(playerid);
  1111. CallLocalFunction("OnPlayerModelSelection", "dddd", playerid, 1, listID, item_id);
  1112. return 1;
  1113. }
  1114. }
  1115. x++;
  1116. }
  1117.  
  1118. return CallLocalFunction("MP_OPCPTD", "ii", playerid, _:playertextid);
  1119. }
  1120. #if defined _ALS_OnPlayerClickPlayerTD
  1121. #undef OnPlayerClickPlayerTextDraw
  1122. #else
  1123. #define _ALS_OnPlayerClickPlayerTD
  1124. #endif
  1125. #define OnPlayerClickPlayerTextDraw MP_OPCPTD
  1126. forward MP_OPCPTD(playerid, PlayerText:playertextid);
  1127. stock LoadModelSelectionMenu(f_name[])
  1128. {
  1129. new File:f, str[75];
  1130. format(str, sizeof(str), "%s", f_name);
  1131. f = fopen(str, io_read);
  1132. if( !f ) {
  1133. printf("-mSelection- WARNING: Failed to load list: \"%s\"", f_name);
  1134. return mS_INVALID_LISTID;
  1135. }
  1136.  
  1137. if(gListAmount >= mS_TOTAL_LISTS)
  1138. {
  1139. printf("-mSelection- WARNING: Reached maximum amount of lists, increase \"mS_TOTAL_LISTS\"", f_name);
  1140. return mS_INVALID_LISTID;
  1141. }
  1142. new tmp_ItemAmount = gItemAmount; // copy value if loading fails
  1143.  
  1144.  
  1145. new line2[128], idxx;
  1146. while(fread(f,line2,sizeof(line2),false))
  1147. {
  1148. if(tmp_ItemAmount >= mS_TOTAL_ITEMS)
  1149. {
  1150. printf("-mSelection- WARNING: Reached maximum amount of items, increase \"mS_TOTAL_ITEMS\"", f_name);
  1151. break;
  1152. }
  1153. idxx = 0;
  1154. if(!line2[0]) continue;
  1155. new mID = strval( mS_strtok(line2,idxx) );
  1156. if(0 <= mID < 20000)
  1157. {
  1158. gItemList[tmp_ItemAmount][mS_ITEM_MODEL] = mID;
  1159.  
  1160. new tmp_mS_strtok[20];
  1161. new Float:mRotation[3], Float:mZoom = 1.0;
  1162. new bool:useRotation = false;
  1163.  
  1164. tmp_mS_strtok = mS_strtok(line2,idxx);
  1165. if(tmp_mS_strtok[0]) {
  1166. useRotation = true;
  1167. mRotation[0] = floatstr(tmp_mS_strtok);
  1168. }
  1169. tmp_mS_strtok = mS_strtok(line2,idxx);
  1170. if(tmp_mS_strtok[0]) {
  1171. useRotation = true;
  1172. mRotation[1] = floatstr(tmp_mS_strtok);
  1173. }
  1174. tmp_mS_strtok = mS_strtok(line2,idxx);
  1175. if(tmp_mS_strtok[0]) {
  1176. useRotation = true;
  1177. mRotation[2] = floatstr(tmp_mS_strtok);
  1178. }
  1179. tmp_mS_strtok = mS_strtok(line2,idxx);
  1180. if(tmp_mS_strtok[0]) {
  1181. useRotation = true;
  1182. mZoom = floatstr(tmp_mS_strtok);
  1183. }
  1184. if(useRotation)
  1185. {
  1186. new bool:foundRotZoom = false;
  1187. for(new i=0; i < gRotZoomAmount; i++)
  1188. {
  1189. if(gRotZoom[i][0] == mRotation[0] && gRotZoom[i][1] == mRotation[1] && gRotZoom[i][2] == mRotation[2] && gRotZoom[i][3] == mZoom)
  1190. {
  1191. foundRotZoom = true;
  1192. gItemList[tmp_ItemAmount][mS_ITEM_ROT_ZOOM_ID] = i;
  1193. break;
  1194. }
  1195. }
  1196. if(gRotZoomAmount < mS_TOTAL_ROT_ZOOM)
  1197. {
  1198. if(!foundRotZoom)
  1199. {
  1200. gRotZoom[gRotZoomAmount][0] = mRotation[0];
  1201. gRotZoom[gRotZoomAmount][1] = mRotation[1];
  1202. gRotZoom[gRotZoomAmount][2] = mRotation[2];
  1203. gRotZoom[gRotZoomAmount][3] = mZoom;
  1204. gItemList[tmp_ItemAmount][mS_ITEM_ROT_ZOOM_ID] = gRotZoomAmount;
  1205. gRotZoomAmount++;
  1206. }
  1207. }
  1208. else print("-mSelection- WARNING: Not able to save rotation/zoom information. Reached maximum rotation/zoom information count. Increase '#define mS_TOTAL_ROT_ZOOM' to fix the issue");
  1209. }
  1210. else gItemList[tmp_ItemAmount][mS_ITEM_ROT_ZOOM_ID] = -1;
  1211. tmp_ItemAmount++;
  1212. }
  1213. }
  1214. if(tmp_ItemAmount > gItemAmount) // any models loaded ?
  1215. {
  1216. gLists[gListAmount][mS_LIST_START] = gItemAmount;
  1217. gItemAmount = tmp_ItemAmount; // copy back
  1218. gLists[gListAmount][mS_LIST_END] = (gItemAmount-1);
  1219.  
  1220. gListAmount++;
  1221. return (gListAmount-1);
  1222. }
  1223. printf("-mSelection- WARNING: No Items found in file: %s", f_name);
  1224. return mS_INVALID_LISTID;
  1225. }
  1226. stock mS_strtok(const string[], &index)
  1227. {
  1228. new length = strlen(string);
  1229. while ((index < length) && (string[index] <= ' '))
  1230. {
  1231. index++;
  1232. }
  1233.  
  1234. new offset = index;
  1235. new result[20];
  1236. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  1237. {
  1238. result[index - offset] = string[index];
  1239. index++;
  1240. }
  1241. result[index - offset] = EOS;
  1242. return result;
  1243. }
  1244. //----------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement