gui.inc 99 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220
  1. /*
  2. SA-MP GUI by Thoth A.K.A Seif
  3. » Windows;
  4. » Text Labels;
  5. » Tabs;
  6. » Progress bars;
  7. » Itemlist
  8. » Checkbox/radio buttons
  9. » Buttons
  10. */
  11. #include <a_samp>
  12. #define function%0(%1) forward %0(%1); public %0(%1)
  13. #define GUI_TYPE_WINDOW (1)
  14. #define GUI_TYPE_TAB (2)
  15. #define GUI_TYPE_LABEL (3)
  16. #define GUI_TYPE_BAR (4)
  17. #define GUI_TYPE_ITEMLIST (5)
  18. #define GUI_TYPE_CHECKBOX (6)
  19. #define GUI_TYPE_BUTTON (7)
  20. #define UNIT 0.11 // Font size 0.11 ~= 1 unit pixel
  21. #define MAX_GUI (50) // Maximum GUI per player
  22. new textdrawVisibility[2048];
  23. new p_textdrawVisibility[MAX_PLAYERS][2048];
  24. new p_tab[MAX_PLAYERS];
  25. new p_row[MAX_PLAYERS];
  26. new pcount_i[MAX_PLAYERS];
  27. enum guiinfo_window
  28. {
  29. gui_win_ID,
  30. Float:gui_win_X,
  31. Float:gui_win_Y,
  32. Float:gui_win_SizeX,
  33. Float:gui_win_SizeY,
  34. gui_win_Title[64],
  35. PlayerText:gui_win_td,
  36. PlayerText:gui_win_tdtop,
  37. PlayerText:gui_win_tdtitle,
  38. gui_win_P,
  39. }
  40. new gui_WindowData[MAX_PLAYERS][MAX_GUI][guiinfo_window];
  41. enum guiinfo_label
  42. {
  43. gui_label_ID,
  44. gui_label_Type,
  45. gui_label_Window, // 0 for none, or set the window gui ID so it's part of it
  46. gui_label_Tab, // 0 for none, or set the tab gui ID so it's part of it. If the tab is part of a window, set the window id too!
  47. Float:gui_label_X, // if Window/Tab is set, this value is relative to the window's/tab's
  48. Float:gui_label_Y, // if Window/Tab is set, this value is relative to the window's/tab's
  49. Float:gui_label_Length,
  50. gui_label_Text[64],
  51. gui_label_Color,
  52. PlayerText:gui_label_td,
  53. gui_label_Lines,
  54. gui_label_P,
  55. }
  56. new gui_LabelData[MAX_PLAYERS][MAX_GUI][guiinfo_label];
  57. enum guiinfo_tab
  58. {
  59. gui_tab_ID,
  60. gui_tab_Type,
  61. gui_tab_Window, // 0 for none, or set the window gui ID so it's part of it
  62. Float:gui_tab_X, // if Window is set, this value is relative to the window's
  63. Float:gui_tab_Y, // if Window is set, this value is relative to the window's
  64. Float:gui_tab_plusX,
  65. Float:gui_tab_Height, // 0.0 will take the rest of the GUI window height IF window gui is set. This value is relative to its window parent.
  66. Float:gui_tab_Width, // 0.0 will take the rest of the GUI window width IF window gui is set This value is relative to its window parent.
  67. gui_tab_Text[64],
  68. PlayerText:gui_tab_td,
  69. PlayerText:gui_tab_td2, // active
  70. PlayerText:gui_tab_tdbg,
  71. PlayerText:gui_tab_tdbox,
  72. gui_tab_panel,
  73. Float:gui_tab_panelX,
  74. Float:gui_tab_panelY,
  75. gui_tab_P,
  76. }
  77. new gui_TabData[MAX_PLAYERS][MAX_GUI][guiinfo_tab];
  78. enum guiinfo_bar
  79. {
  80. gui_bar_ID,
  81. gui_bar_Type,
  82. gui_bar_Window, // 0 for none, or set the window gui ID so it's part of it
  83. gui_bar_Tab, // 0 for none, or set the tab gui ID so it's under it, AND set the window id of the tab.
  84. Float:gui_bar_X, // if Window is set, this value is relative to the window's/tab's
  85. Float:gui_bar_Y, // if Window is set, this value is relative to the window's/tab's
  86. Float:gui_bar_Height, // Sets the height of the bar.
  87. Float:gui_bar_Width, // Sets the weidth of the bar.
  88. Float:gui_bar_Progress, // The progress in percentage
  89. PlayerText:gui_bar_tdbg,
  90. PlayerText:gui_bar_tdbox,
  91. PlayerText:gui_bar_tdbar,
  92. gui_bar_bgcolor,
  93. gui_bar_boxcolor,
  94. gui_bar_barcolor,
  95. gui_bar_P,
  96. }
  97. new gui_BarData[MAX_PLAYERS][MAX_GUI][guiinfo_bar];
  98. enum guiinfo_list
  99. {
  100. gui_list_ID,
  101. gui_list_Type,
  102. gui_list_Window, // 0 for none, or set the window gui ID so it's part of it
  103. gui_list_Tab, // 0 for none, or set the tab gui ID so it's under it, AND set the window id of the tab.
  104. Float:gui_list_X, // if Window is set, this value is relative to the window's/tab's
  105. Float:gui_list_Y, // if Window is set, this value is relative to the window's/tab's
  106. Float:gui_list_Height, // Sets the height of the bar. Set to 0.0 to take up the whole window or tab panel
  107. Float:gui_list_Width, // Sets the weidth of the bar. Set to 0.0 to take up the whole window or tab panel
  108. Float:gui_list_RowX,
  109. Float:gui_list_RowY,
  110. gui_list_RowMax,
  111. gui_list_Title[32],
  112. PlayerText:gui_list_tdbox,
  113. PlayerText:gui_list_tdline,
  114. PlayerText:gui_list_tdtitle,
  115. gui_list_P,
  116. }
  117. new gui_ItemlistData[MAX_PLAYERS][MAX_GUI][guiinfo_list];
  118. enum guiinfo_row
  119. {
  120. gui_row_ID,
  121. gui_row_List,
  122. gui_row_Order, // The order number in the list. Ex. 0 = first in the list. 1 = second in the list(if there's multiple listitems)
  123. Float:gui_row_X,
  124. Float:gui_row_Y,
  125. Float:gui_row_Height,
  126. Float:gui_row_Width,
  127. gui_row_Text[32],
  128. PlayerText:gui_row_td,
  129. PlayerText:gui_row_td2, // active
  130. }
  131. new gui_ItemRowData[MAX_PLAYERS][MAX_GUI][guiinfo_row];
  132. enum guiinfo_check
  133. {
  134. gui_check_ID,
  135. gui_check_Type,
  136. gui_check_Window,
  137. gui_check_Tab,
  138. Float:gui_check_X,
  139. Float:gui_check_Y,
  140. PlayerText:gui_check_td,
  141. PlayerText:gui_check_td2, // active
  142. gui_check_P,
  143. }
  144. new gui_CheckboxData[MAX_PLAYERS][MAX_GUI][guiinfo_check];
  145. enum guiinfo_but
  146. {
  147. gui_but_ID,
  148. gui_but_Type,
  149. gui_but_Window, // 0 for none, or set the window gui ID so it's part of it
  150. gui_but_Tab, // 0 for none, or set the tab gui ID so it's under it, AND set the window id of the tab.
  151. Float:gui_but_X, // if Window is set, this value is relative to the window's/tab's
  152. Float:gui_but_Y, // if Window is set, this value is relative to the window's/tab's
  153. Float:gui_but_Height, // Sets the height of the bar.
  154. Float:gui_but_Width, // Sets the weidth of the bar.
  155. gui_but_Text[32],
  156. PlayerText:gui_but_tdbg,
  157. PlayerText:gui_but_tdout,
  158. PlayerText:gui_but_tdbox,
  159. PlayerText:gui_but_tdgl,
  160. PlayerText:gui_but_tdtxt,
  161. gui_but_P,
  162. }
  163. new gui_ButtonData[MAX_PLAYERS][MAX_GUI][guiinfo_but];
  164. forward OnPlayerClickTab(playerid, tabid);
  165. forward OnPlayerClickButton(playerid, buttonid);
  166. /*
  167. native guiSetVisible(playerid, type, gui, bool:toggle)
  168. native guiSetVisibleAll(type, gui, bool:toggle)
  169. native guiCreateWindow(playerid, Float:x, Float:y, Float:size_x, Float:size_y, title[])
  170. native guiCreateTab(playerid, windowid, Float:x, Float:y, Float:height, Float:width, text[])
  171. native guiCreateLabel(playerid, windowid, tabid, Float:x, Float:y, Float:length, color, font, text[])
  172. native guiLabelSetText(playerid, labelid, color, font, text[])
  173. native guiCreateProgressBar(playerid, windowid, tabid, Float:x, Float:y, Float:height, Float:width, color_bg, color_box, color_bar)
  174. native guiProgressBarSetProgress(playerid, barid, Float:progress)
  175. native Float:guiProgressBarGetProgress(playerid, barid)
  176. native guiCreateItemList(playerid, windowid, tabid, Float:x, Float:y, Float:height, Float:width, title[])
  177. native guiItemListAddRow(playerid, listid, text[])
  178. native guiItemListRemoveRow(playerid, listid, rowid)
  179. native guiItemListSetRowOrder(playerid, listid, rowid, orderid)
  180. native guiItemListGetSelectedRow(playerid)
  181. native guiItemListGetRowText(playerid, listid, rowid, string[])
  182. native guiItemListGetCount(playerid, listid)
  183. native guiItemListGetRowList(playerid, rowid)
  184. native guiCreateCheckBox(playerid, windowid, tabid, Float:x, Float:y)
  185. native guiCheckBoxGetSelected(playerid, checkboxid)
  186. native guiCheckBoxSetSelected(playerid, checkboxid)
  187. native guiGetCheckBoxPos(playerid, checkboxid, &Float:x, &Float:y)
  188. native guiCreateButton(playerid, windowid, tabid, Float:x, Float:y, Float:height, Float:width, text[])
  189. native Float:guiGetButtonHeight(playerid, buttonid)
  190. native Float:guiGetButtonWidth(playerid, buttonid)
  191. native guiGetButtonPos(playerid, buttonid, &Float:x, &Float:y)
  192. native guiIsVisible(playerid, type, gui)
  193. native guiDestroy(playerid, type, gui)
  194. native guiDestroyAll(playerid, type)
  195. */
  196. /*x---------------------------------CallBacks-------------------------------------x*/
  197. /*forward gui_OnPlayerConnect(playerid);
  198. public gui_OnPlayerConnect(playerid)
  199. {
  200. //CreatePlayerTextDraw(playerid, 0.0, 0.0, "_");
  201. //p_tab[playerid] = 0;
  202. //p_row[playerid] = 0;
  203. //return OnPlayerConnect(playerid);
  204. return 1;
  205. }
  206. //#define OnPlayerConnect gui_OnPlayerConnect*/
  207. forward gui_OnPlayerConnect(playerid);
  208. public gui_OnPlayerConnect(playerid)
  209. {
  210. CreatePlayerTextDraw(playerid, 0.0, 0.0, "_");
  211. p_tab[playerid] = 0;
  212. p_row[playerid] = 0;
  213. return OnPlayerConnect(playerid);
  214. }
  215. function PlayerTextDrawShowEx(playerid, PlayerText:textdrawid)
  216. {
  217. p_textdrawVisibility[playerid][io_PlayerText:textdrawid] = 1;
  218. return PlayerTextDrawShow(playerid, textdrawid);
  219. }
  220. #define PlayerTextDrawShow(%0,%1) PlayerTextDrawShowEx(%0,%1)
  221. function PlayerTextDrawHideEx(playerid, PlayerText:textdrawid)
  222. {
  223. p_textdrawVisibility[playerid][io_PlayerText:textdrawid] = 0;
  224. return PlayerTextDrawHide(playerid, textdrawid);
  225. }
  226. #define PlayerTextDrawHide(%0,%1) PlayerTextDrawHideEx(%0,%1)
  227. function TextDrawDestroyEx(playerid, PlayerText:textdrawid)
  228. {
  229. for(new p; p < MAX_PLAYERS; p++)
  230. {
  231. if (!IsPlayerConnected(p)) continue;
  232. p_textdrawVisibility[p][io_PlayerText:textdrawid] = 0;
  233. }
  234. textdrawVisibility[io_PlayerText:textdrawid] = 0;
  235. return PlayerTextDrawDestroy(playerid, textdrawid);
  236. }
  237. function GetTextDrawVisibilityForPlayer(playerid, PlayerText:textdrawid) return p_textdrawVisibility[playerid][io_PlayerText:textdrawid];
  238. function GetTextDrawVisibilityForAll(PlayerText:textdrawid) return textdrawVisibility[io_PlayerText:textdrawid];
  239. function guiSetVisible(playerid, type, gui, bool:toggle)
  240. {
  241. new str[32],end = 0;
  242. new oldw = GetPVarInt(playerid, "guisetvisible_w");
  243. if (toggle == true)
  244. {
  245. format(str, sizeof str, "PlayerTextDrawShowEx");
  246. }
  247. else if (toggle == false)
  248. {
  249. format(str, sizeof str, "PlayerTextDrawHideEx");
  250. }
  251. new gid = guiGetID(playerid, type, gui);
  252. if (gid == -1) return 0;
  253. //printf("ID: %d = %s", playerid, str);
  254. if (type == GUI_TYPE_WINDOW)
  255. {
  256. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_WindowData[playerid][gid][gui_win_td]);
  257. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_WindowData[playerid][gid][gui_win_tdtop]);
  258. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_WindowData[playerid][gid][gui_win_tdtitle]);
  259. }
  260. else if (type != GUI_TYPE_TAB && type != GUI_TYPE_WINDOW) end = 1;
  261. new count;
  262. /*if (p_tab[playerid] > 0)
  263. {
  264. type = GUI_TYPE_TAB;
  265. gui = gui_TabData[p_tab[playerid]][gui_tab_ID];
  266. }*/
  267. for(new g; g < MAX_GUI; g++)
  268. {
  269. switch (type)
  270. {
  271. case GUI_TYPE_TAB: goto TAB;
  272. case GUI_TYPE_LABEL: goto LABEL;
  273. case GUI_TYPE_BAR: goto BAR;
  274. case GUI_TYPE_ITEMLIST: goto ITEMLIST;
  275. case GUI_TYPE_CHECKBOX: goto CHECKBOX;
  276. case GUI_TYPE_BUTTON: goto BUTTON;
  277. }
  278. TAB:
  279. if (
  280. gui_TabData[playerid][g][gui_tab_ID] > 0 &&
  281. (
  282. (type == GUI_TYPE_WINDOW && gui_TabData[playerid][g][gui_tab_Window] == gui) ||
  283. (type == gui_TabData[playerid][g][gui_tab_Type])
  284. ) &&
  285. gui_TabData[playerid][g][gui_tab_P] == playerid
  286. )
  287. {
  288. if (!count && !p_tab[playerid])
  289. {
  290. p_tab[playerid] = g;
  291. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_TabData[playerid][g][gui_tab_td2]); // first tab
  292. //type = GUI_TYPE_TAB;
  293. //gui = gui_TabData[g][gui_tab_ID];
  294. if (type == GUI_TYPE_WINDOW) // Re-applies the function with the tab option, so it can show its child elements
  295. {
  296. SetPVarInt(playerid, "guisetvisible_w", gui);
  297. guiSetVisible(playerid, GUI_TYPE_TAB, gui_TabData[playerid][g][gui_tab_ID], toggle);
  298. break;
  299. }
  300. }
  301. else if (p_tab[playerid] == g)
  302. {
  303. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_TabData[playerid][g][gui_tab_td2]); // selected tab
  304. //type = GUI_TYPE_TAB;
  305. //gui = gui_TabData[playerid][g][gui_tab_ID];
  306. if (type == GUI_TYPE_WINDOW)
  307. {
  308. guiSetVisible(playerid, GUI_TYPE_TAB, gui_TabData[playerid][g][gui_tab_ID], toggle);
  309. break;
  310. }
  311. }
  312. else CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_TabData[playerid][g][gui_tab_td]);
  313. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_TabData[playerid][g][gui_tab_tdbg]);
  314. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_TabData[playerid][g][gui_tab_tdbox]);
  315. count++;
  316. }
  317. if (end) continue;
  318. LABEL:
  319. //printf("Type: %d(%d) | GUI: %d(%d) | Window: %d(%d) | Tab: %d(%d)", type, gui_LabelData[playerid][g][gui_label_Type], gui, gui_LabelData[playerid][g][gui_label_ID], gui, gui_LabelData[playerid][g][gui_label_Window], gui, gui_LabelData[playerid][g][gui_label_Tab]);
  320. if (
  321. gui_LabelData[playerid][g][gui_label_ID] > 0 && // Valid gui?
  322. (
  323. (type == GUI_TYPE_WINDOW && gui_LabelData[playerid][g][gui_label_Window] == gui && // If it's being viewed under a window (In case the window has no tab)
  324. (
  325. (!gui_LabelData[playerid][g][gui_label_Tab] && toggle) ||
  326. (gui_LabelData[playerid][g][gui_label_Tab] > 0 && !toggle)
  327. )
  328. ) ||
  329. (type == GUI_TYPE_TAB && gui_LabelData[playerid][g][gui_label_Tab] == gui) || // Under a tab?
  330. (type == gui_LabelData[playerid][g][gui_label_Type] && gui_LabelData[playerid][g][gui_label_ID] == gui) // Maybe it's alone?
  331. ) ||
  332. ( // It's under a window, however if the window has a tab, it automatically runs the function under tab. So this checks if it's only under a window
  333. oldw > 0 && oldw == gui_LabelData[playerid][g][gui_label_Window] &&
  334. (type == GUI_TYPE_TAB && !gui_LabelData[playerid][g][gui_label_Tab])
  335. ) &&
  336. gui_LabelData[playerid][g][gui_label_P] == playerid
  337. )
  338. {
  339. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_LabelData[playerid][g][gui_label_td]);
  340. }
  341. if (end) continue;
  342. BAR:
  343. if (
  344. gui_BarData[playerid][g][gui_bar_ID] > 0 &&
  345. (
  346. (type == GUI_TYPE_WINDOW && gui_BarData[playerid][g][gui_bar_Window] == gui &&
  347. (
  348. (!gui_BarData[playerid][g][gui_bar_Tab] && toggle) ||
  349. (gui_BarData[playerid][g][gui_bar_Tab] > 0 && !toggle)
  350. )
  351. ) ||
  352. (type == GUI_TYPE_TAB && gui_BarData[playerid][g][gui_bar_Tab] == gui) ||
  353. (type == gui_BarData[playerid][g][gui_bar_Type] && gui_BarData[playerid][g][gui_bar_ID] == gui)
  354. ) ||
  355. (
  356. oldw > 0 && oldw == gui_BarData[playerid][g][gui_bar_Window] &&
  357. (type == GUI_TYPE_TAB && !gui_BarData[playerid][g][gui_bar_Tab])
  358. ) &&
  359. gui_BarData[playerid][g][gui_bar_P] == playerid
  360. )
  361. {
  362. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_BarData[playerid][g][gui_bar_tdbg]);
  363. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_BarData[playerid][g][gui_bar_tdbox]);
  364. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_BarData[playerid][g][gui_bar_tdbar]);
  365. }
  366. if (end) continue;
  367. ITEMLIST:
  368. if (
  369. gui_ItemlistData[playerid][g][gui_list_ID] > 0 &&
  370. (
  371. (type == GUI_TYPE_WINDOW && gui_ItemlistData[playerid][g][gui_list_Window] == gui &&
  372. (
  373. (!gui_ItemlistData[playerid][g][gui_list_Tab] && toggle) ||
  374. (gui_ItemlistData[playerid][g][gui_list_Tab] > 0 && !toggle)
  375. )
  376. ) ||
  377. (type == GUI_TYPE_TAB && gui_ItemlistData[playerid][g][gui_list_Tab] == gui) ||
  378. (type == gui_ItemlistData[playerid][g][gui_list_Type] && gui_ItemlistData[playerid][g][gui_list_ID] == gui)
  379. ) ||
  380. (
  381. oldw > 0 && oldw == gui_ItemlistData[playerid][g][gui_list_Window] &&
  382. (type == GUI_TYPE_TAB && !gui_ItemlistData[playerid][g][gui_list_Tab])
  383. ) &&
  384. gui_ItemlistData[playerid][g][gui_list_P] == playerid
  385. )
  386. {
  387. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_ItemlistData[playerid][g][gui_list_tdbox]);
  388. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_ItemlistData[playerid][g][gui_list_tdline]);
  389. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_ItemlistData[playerid][g][gui_list_tdtitle]);
  390. pcount_i[playerid] = 0;
  391. for(new r; r <= gui_ItemlistData[playerid][g][gui_list_RowMax]+1; r++)
  392. {
  393. if (gui_ItemRowData[playerid][r][gui_row_ID] > 0 && gui_ItemRowData[playerid][r][gui_row_List] == gui_ItemlistData[playerid][g][gui_list_ID])
  394. {
  395. if ((!pcount_i[playerid] && !p_row[playerid]) || p_row[playerid] == r)
  396. {
  397. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_ItemRowData[playerid][r][gui_row_td2]);
  398. p_row[playerid] = g;
  399. }
  400. else
  401. {
  402. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_ItemRowData[playerid][r][gui_row_td]);
  403. }
  404. }
  405. pcount_i[playerid]++;
  406. }
  407. }
  408. if (end) continue;
  409. CHECKBOX:
  410. if (
  411. gui_CheckboxData[playerid][g][gui_check_ID] > 0 &&
  412. (
  413. (type == GUI_TYPE_WINDOW && gui_CheckboxData[playerid][g][gui_check_Window] == gui &&
  414. (
  415. (!gui_CheckboxData[playerid][g][gui_check_Tab] && toggle) ||
  416. (gui_CheckboxData[playerid][g][gui_check_Tab] > 0 && !toggle)
  417. )
  418. ) ||
  419. (type == GUI_TYPE_TAB && gui_CheckboxData[playerid][g][gui_check_Tab] == gui) ||
  420. (type == gui_CheckboxData[playerid][g][gui_check_Type] && gui_CheckboxData[playerid][g][gui_check_ID] == gui)
  421. ) ||
  422. (
  423. oldw > 0 && oldw == gui_CheckboxData[playerid][g][gui_check_Window] &&
  424. (type == GUI_TYPE_TAB && !gui_CheckboxData[playerid][g][gui_check_Tab])
  425. ) &&
  426. gui_CheckboxData[playerid][g][gui_check_P] == playerid
  427. )
  428. {
  429. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_CheckboxData[playerid][g][gui_check_td]);
  430. }
  431. if (end) continue;
  432. BUTTON:
  433. //printf("Type: %d(%d) | GUI: %d(%d) | Window: %d | Tab: %d", type, gui_ButtonData[playerid][g][gui_but_Type], gui, gui_ButtonData[playerid][g][gui_but_ID], gui_ButtonData[playerid][g][gui_but_Window], gui_ButtonData[playerid][g][gui_but_Tab]);
  434. if (
  435. gui_ButtonData[playerid][g][gui_but_ID] > 0 &&
  436. (
  437. (type == GUI_TYPE_WINDOW && gui_ButtonData[playerid][g][gui_but_Window] == gui &&
  438. (
  439. (!gui_ButtonData[playerid][g][gui_but_Tab] && toggle) ||
  440. (gui_ButtonData[playerid][g][gui_but_Tab] > 0 && !toggle)
  441. )
  442. ) ||
  443. (type == GUI_TYPE_TAB && gui_ButtonData[playerid][g][gui_but_Tab] == gui) ||
  444. (type == gui_ButtonData[playerid][g][gui_but_Type] && gui_ButtonData[playerid][g][gui_but_ID] == gui)
  445. ) ||
  446. (
  447. oldw > 0 && oldw == gui_ButtonData[playerid][g][gui_but_Window] &&
  448. (type == GUI_TYPE_TAB && !gui_ButtonData[playerid][g][gui_but_Tab])
  449. ) &&
  450. gui_ButtonData[playerid][g][gui_but_P] == playerid
  451. )
  452. {
  453. //printf("%s(%d, %d)", str, playerid, io_PlayerText:gui_ButtonData[playerid][g][gui_but_tdbg]);
  454. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_ButtonData[playerid][g][gui_but_tdbg]);
  455. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_ButtonData[playerid][g][gui_but_tdout]);
  456. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_ButtonData[playerid][g][gui_but_tdbox]);
  457. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_ButtonData[playerid][g][gui_but_tdtxt]);
  458. CallLocalFunction(str, "dd", playerid, io_PlayerText:gui_ButtonData[playerid][g][gui_but_tdgl]);
  459. }
  460. if (end) continue;
  461. }
  462. return 1;
  463. }
  464. function guiSetVisibleAll(type, gui, bool:toggle)
  465. {
  466. for(new playerid, m = GetMaxPlayers(); playerid < m; playerid++)
  467. {
  468. if (!IsPlayerConnected(playerid)) continue;
  469. guiSetVisible(playerid, type, gui, toggle);
  470. }
  471. }
  472. /*function guiSetVisibleAll(type, gui, bool:toggle)
  473. {
  474. gui--;
  475. new str[32],end = 0;
  476. if (toggle == true)
  477. {
  478. format(str, sizeof str, "TextDrawShowForAllEx");
  479. }
  480. else if (toggle == false)
  481. {
  482. format(str, sizeof str, "TextDrawHideForAllEx");
  483. }
  484. if (type == GUI_TYPE_WINDOW)
  485. {
  486. CallLocalFunction(str, "d", io_PlayerText:gui_WindowData[gui][gui_win_td]);
  487. CallLocalFunction(str, "d", io_PlayerText:gui_WindowData[gui][gui_win_tdtop]);
  488. CallLocalFunction(str, "d", io_PlayerText:gui_WindowData[gui][gui_win_tdtitle]);
  489. }
  490. else if (type != GUI_TYPE_WINDOW && type != GUI_TYPE_WINDOW) end = 1;
  491. new count;
  492. if (p_tab[playerid] > 0)
  493. {
  494. type = GUI_TYPE_TAB;
  495. gui = gui_TabData[p_tab[playerid]][gui_tab_ID]-1;
  496. }
  497. for(new g; g < MAX_GUI; g++)
  498. {
  499. if (end)
  500. {
  501. switch (type)
  502. {
  503. case GUI_TYPE_TAB: goto TAB;
  504. case GUI_TYPE_LABEL: goto LABEL;
  505. case GUI_TYPE_BAR: goto BAR;
  506. case GUI_TYPE_ITEMLIST: goto ITEMLIST;
  507. case GUI_TYPE_CHECKBOX: goto CHECKBOX;
  508. case GUI_TYPE_BUTTON: goto BUTTON;
  509. }
  510. }
  511. TAB:
  512. if (gui_TabData[g][gui_tab_ID] > 0 && ((type == GUI_TYPE_WINDOW && gui_TabData[g][gui_tab_Window] == gui) || type == gui_TabData[g][gui_tab_Type]))
  513. {
  514. if (!count)
  515. {
  516. for(new playerid; playerid < MAX_PLAYERS; playerid++)
  517. {
  518. if (IsPlayerConnected(playerid) && !p_tab[playerid])
  519. {
  520. p_tab[playerid] = g;
  521. CallLocalFunction(str, "d", io_PlayerText:gui_TabData[g][gui_tab_td2]); // first tab
  522. type = GUI_TYPE_TAB;
  523. gui = gui_TabData[p_tab[playerid]][gui_tab_ID]-1;
  524. }
  525. }
  526. }
  527. else CallLocalFunction(str, "d", io_PlayerText:gui_TabData[g][gui_tab_td]);
  528. CallLocalFunction(str, "d", io_PlayerText:gui_TabData[g][gui_tab_tdbg]);
  529. CallLocalFunction(str, "d", io_PlayerText:gui_TabData[g][gui_tab_tdbox]);
  530. count++;
  531. }
  532. if (end) break;
  533. LABEL:
  534. if (gui_LabelData[g][gui_label_ID] > 0 && ((type == GUI_TYPE_WINDOW && gui_LabelData[g][gui_label_Window] == gui && !gui_LabelData[g][gui_label_Tab]) || (type == GUI_TYPE_TAB && gui_LabelData[g][gui_label_Tab] == gui) || type == gui_LabelData[g][gui_label_Type]))
  535. CallLocalFunction(str, "d", io_PlayerText:gui_LabelData[g][gui_label_td]);
  536. if (end) break;
  537. BAR:
  538. if (gui_BarData[g][gui_bar_ID] > 0 && ((type == GUI_TYPE_WINDOW && gui_BarData[g][gui_bar_Window] == gui && !gui_BarData[g][gui_bar_Tab]) || (type == GUI_TYPE_TAB && gui_BarData[g][gui_bar_Tab] == gui) || type == gui_BarData[g][gui_bar_Type]))
  539. {
  540. CallLocalFunction(str, "d", io_PlayerText:gui_BarData[g][gui_bar_tdbg]);
  541. CallLocalFunction(str, "d", io_PlayerText:gui_BarData[g][gui_bar_tdbox]);
  542. CallLocalFunction(str, "d", io_PlayerText:gui_BarData[g][gui_bar_tdbar]);
  543. }
  544. if (end) break;
  545. ITEMLIST:
  546. if (gui_ItemlistData[g][gui_list_ID] > 0 && ((type == GUI_TYPE_WINDOW && gui_ItemlistData[g][gui_list_Window] == gui && !gui_ItemlistData[g][gui_list_Tab]) || (type == GUI_TYPE_TAB && gui_ItemlistData[g][gui_list_Tab] == gui) || type == gui_ItemlistData[g][gui_list_Type]))
  547. {
  548. CallLocalFunction(str, "d", io_PlayerText:gui_ItemlistData[g][gui_list_tdbox]);
  549. CallLocalFunction(str, "d", io_PlayerText:gui_ItemlistData[g][gui_list_tdline]);
  550. CallLocalFunction(str, "d", io_PlayerText:gui_ItemlistData[g][gui_list_tdtitle]);
  551. count = 0;
  552. for(new r; r <= gui_ItemlistData[g][gui_list_RowMax]+1; r++)
  553. {
  554. if (gui_ItemRowData[playerid][r][gui_row_ID] > 0)
  555. {
  556. if (!count)
  557. {
  558. CallLocalFunction(str, "d", io_PlayerText:gui_ItemRowData[playerid][r][gui_row_td2]);
  559. for(new playerid; playerid < MAX_PLAYERS; playerid++)
  560. p_row[playerid] = g;
  561. }
  562. else CallLocalFunction(str, "d", io_PlayerText:gui_ItemRowData[playerid][r][gui_row_td]);
  563. }
  564. count++;
  565. }
  566. }
  567. if (end) break;
  568. CHECKBOX:
  569. if (gui_CheckboxData[g][gui_check_ID] > 0 && ((type == GUI_TYPE_WINDOW && gui_CheckboxData[g][gui_check_Window] == gui && !gui_CheckboxData[g][gui_check_Tab]) || (type == GUI_TYPE_TAB && gui_CheckboxData[g][gui_check_Tab] == gui) || type == gui_CheckboxData[g][gui_check_Type]))
  570. {
  571. CallLocalFunction(str, "d", io_PlayerText:gui_CheckboxData[g][gui_check_td]);
  572. }
  573. if (end) break;
  574. BUTTON:
  575. if (gui_ButtonData[g][gui_but_ID] > 0 && ((type == GUI_TYPE_WINDOW && gui_ButtonData[g][gui_but_Window] == gui && !gui_ButtonData[g][gui_but_Tab]) || (type == GUI_TYPE_TAB && gui_ButtonData[g][gui_but_Tab] == gui) || type == gui_ButtonData[g][gui_but_Type]))
  576. {
  577. CallLocalFunction(str, "d", io_PlayerText:gui_ButtonData[g][gui_but_tdbg]);
  578. CallLocalFunction(str, "d", io_PlayerText:gui_ButtonData[g][gui_but_tdout]);
  579. CallLocalFunction(str, "d", io_PlayerText:gui_ButtonData[g][gui_but_tdbox]);
  580. CallLocalFunction(str, "d", io_PlayerText:gui_ButtonData[g][gui_but_tdtxt]);
  581. CallLocalFunction(str, "d", io_PlayerText:gui_ButtonData[g][gui_but_tdgl]);
  582. }
  583. if (end) break;
  584. }
  585. }*/
  586. function guiCreateWindow(playerid, Float:x, Float:y, Float:size_x, Float:size_y, title[])
  587. {
  588. new wid = -1;
  589. for(new c; c < MAX_GUI; c++)
  590. {
  591. if (!gui_WindowData[playerid][c][gui_win_ID])
  592. {
  593. wid = c;
  594. break;
  595. }
  596. }
  597. if (wid == -1) return !printf("ERROR GUI: You cannot exceed the GUI window limit! (%d)", MAX_GUI);
  598. gui_WindowData[playerid][wid][gui_win_X] = x;
  599. gui_WindowData[playerid][wid][gui_win_Y] = y;
  600. gui_WindowData[playerid][wid][gui_win_SizeX] = size_x;
  601. gui_WindowData[playerid][wid][gui_win_SizeY] = size_y;
  602. strins(gui_WindowData[playerid][wid][gui_win_Title], title, 0);
  603. gui_WindowData[playerid][wid][gui_win_P] = playerid;
  604. gui_WindowData[playerid][wid][gui_win_ID] = wid+1;
  605. gui_WindowData[playerid][wid][gui_win_td] = CreatePlayerTextDraw(playerid, x, y, "_");
  606. PlayerTextDrawAlignment(playerid, gui_WindowData[playerid][wid][gui_win_td], 2);
  607. PlayerTextDrawBackgroundColor(playerid, gui_WindowData[playerid][wid][gui_win_td], 255);
  608. PlayerTextDrawFont(playerid, gui_WindowData[playerid][wid][gui_win_td], 1);
  609. PlayerTextDrawLetterSize(playerid, gui_WindowData[playerid][wid][gui_win_td], 0.500000, size_y*UNIT);
  610. PlayerTextDrawColor(playerid, gui_WindowData[playerid][wid][gui_win_td], -1);
  611. PlayerTextDrawSetOutline(playerid, gui_WindowData[playerid][wid][gui_win_td], 1);
  612. PlayerTextDrawSetProportional(playerid, gui_WindowData[playerid][wid][gui_win_td], 1);
  613. PlayerTextDrawUseBox(playerid, gui_WindowData[playerid][wid][gui_win_td], 1);
  614. PlayerTextDrawBoxColor(playerid, gui_WindowData[playerid][wid][gui_win_td], 155);
  615. PlayerTextDrawTextSize(playerid, gui_WindowData[playerid][wid][gui_win_td], 0.000000, size_x);
  616. gui_WindowData[playerid][wid][gui_win_tdtop] = CreatePlayerTextDraw(playerid, x, y, "_");
  617. PlayerTextDrawAlignment(playerid, gui_WindowData[playerid][wid][gui_win_tdtop], 2);
  618. PlayerTextDrawBackgroundColor(playerid, gui_WindowData[playerid][wid][gui_win_tdtop], 255);
  619. PlayerTextDrawFont(playerid, gui_WindowData[playerid][wid][gui_win_tdtop], 1);
  620. PlayerTextDrawLetterSize(playerid, gui_WindowData[playerid][wid][gui_win_tdtop], 0.500000, 0.599997);
  621. PlayerTextDrawColor(playerid, gui_WindowData[playerid][wid][gui_win_tdtop], -1);
  622. PlayerTextDrawSetOutline(playerid, gui_WindowData[playerid][wid][gui_win_tdtop], 1);
  623. PlayerTextDrawSetProportional(playerid, gui_WindowData[playerid][wid][gui_win_tdtop], 1);
  624. PlayerTextDrawUseBox(playerid, gui_WindowData[playerid][wid][gui_win_tdtop], 1);
  625. PlayerTextDrawBoxColor(playerid, gui_WindowData[playerid][wid][gui_win_tdtop], -1296911838);
  626. PlayerTextDrawTextSize(playerid, gui_WindowData[playerid][wid][gui_win_tdtop], 0.000000, size_x);
  627. gui_WindowData[playerid][wid][gui_win_tdtitle] = CreatePlayerTextDraw(playerid, x, y-1.0, title);
  628. PlayerTextDrawAlignment(playerid, gui_WindowData[playerid][wid][gui_win_tdtitle], 2);
  629. PlayerTextDrawBackgroundColor(playerid, gui_WindowData[playerid][wid][gui_win_tdtitle], 255);
  630. PlayerTextDrawFont(playerid, gui_WindowData[playerid][wid][gui_win_tdtitle], 2);
  631. PlayerTextDrawLetterSize(playerid, gui_WindowData[playerid][wid][gui_win_tdtitle], 0.179999, 0.799997);
  632. PlayerTextDrawColor(playerid, gui_WindowData[playerid][wid][gui_win_tdtitle], -1);
  633. PlayerTextDrawSetOutline(playerid, gui_WindowData[playerid][wid][gui_win_tdtitle], 0);
  634. PlayerTextDrawSetProportional(playerid, gui_WindowData[playerid][wid][gui_win_tdtitle], 1);
  635. PlayerTextDrawSetShadow(playerid, gui_WindowData[playerid][wid][gui_win_tdtitle], 0);
  636. return gui_WindowData[playerid][wid][gui_win_ID];
  637. }
  638. function guiCreateTab(playerid, windowid, Float:x, Float:y, Float:height, Float:width, text[])
  639. {
  640. new id = -1, pos, Float:len, wind = windowid;
  641. for(new c; c < MAX_GUI; c++)
  642. {
  643. if (!gui_TabData[playerid][c][gui_tab_ID] && id == -1)
  644. {
  645. id = c;
  646. //printf("TAB ID: %d", c);
  647. }
  648. if (gui_TabData[playerid][c][gui_tab_Window] == windowid)
  649. {
  650. pos++;
  651. len += (float(strlen(gui_TabData[playerid][c][gui_tab_Text]))*5.0)+4.0 + gui_TabData[playerid][c][gui_tab_plusX];
  652. }
  653. }
  654. if (id == -1) return !printf("ERROR GUI: You cannot exceed the GUI tab limit! (%d)", MAX_GUI);
  655. new units = strlen(text)*5; // Every char is 5 units space
  656. new Float:boxX = x, Float:boxY = y+10.0, Float:tabheight = 0.799996;
  657. if (windowid > 0) // If you set the tab under a GUI Window ...
  658. {
  659. windowid = guiGetID(playerid, GUI_TYPE_WINDOW, windowid);
  660. /*printf("CURRENT LEN: %.2f | MAX LEN: %.2f | TOTAL: %d(%d)", (gui_WindowData[windowid][gui_win_X]-(gui_WindowData[windowid][gui_win_SizeX]/2))+((len+units)/2)+4.0, gui_WindowData[windowid][gui_win_X]+(gui_WindowData[windowid][gui_win_SizeX]/2), len+units, units);
  661. if (((gui_WindowData[windowid][gui_win_X]-(gui_WindowData[windowid][gui_win_SizeX]/2))+((len+units)/2)+4.0) > (gui_WindowData[windowid][gui_win_X]+(gui_WindowData[windowid][gui_win_SizeX]/2)))
  662. {
  663. printf("ERROR GUI: Tab %d cannot be created because it does not fit in the window!", id);
  664. gui_TabData[playerid][id][gui_tab_ID] = 0;
  665. return 0;
  666. }*/
  667. gui_TabData[playerid][id][gui_tab_plusX] = x;
  668. boxX = gui_WindowData[playerid][windowid][gui_win_X];
  669. x += (gui_WindowData[playerid][windowid][gui_win_X]-(gui_WindowData[playerid][windowid][gui_win_SizeX]/2)); // relative positioning
  670. y += (gui_WindowData[playerid][windowid][gui_win_Y]+10.0);
  671. boxY = y+10.5;
  672. if (height == 0.0) height = ( ((gui_WindowData[playerid][windowid][gui_win_SizeY])*UNIT) - (20.0)*UNIT ) - (4.0*UNIT);
  673. else height *= UNIT;
  674. if (width == 0.0) width = gui_WindowData[playerid][windowid][gui_win_SizeX]-3.0;
  675. else width += gui_WindowData[playerid][windowid][gui_win_SizeX];
  676. //printf("CURRENT: %.2f | MAXIMUM: %.2f", (x+units+len+4.0), gui_WindowData[windowid][gui_win_X]+(gui_WindowData[windowid][gui_win_SizeX]/2));
  677. if ((x+float(units)+len+4.0+gui_TabData[playerid][id][gui_tab_plusX]) > (gui_WindowData[playerid][windowid][gui_win_X]+(gui_WindowData[playerid][windowid][gui_win_SizeX]/2)))
  678. {
  679. printf("ERROR GUI: Tab %d cannot be created because it does not fit in the window!", id);
  680. gui_TabData[playerid][id][gui_tab_ID] = 0;
  681. return 0;
  682. }
  683. //printf("height:%.2f | width: %.2f | boxY: %.2f | winY: %.2f = %.2f", height, width, boxY, gui_WindowData[playerid][windowid][gui_win_SizeY], gui_WindowData[playerid][windowid][gui_win_Y]-boxY);
  684. }
  685. if (pos > 0)
  686. {
  687. for(new c; c < MAX_GUI; c++)
  688. {
  689. if (!gui_TabData[playerid][c][gui_tab_ID]) continue;
  690. if (gui_TabData[playerid][c][gui_tab_Window] == wind)
  691. {
  692. gui_TabData[playerid][c][gui_tab_panel] = id;
  693. x += float(strlen(gui_TabData[playerid][c][gui_tab_Text]))*5+4.0 + gui_TabData[playerid][c][gui_tab_plusX];
  694. //if (pos == 7) x = gui_WindowData[playerid][windowid][gui_win_X]-(gui_WindowData[playerid][windowid][gui_win_SizeX]/2);
  695. //printf("(%d)x:%.2f - %d(%s)", c, x, strlen(gui_TabData[playerid][c][gui_tab_Text]), gui_TabData[playerid][c][gui_tab_Text]);
  696. }
  697. }
  698. }
  699. gui_TabData[playerid][id][gui_tab_X] = x;
  700. gui_TabData[playerid][id][gui_tab_Y] = y;
  701. gui_TabData[playerid][id][gui_tab_Height] = height;
  702. gui_TabData[playerid][id][gui_tab_Width] = width;
  703. strins(gui_TabData[playerid][id][gui_tab_Text], text, 0);
  704. gui_TabData[playerid][id][gui_tab_Window] = wind;
  705. gui_TabData[playerid][id][gui_tab_panelX] = boxX;
  706. gui_TabData[playerid][id][gui_tab_panelY] = boxY+2.0;
  707. gui_TabData[playerid][id][gui_tab_Type] = GUI_TYPE_TAB;
  708. gui_TabData[playerid][id][gui_tab_P] = playerid;
  709. gui_TabData[playerid][id][gui_tab_ID] = id+1;
  710. gui_TabData[playerid][id][gui_tab_td] = CreatePlayerTextDraw(playerid, (x+2.0+float(units)/2), y, text);
  711. PlayerTextDrawAlignment(playerid, gui_TabData[playerid][id][gui_tab_td], 2);
  712. PlayerTextDrawBackgroundColor(playerid, gui_TabData[playerid][id][gui_tab_td], 255);
  713. PlayerTextDrawFont(playerid, gui_TabData[playerid][id][gui_tab_td], 2);
  714. PlayerTextDrawLetterSize(playerid, gui_TabData[playerid][id][gui_tab_td], 0.179998, tabheight);
  715. PlayerTextDrawColor(playerid, gui_TabData[playerid][id][gui_tab_td], -1);
  716. PlayerTextDrawSetOutline(playerid, gui_TabData[playerid][id][gui_tab_td], 0);
  717. PlayerTextDrawSetProportional(playerid, gui_TabData[playerid][id][gui_tab_td], 1);
  718. PlayerTextDrawSetShadow(playerid, gui_TabData[playerid][id][gui_tab_td], 0);
  719. PlayerTextDrawUseBox(playerid, gui_TabData[playerid][id][gui_tab_td], 1);
  720. PlayerTextDrawBoxColor(playerid, gui_TabData[playerid][id][gui_tab_td], 0x6F6F6F22);
  721. PlayerTextDrawTextSize(playerid, gui_TabData[playerid][id][gui_tab_td], tabheight/UNIT, float(units));
  722. PlayerTextDrawSetSelectable(playerid, gui_TabData[playerid][id][gui_tab_td], 1);
  723. gui_TabData[playerid][id][gui_tab_td2] = CreatePlayerTextDraw(playerid, (x+2.0+float(units)/2), y, text);
  724. PlayerTextDrawAlignment(playerid, gui_TabData[playerid][id][gui_tab_td2], 2);
  725. PlayerTextDrawBackgroundColor(playerid, gui_TabData[playerid][id][gui_tab_td2], 255);
  726. PlayerTextDrawFont(playerid, gui_TabData[playerid][id][gui_tab_td2], 2);
  727. PlayerTextDrawLetterSize(playerid, gui_TabData[playerid][id][gui_tab_td2], 0.179998, tabheight);
  728. PlayerTextDrawColor(playerid, gui_TabData[playerid][id][gui_tab_td2], -1);
  729. PlayerTextDrawSetOutline(playerid, gui_TabData[playerid][id][gui_tab_td2], 0);
  730. PlayerTextDrawSetProportional(playerid, gui_TabData[playerid][id][gui_tab_td2], 1);
  731. PlayerTextDrawSetShadow(playerid, gui_TabData[playerid][id][gui_tab_td2], 0);
  732. PlayerTextDrawUseBox(playerid, gui_TabData[playerid][id][gui_tab_td2], 1);
  733. PlayerTextDrawBoxColor(playerid, gui_TabData[playerid][id][gui_tab_td2], 0xC3C3C344);
  734. PlayerTextDrawTextSize(playerid, gui_TabData[playerid][id][gui_tab_td2], tabheight/UNIT, float(units));
  735. if (!pos) // only the first tab will create the tab panel
  736. {
  737. gui_TabData[playerid][id][gui_tab_panel] = id;
  738. gui_TabData[playerid][id][gui_tab_tdbg] = CreatePlayerTextDraw(playerid, boxX, boxY, "_");
  739. PlayerTextDrawAlignment(playerid, gui_TabData[playerid][id][gui_tab_tdbg], 2);
  740. PlayerTextDrawBackgroundColor(playerid, gui_TabData[playerid][id][gui_tab_tdbg], 255);
  741. PlayerTextDrawFont(playerid, gui_TabData[playerid][id][gui_tab_tdbg], 1);
  742. PlayerTextDrawLetterSize(playerid, gui_TabData[playerid][id][gui_tab_tdbg], 0.199998, height);
  743. PlayerTextDrawColor(playerid, gui_TabData[playerid][id][gui_tab_tdbg], -1);
  744. PlayerTextDrawSetOutline(playerid, gui_TabData[playerid][id][gui_tab_tdbg], 0);
  745. PlayerTextDrawSetProportional(playerid, gui_TabData[playerid][id][gui_tab_tdbg], 1);
  746. PlayerTextDrawSetShadow(playerid, gui_TabData[playerid][id][gui_tab_tdbg], 0);
  747. PlayerTextDrawUseBox(playerid, gui_TabData[playerid][id][gui_tab_tdbg], 1);
  748. PlayerTextDrawBoxColor(playerid, gui_TabData[playerid][id][gui_tab_tdbg], 0xC3C3C344);
  749. PlayerTextDrawTextSize(playerid, gui_TabData[playerid][id][gui_tab_tdbg], 0.0, width);
  750. gui_TabData[playerid][id][gui_tab_tdbox] = CreatePlayerTextDraw(playerid, boxX, boxY+2.0, "_");
  751. PlayerTextDrawAlignment(playerid, gui_TabData[playerid][id][gui_tab_tdbox], 2);
  752. PlayerTextDrawBackgroundColor(playerid, gui_TabData[playerid][id][gui_tab_tdbox], 255);
  753. PlayerTextDrawFont(playerid, gui_TabData[playerid][id][gui_tab_tdbox], 1);
  754. PlayerTextDrawLetterSize(playerid, gui_TabData[playerid][id][gui_tab_tdbox], 0.199998, height-(4.0*UNIT));
  755. PlayerTextDrawColor(playerid, gui_TabData[playerid][id][gui_tab_tdbox], -1);
  756. PlayerTextDrawSetOutline(playerid, gui_TabData[playerid][id][gui_tab_tdbox], 0);
  757. PlayerTextDrawSetProportional(playerid, gui_TabData[playerid][id][gui_tab_tdbox], 1);
  758. PlayerTextDrawSetShadow(playerid, gui_TabData[playerid][id][gui_tab_tdbox], 0);
  759. PlayerTextDrawUseBox(playerid, gui_TabData[playerid][id][gui_tab_tdbox], 1);
  760. PlayerTextDrawBoxColor(playerid, gui_TabData[playerid][id][gui_tab_tdbox], 153);
  761. PlayerTextDrawTextSize(playerid, gui_TabData[playerid][id][gui_tab_tdbox], 0.0, width-3.0);
  762. }
  763. return gui_TabData[playerid][id][gui_tab_ID];
  764. }
  765. function guiCreateLabel(playerid, windowid, tabid, Float:x, Float:y, Float:length, color, font, text[])
  766. {
  767. new id = -1, wind = windowid, t = tabid;
  768. for(new c; c < MAX_GUI; c++)
  769. {
  770. if (!gui_LabelData[playerid][c][gui_label_ID])
  771. {
  772. id = c;
  773. break;
  774. }
  775. }
  776. if (id == -1) return !printf("ERROR GUI: You cannot exceed the GUI label limit! (%d)", MAX_GUI);
  777. if (windowid > 0) // If you set the label under a GUI Window ...
  778. {
  779. windowid = guiGetID(playerid, GUI_TYPE_WINDOW, windowid);
  780. if (tabid > 0) // if it's under a tab panel
  781. {
  782. tabid = guiGetID(playerid, GUI_TYPE_TAB, tabid);
  783. x += (gui_TabData[playerid][tabid][gui_tab_panelX]-(gui_TabData[playerid][tabid][gui_tab_Width]/2))+1.5;
  784. y += (gui_TabData[playerid][tabid][gui_tab_panelY]-(gui_TabData[playerid][tabid][gui_tab_Height]/2))+6.0; // relative positioning
  785. if (length == 0.0) length = x+gui_TabData[playerid][tabid][gui_tab_Width];
  786. else length += x;
  787. }
  788. else // only under a window gui
  789. {
  790. x += (gui_WindowData[playerid][windowid][gui_win_X]-(gui_WindowData[playerid][windowid][gui_win_SizeX]/2));
  791. y += (gui_WindowData[playerid][windowid][gui_win_Y]+7.0); // relative positioning
  792. // SendFormatMessage(0, 0xFFFFFFFF, "%f - %f", gui_WindowData[playerid][windowid][gui_win_SizeX], gui_WindowData[playerid][windowid][gui_win_X]+gui_WindowData[playerid][windowid][gui_win_SizeX]);
  793. if (length == 0.0) length = x+gui_WindowData[playerid][windowid][gui_win_SizeX];
  794. else length += x;
  795. }
  796. }
  797. gui_LabelData[playerid][id][gui_label_X] = x;
  798. gui_LabelData[playerid][id][gui_label_Y] = y;
  799. gui_LabelData[playerid][id][gui_label_Length] = length;
  800. strins(gui_LabelData[playerid][id][gui_label_Text], text, 0);
  801. gui_LabelData[playerid][id][gui_label_Window] = wind;
  802. gui_LabelData[playerid][id][gui_label_Tab] = t;
  803. gui_LabelData[playerid][id][gui_label_Color] = color;
  804. gui_LabelData[playerid][id][gui_label_Type] = GUI_TYPE_LABEL;
  805. gui_LabelData[playerid][id][gui_label_P] = playerid;
  806. gui_LabelData[playerid][id][gui_label_ID] = id+1;
  807. gui_LabelData[playerid][id][gui_label_td] = CreatePlayerTextDraw(playerid, x, y, text);
  808. PlayerTextDrawBackgroundColor(playerid, gui_LabelData[playerid][id][gui_label_td], 255);
  809. PlayerTextDrawFont(playerid, gui_LabelData[playerid][id][gui_label_td], font);
  810. PlayerTextDrawLetterSize(playerid, gui_LabelData[playerid][id][gui_label_td], 0.199998, 0.799996);
  811. PlayerTextDrawColor(playerid, gui_LabelData[playerid][id][gui_label_td], color);
  812. PlayerTextDrawSetOutline(playerid, gui_LabelData[playerid][id][gui_label_td], 0);
  813. PlayerTextDrawSetProportional(playerid, gui_LabelData[playerid][id][gui_label_td], 1);
  814. PlayerTextDrawSetShadow(playerid, gui_LabelData[playerid][id][gui_label_td], 0);
  815. PlayerTextDrawUseBox(playerid, gui_LabelData[playerid][id][gui_label_td], 1);
  816. PlayerTextDrawBoxColor(playerid, gui_LabelData[playerid][id][gui_label_td], 0xFFFFFF00);
  817. PlayerTextDrawTextSize(playerid, gui_LabelData[playerid][id][gui_label_td], length, 0.000000);
  818. return gui_LabelData[playerid][id][gui_label_ID];
  819. }
  820. function guiLabelSetText(playerid, labelid, color, font, text[])
  821. {
  822. if (labelid >= MAX_GUI) return 0;
  823. new id = guiGetID(playerid, GUI_TYPE_LABEL, labelid);
  824. if (id == -1) return 0;
  825. if (!IsPlayerConnected(playerid)) return 0;
  826. PlayerTextDrawDestroy(playerid, gui_LabelData[playerid][id][gui_label_td]);
  827. new PlayerText:txt = CreatePlayerTextDraw(playerid, gui_LabelData[playerid][id][gui_label_X], gui_LabelData[playerid][id][gui_label_Y], text);
  828. PlayerTextDrawBackgroundColor(playerid, txt, 255);
  829. PlayerTextDrawFont(playerid, txt, font);
  830. PlayerTextDrawLetterSize(playerid, txt, 0.199998, 0.799996);
  831. PlayerTextDrawColor(playerid, txt, color);
  832. PlayerTextDrawSetOutline(playerid, txt, 0);
  833. PlayerTextDrawSetProportional(playerid, txt, 1);
  834. PlayerTextDrawSetShadow(playerid, txt, 0);
  835. PlayerTextDrawUseBox(playerid, txt, 1);
  836. PlayerTextDrawBoxColor(playerid, txt, 0xFFFFFF00);
  837. PlayerTextDrawTextSize(playerid, txt, gui_LabelData[playerid][id][gui_label_Length], 0.000000);
  838. gui_LabelData[playerid][id][gui_label_Color] = color;
  839. strdel(gui_LabelData[playerid][id][gui_label_Text], 0, strlen(gui_LabelData[playerid][id][gui_label_Text]));
  840. strins(gui_LabelData[playerid][id][gui_label_Text], text, 0);
  841. //printf("%s",text);
  842. gui_LabelData[playerid][id][gui_label_td] = txt;
  843. if (GetTextDrawVisibilityForPlayer(playerid, txt)) PlayerTextDrawShow(playerid, txt);
  844. return 1;
  845. }
  846. function guiCreateProgressBar(playerid, windowid, tabid, Float:x, Float:y, Float:height, Float:width, color_bg, color_box, color_bar)
  847. {
  848. new id = -1, wind = windowid, t = tabid;
  849. for(new c; c < MAX_GUI; c++)
  850. {
  851. if (!gui_BarData[playerid][c][gui_bar_ID])
  852. {
  853. id = c;
  854. break;
  855. }
  856. }
  857. if (id == -1) return !printf("ERROR GUI: You cannot exceed the GUI progress bar limit! (%d)", MAX_GUI);
  858. if (windowid > 0) // If you set the label under a GUI Window ...
  859. {
  860. windowid = guiGetID(playerid, GUI_TYPE_WINDOW, windowid);
  861. if (tabid > 0) // if it's under a tab panel
  862. {
  863. tabid = guiGetID(playerid, GUI_TYPE_TAB, tabid);
  864. x += (gui_TabData[playerid][tabid][gui_tab_panelX]-(gui_TabData[playerid][tabid][gui_tab_Width]/2))+1.5;
  865. y += (gui_TabData[playerid][tabid][gui_tab_panelY]-(gui_TabData[playerid][tabid][gui_tab_Height]/2))+6.0; // relative positioning
  866. }
  867. else // only under a window gui
  868. {
  869. x += (gui_WindowData[playerid][windowid][gui_win_X]-(gui_WindowData[playerid][windowid][gui_win_SizeX]/2));
  870. y += (gui_WindowData[playerid][windowid][gui_win_Y]+7.0); // relative positioning
  871. }
  872. }
  873. gui_BarData[playerid][id][gui_bar_X] = x;
  874. gui_BarData[playerid][id][gui_bar_Y] = y;
  875. gui_BarData[playerid][id][gui_bar_Height] = height;
  876. gui_BarData[playerid][id][gui_bar_Width] = width;
  877. gui_BarData[playerid][id][gui_bar_Window] = wind;
  878. gui_BarData[playerid][id][gui_bar_Tab] = t;
  879. gui_BarData[playerid][id][gui_bar_Progress] = 100.0; // 100%
  880. gui_BarData[playerid][id][gui_bar_bgcolor] = color_bg;
  881. gui_BarData[playerid][id][gui_bar_boxcolor] = color_box;
  882. gui_BarData[playerid][id][gui_bar_barcolor] = color_bar;
  883. gui_BarData[playerid][id][gui_bar_Type] = GUI_TYPE_BAR;
  884. gui_BarData[playerid][id][gui_bar_P] = playerid;
  885. gui_BarData[playerid][id][gui_bar_ID] = id+1;
  886. gui_BarData[playerid][id][gui_bar_tdbg] = CreatePlayerTextDraw(playerid, x, y, "_");
  887. PlayerTextDrawBackgroundColor(playerid, gui_BarData[playerid][id][gui_bar_tdbg], 255);
  888. PlayerTextDrawFont(playerid, gui_BarData[playerid][id][gui_bar_tdbg], 1);
  889. PlayerTextDrawLetterSize(playerid, gui_BarData[playerid][id][gui_bar_tdbg], 0.0, height*UNIT);
  890. PlayerTextDrawColor(playerid, gui_BarData[playerid][id][gui_bar_tdbg], -1);
  891. PlayerTextDrawSetOutline(playerid, gui_BarData[playerid][id][gui_bar_tdbg], 1);
  892. PlayerTextDrawSetProportional(playerid, gui_BarData[playerid][id][gui_bar_tdbg], 1);
  893. PlayerTextDrawUseBox(playerid, gui_BarData[playerid][id][gui_bar_tdbg], 1);
  894. PlayerTextDrawBoxColor(playerid, gui_BarData[playerid][id][gui_bar_tdbg], color_bg);
  895. PlayerTextDrawTextSize(playerid, gui_BarData[playerid][id][gui_bar_tdbg], x+width, 0.000000);
  896. gui_BarData[playerid][id][gui_bar_tdbox] = CreatePlayerTextDraw(playerid, x+2.0, y+2.0, "_");
  897. PlayerTextDrawBackgroundColor(playerid, gui_BarData[playerid][id][gui_bar_tdbox], 255);
  898. PlayerTextDrawFont(playerid, gui_BarData[playerid][id][gui_bar_tdbox], 1);
  899. PlayerTextDrawLetterSize(playerid, gui_BarData[playerid][id][gui_bar_tdbox], 0.0, (height*UNIT)-(4.0*UNIT));
  900. PlayerTextDrawColor(playerid, gui_BarData[playerid][id][gui_bar_tdbox], -1);
  901. PlayerTextDrawSetOutline(playerid, gui_BarData[playerid][id][gui_bar_tdbox], 1);
  902. PlayerTextDrawSetProportional(playerid, gui_BarData[playerid][id][gui_bar_tdbox], 1);
  903. PlayerTextDrawUseBox(playerid, gui_BarData[playerid][id][gui_bar_tdbox], 1);
  904. PlayerTextDrawBoxColor(playerid, gui_BarData[playerid][id][gui_bar_tdbox], color_box);
  905. PlayerTextDrawTextSize(playerid, gui_BarData[playerid][id][gui_bar_tdbox], x+width-2.0, 0.000000);
  906. gui_BarData[playerid][id][gui_bar_tdbar] = CreatePlayerTextDraw(playerid, x+2.0, y+2.0, "_");
  907. PlayerTextDrawBackgroundColor(playerid, gui_BarData[playerid][id][gui_bar_tdbar], 255);
  908. PlayerTextDrawFont(playerid, gui_BarData[playerid][id][gui_bar_tdbar], 1);
  909. PlayerTextDrawLetterSize(playerid, gui_BarData[playerid][id][gui_bar_tdbar], 0.0, (height*UNIT)-(4.0*UNIT));
  910. PlayerTextDrawColor(playerid, gui_BarData[playerid][id][gui_bar_tdbar], -1);
  911. PlayerTextDrawSetOutline(playerid, gui_BarData[playerid][id][gui_bar_tdbar], 1);
  912. PlayerTextDrawSetProportional(playerid, gui_BarData[playerid][id][gui_bar_tdbar], 1);
  913. PlayerTextDrawUseBox(playerid, gui_BarData[playerid][id][gui_bar_tdbar], 1);
  914. PlayerTextDrawBoxColor(playerid, gui_BarData[playerid][id][gui_bar_tdbar], color_bar);
  915. PlayerTextDrawTextSize(playerid, gui_BarData[playerid][id][gui_bar_tdbar], x+width-2.0, 0.000000);
  916. return gui_BarData[playerid][id][gui_bar_ID];
  917. }
  918. function guiProgressBarSetProgress(playerid, barid, Float:progress)
  919. {
  920. if (barid >= MAX_GUI) return 0;
  921. new r;
  922. for(new g; g < MAX_GUI; g++)
  923. {
  924. if (gui_BarData[playerid][g][gui_bar_ID] == barid)
  925. {
  926. barid = g;
  927. r = 1;
  928. break;
  929. }
  930. }
  931. if (!r) return 0;
  932. if (!gui_BarData[playerid][barid][gui_bar_ID]) return 0;
  933. gui_BarData[playerid][barid][gui_bar_Progress] = progress;
  934. new Float:size = (gui_BarData[playerid][barid][gui_bar_X]+gui_BarData[playerid][barid][gui_bar_Width]-2.0) - gui_BarData[playerid][barid][gui_bar_X];
  935. size *= progress/100.0;
  936. PlayerTextDrawTextSize(gui_BarData[playerid][barid][gui_bar_P], gui_BarData[playerid][barid][gui_bar_tdbar], gui_BarData[playerid][barid][gui_bar_X]+size, 0.000000);
  937. if (GetTextDrawVisibilityForPlayer(gui_BarData[playerid][barid][gui_bar_P], gui_BarData[playerid][barid][gui_bar_tdbg]))
  938. {
  939. PlayerTextDrawShow(gui_BarData[playerid][barid][gui_bar_P], gui_BarData[playerid][barid][gui_bar_tdbg]);
  940. PlayerTextDrawShow(gui_BarData[playerid][barid][gui_bar_P], gui_BarData[playerid][barid][gui_bar_tdbox]);
  941. PlayerTextDrawShow(gui_BarData[playerid][barid][gui_bar_P], gui_BarData[playerid][barid][gui_bar_tdbar]);
  942. }
  943. /*for(new i; i < MAX_PLAYERS; i++)
  944. {
  945. if (!IsPlayerConnected(i)) continue;
  946. if (GetTextDrawVisibilityForPlayer(i, gui_BarData[barid][gui_bar_tdbg]))
  947. {
  948. PlayerTextDrawShow(i, gui_BarData[barid][gui_bar_tdbg]);
  949. PlayerTextDrawShow(i, gui_BarData[barid][gui_bar_tdbox]);
  950. PlayerTextDrawShow(i, gui_BarData[barid][gui_bar_tdbar]);
  951. }
  952. }*/
  953. return 1;
  954. }
  955. function Float:guiProgressBarGetProgress(playerid, barid)
  956. {
  957. if (barid >= MAX_GUI) return -1.0;
  958. new r;
  959. for(new g; g < MAX_GUI; g++)
  960. {
  961. if (gui_BarData[playerid][g][gui_bar_ID] == barid)
  962. {
  963. barid = g;
  964. r = 1;
  965. break;
  966. }
  967. }
  968. if (!r) return -1.0;
  969. if (!gui_BarData[playerid][barid][gui_bar_ID]) return -1.0;
  970. return gui_BarData[playerid][barid][gui_bar_Progress];
  971. }
  972. function guiCreateItemList(playerid, windowid, tabid, Float:x, Float:y, Float:height, Float:width, title[])
  973. {
  974. new id = -1, wind = windowid, t = tabid;
  975. for(new c; c < MAX_GUI; c++)
  976. {
  977. if (!gui_ItemlistData[playerid][c][gui_list_ID])
  978. {
  979. id = c;
  980. break;
  981. }
  982. }
  983. if (id == -1) return !printf("ERROR GUI: You cannot exceed the GUI item list limit! (%d)", MAX_GUI);
  984. if (windowid > 0) // If you set the tab under a GUI Window ...
  985. {
  986. windowid = guiGetID(playerid, GUI_TYPE_WINDOW, windowid);
  987. if (tabid > 0)
  988. {
  989. tabid = guiGetID(playerid, GUI_TYPE_TAB, tabid);
  990. new Float:offsetY = y;
  991. x += gui_TabData[playerid][tabid][gui_tab_panelX]-0.5;
  992. y += (gui_TabData[playerid][tabid][gui_tab_panelY]+3.0);
  993. if (height == 0.0) height = gui_TabData[playerid][tabid][gui_tab_Height] - (8.0*UNIT) - (2.0*UNIT) - (offsetY*UNIT);
  994. else height *= UNIT;
  995. if (width == 0.0) width = gui_TabData[playerid][tabid][gui_tab_Width]-7.5;
  996. else x = x-(gui_TabData[playerid][tabid][gui_tab_Width]/2)+(width/2)+4.0;
  997. }
  998. else
  999. {
  1000. x += gui_WindowData[playerid][windowid][gui_win_X];
  1001. y += (gui_WindowData[playerid][windowid][gui_win_Y]+10.5);
  1002. if (height == 0.0) height = ( ((gui_WindowData[playerid][windowid][gui_win_SizeY])*UNIT) - (20.0)*UNIT ) - (4.0*UNIT);
  1003. else height *= UNIT;
  1004. if (width == 0.0) width = gui_WindowData[playerid][windowid][gui_win_SizeX]-3.0;
  1005. else width += gui_WindowData[playerid][windowid][gui_win_SizeX];
  1006. }
  1007. }
  1008. else height *= UNIT;
  1009. gui_ItemlistData[playerid][id][gui_list_X] = x;
  1010. gui_ItemlistData[playerid][id][gui_list_Y] = y;
  1011. gui_ItemlistData[playerid][id][gui_list_Height] = height;
  1012. gui_ItemlistData[playerid][id][gui_list_Width] = width;
  1013. strins(gui_ItemlistData[playerid][id][gui_list_Title], title, 0);
  1014. gui_ItemlistData[playerid][id][gui_list_Window] = wind;
  1015. gui_ItemlistData[playerid][id][gui_list_Tab] = t;
  1016. gui_ItemlistData[playerid][id][gui_list_RowX] = x-(width/2) + 2.0;
  1017. gui_ItemlistData[playerid][id][gui_list_RowY] = y+9.0;
  1018. gui_ItemlistData[playerid][id][gui_list_RowMax] = 1;
  1019. gui_ItemlistData[playerid][id][gui_list_Type] = GUI_TYPE_ITEMLIST;
  1020. gui_ItemlistData[playerid][id][gui_list_P] = playerid;
  1021. gui_ItemlistData[playerid][id][gui_list_ID] = id+1;
  1022. gui_ItemlistData[playerid][id][gui_list_tdbox] = CreatePlayerTextDraw(playerid, x, y, "_");
  1023. PlayerTextDrawAlignment(playerid, gui_ItemlistData[playerid][id][gui_list_tdbox], 2);
  1024. PlayerTextDrawBackgroundColor(playerid, gui_ItemlistData[playerid][id][gui_list_tdbox], 255);
  1025. PlayerTextDrawFont(playerid, gui_ItemlistData[playerid][id][gui_list_tdbox], 2);
  1026. PlayerTextDrawLetterSize(playerid, gui_ItemlistData[playerid][id][gui_list_tdbox], 0.199998, height);
  1027. PlayerTextDrawColor(playerid, gui_ItemlistData[playerid][id][gui_list_tdbox], -1);
  1028. PlayerTextDrawSetOutline(playerid, gui_ItemlistData[playerid][id][gui_list_tdbox], 0);
  1029. PlayerTextDrawSetProportional(playerid, gui_ItemlistData[playerid][id][gui_list_tdbox], 1);
  1030. PlayerTextDrawSetShadow(playerid, gui_ItemlistData[playerid][id][gui_list_tdbox], 0);
  1031. PlayerTextDrawUseBox(playerid, gui_ItemlistData[playerid][id][gui_list_tdbox], 1);
  1032. PlayerTextDrawBoxColor(playerid, gui_ItemlistData[playerid][id][gui_list_tdbox], 255);
  1033. PlayerTextDrawTextSize(playerid, gui_ItemlistData[playerid][id][gui_list_tdbox], 0.0, width);
  1034. PlayerTextDrawSetPreviewModel(playerid, gui_ItemlistData[playerid][id][gui_list_tdbox], 0);
  1035. gui_ItemlistData[playerid][id][gui_list_tdline] = CreatePlayerTextDraw(playerid, x, y+6.0, "_");
  1036. PlayerTextDrawAlignment(playerid, gui_ItemlistData[playerid][id][gui_list_tdline], 2);
  1037. PlayerTextDrawBackgroundColor(playerid, gui_ItemlistData[playerid][id][gui_list_tdline], 255);
  1038. PlayerTextDrawFont(playerid, gui_ItemlistData[playerid][id][gui_list_tdline], 1);
  1039. PlayerTextDrawLetterSize(playerid, gui_ItemlistData[playerid][id][gui_list_tdline], 0.199998, -0.200004);
  1040. PlayerTextDrawColor(playerid, gui_ItemlistData[playerid][id][gui_list_tdline], -1);
  1041. PlayerTextDrawSetOutline(playerid, gui_ItemlistData[playerid][id][gui_list_tdline], 0);
  1042. PlayerTextDrawSetProportional(playerid, gui_ItemlistData[playerid][id][gui_list_tdline], 1);
  1043. PlayerTextDrawSetShadow(playerid, gui_ItemlistData[playerid][id][gui_list_tdline], 0);
  1044. PlayerTextDrawUseBox(playerid, gui_ItemlistData[playerid][id][gui_list_tdline], 1);
  1045. PlayerTextDrawBoxColor(playerid, gui_ItemlistData[playerid][id][gui_list_tdline], -1);
  1046. PlayerTextDrawTextSize(playerid, gui_ItemlistData[playerid][id][gui_list_tdline], 0.0, width-4.0);
  1047. PlayerTextDrawSetPreviewModel(playerid, gui_ItemlistData[playerid][id][gui_list_tdline], 0);
  1048. gui_ItemlistData[playerid][id][gui_list_tdtitle] = CreatePlayerTextDraw(playerid, x, y-2.0, title);
  1049. PlayerTextDrawAlignment(playerid, gui_ItemlistData[playerid][id][gui_list_tdtitle], 2);
  1050. PlayerTextDrawBackgroundColor(playerid, gui_ItemlistData[playerid][id][gui_list_tdtitle], 255);
  1051. PlayerTextDrawFont(playerid, gui_ItemlistData[playerid][id][gui_list_tdtitle], 2);
  1052. PlayerTextDrawLetterSize(playerid, gui_ItemlistData[playerid][id][gui_list_tdtitle], 0.139998, 0.799995);
  1053. PlayerTextDrawColor(playerid, gui_ItemlistData[playerid][id][gui_list_tdtitle], -1);
  1054. PlayerTextDrawSetOutline(playerid, gui_ItemlistData[playerid][id][gui_list_tdtitle], 0);
  1055. PlayerTextDrawSetProportional(playerid, gui_ItemlistData[playerid][id][gui_list_tdtitle], 1);
  1056. PlayerTextDrawSetShadow(playerid, gui_ItemlistData[playerid][id][gui_list_tdtitle], 0);
  1057. PlayerTextDrawSetPreviewModel(playerid, gui_ItemlistData[playerid][id][gui_list_tdtitle], 0);
  1058. return gui_ItemlistData[playerid][id][gui_list_ID];
  1059. }
  1060. function guiItemListAddRow(playerid, listid, text[])
  1061. {
  1062. if (!(listid > 0)) return !print("ERROR GUI: Item row must be placed under a list id!");
  1063. new id = -1, l = listid;
  1064. for(new c; c < MAX_GUI; c++)
  1065. {
  1066. if (!gui_ItemRowData[playerid][c][gui_row_ID])
  1067. {
  1068. id = c;
  1069. break;
  1070. }
  1071. }
  1072. if (id == -1) return !printf("ERROR GUI: You cannot exceed the GUI item row limit! (%d)", MAX_GUI);
  1073. listid = guiGetID(playerid, GUI_TYPE_ITEMLIST, listid);
  1074. gui_ItemRowData[playerid][id][gui_row_X] = gui_ItemlistData[playerid][listid][gui_list_RowX];
  1075. gui_ItemRowData[playerid][id][gui_row_Y] = gui_ItemlistData[playerid][listid][gui_list_RowY];
  1076. gui_ItemRowData[playerid][id][gui_row_Height] = 8.5;
  1077. gui_ItemRowData[playerid][id][gui_row_Width] = gui_ItemRowData[playerid][id][gui_row_X]+gui_ItemlistData[playerid][listid][gui_list_Width] - 4.0;
  1078. strins(gui_ItemRowData[playerid][id][gui_row_Text], text, 0);
  1079. gui_ItemRowData[playerid][id][gui_row_List] = l;
  1080. gui_ItemRowData[playerid][id][gui_row_Order] = gui_ItemlistData[playerid][listid][gui_list_RowMax];
  1081. gui_ItemRowData[playerid][id][gui_row_ID] = id+1;
  1082. gui_ItemlistData[playerid][listid][gui_list_RowY] += 9.5;
  1083. gui_ItemlistData[playerid][listid][gui_list_RowMax]++;
  1084. //printf("ADD: %d %s %.2f", playerid, text, gui_ItemRowData[playerid][id][gui_row_Y]);
  1085. gui_ItemRowData[playerid][id][gui_row_td] = CreatePlayerTextDraw(playerid, gui_ItemRowData[playerid][id][gui_row_X], gui_ItemRowData[playerid][id][gui_row_Y], text);
  1086. PlayerTextDrawBackgroundColor(playerid, gui_ItemRowData[playerid][id][gui_row_td], 55);
  1087. PlayerTextDrawFont(playerid, gui_ItemRowData[playerid][id][gui_row_td], 1);
  1088. PlayerTextDrawLetterSize(playerid, gui_ItemRowData[playerid][id][gui_row_td], 0.175000, gui_ItemRowData[playerid][id][gui_row_Height]*UNIT);
  1089. PlayerTextDrawColor(playerid, gui_ItemRowData[playerid][id][gui_row_td], -1);
  1090. PlayerTextDrawSetOutline(playerid, gui_ItemRowData[playerid][id][gui_row_td], 1);
  1091. PlayerTextDrawSetProportional(playerid, gui_ItemRowData[playerid][id][gui_row_td], 1);
  1092. PlayerTextDrawUseBox(playerid, gui_ItemRowData[playerid][id][gui_row_td], 1);
  1093. PlayerTextDrawBoxColor(playerid, gui_ItemRowData[playerid][id][gui_row_td], 0x00000000);
  1094. PlayerTextDrawTextSize(playerid, gui_ItemRowData[playerid][id][gui_row_td], gui_ItemRowData[playerid][id][gui_row_Width], gui_ItemRowData[playerid][id][gui_row_Height]);
  1095. PlayerTextDrawSetSelectable(playerid, gui_ItemRowData[playerid][id][gui_row_td], 1);
  1096. gui_ItemRowData[playerid][id][gui_row_td2] = CreatePlayerTextDraw(playerid, gui_ItemRowData[playerid][id][gui_row_X], gui_ItemRowData[playerid][id][gui_row_Y], text);
  1097. PlayerTextDrawBackgroundColor(playerid, gui_ItemRowData[playerid][id][gui_row_td2], 55);
  1098. PlayerTextDrawFont(playerid, gui_ItemRowData[playerid][id][gui_row_td2], 1);
  1099. PlayerTextDrawLetterSize(playerid, gui_ItemRowData[playerid][id][gui_row_td2], 0.175000, gui_ItemRowData[playerid][id][gui_row_Height]*UNIT);
  1100. PlayerTextDrawColor(playerid, gui_ItemRowData[playerid][id][gui_row_td2], -1);
  1101. PlayerTextDrawSetOutline(playerid, gui_ItemRowData[playerid][id][gui_row_td2], 1);
  1102. PlayerTextDrawSetProportional(playerid, gui_ItemRowData[playerid][id][gui_row_td2], 1);
  1103. PlayerTextDrawUseBox(playerid, gui_ItemRowData[playerid][id][gui_row_td2], 1);
  1104. PlayerTextDrawBoxColor(playerid, gui_ItemRowData[playerid][id][gui_row_td2], 0xFF000033);
  1105. PlayerTextDrawTextSize(playerid, gui_ItemRowData[playerid][id][gui_row_td2], gui_ItemRowData[playerid][id][gui_row_Width], gui_ItemRowData[playerid][id][gui_row_Height]);
  1106. return gui_ItemRowData[playerid][id][gui_row_ID];
  1107. }
  1108. function guiItemListRemoveRow(playerid, listid, rowid)
  1109. {
  1110. if (!(listid > 0)) return !print("ERROR GUI: Itemlist ID required to remove row!");
  1111. if (!(rowid > 0)) return !print("ERROR GUI: Row ID required to remove row!");
  1112. new l = listid;
  1113. listid = guiGetID(playerid, GUI_TYPE_ITEMLIST, listid);
  1114. new id = -1;
  1115. for(new r; r <= gui_ItemlistData[playerid][listid][gui_list_RowMax]; r++)
  1116. {
  1117. //printf("ROW: %d ID: %d", r, gui_ItemRowData[playerid][r][gui_row_ID]);
  1118. if (gui_ItemRowData[playerid][r][gui_row_ID] == rowid)
  1119. {
  1120. rowid = r;
  1121. id = 1;
  1122. break;
  1123. }
  1124. }
  1125. if (id == -1) return !printf("ERROR GUI: Invalid row ID. (%d)",rowid);
  1126. for(new r; r <= gui_ItemlistData[playerid][listid][gui_list_RowMax]; r++)
  1127. {
  1128. if (!gui_ItemRowData[playerid][r][gui_row_ID]) continue;
  1129. if (gui_ItemRowData[playerid][r][gui_row_List] != l) continue;
  1130. if (gui_ItemRowData[playerid][r][gui_row_Order] > gui_ItemRowData[playerid][rowid][gui_row_Order])
  1131. {
  1132. gui_ItemRowData[playerid][r][gui_row_Y] -= 9.5;
  1133. gui_ItemRowData[playerid][r][gui_row_Order]--;
  1134. PlayerTextDrawDestroy(playerid, gui_ItemRowData[playerid][r][gui_row_td]);
  1135. gui_ItemRowData[playerid][r][gui_row_td] = CreatePlayerTextDraw(playerid, gui_ItemRowData[playerid][r][gui_row_X], gui_ItemRowData[playerid][r][gui_row_Y], gui_ItemRowData[playerid][r][gui_row_Text]);
  1136. PlayerTextDrawBackgroundColor(playerid, gui_ItemRowData[playerid][r][gui_row_td], 55);
  1137. PlayerTextDrawFont(playerid, gui_ItemRowData[playerid][r][gui_row_td], 1);
  1138. PlayerTextDrawLetterSize(playerid, gui_ItemRowData[playerid][r][gui_row_td], 0.175000, gui_ItemRowData[playerid][r][gui_row_Height]*UNIT);
  1139. PlayerTextDrawColor(playerid, gui_ItemRowData[playerid][r][gui_row_td], -1);
  1140. PlayerTextDrawSetOutline(playerid, gui_ItemRowData[playerid][r][gui_row_td], 1);
  1141. PlayerTextDrawSetProportional(playerid, gui_ItemRowData[playerid][r][gui_row_td], 1);
  1142. PlayerTextDrawUseBox(playerid, gui_ItemRowData[playerid][r][gui_row_td], 1);
  1143. PlayerTextDrawBoxColor(playerid, gui_ItemRowData[playerid][r][gui_row_td], 0x00000000);
  1144. PlayerTextDrawTextSize(playerid, gui_ItemRowData[playerid][r][gui_row_td], gui_ItemRowData[playerid][r][gui_row_Width], gui_ItemRowData[playerid][r][gui_row_Height]);
  1145. PlayerTextDrawSetSelectable(playerid, gui_ItemRowData[playerid][r][gui_row_td], 1);
  1146. PlayerTextDrawDestroy(playerid, gui_ItemRowData[playerid][r][gui_row_td2]);
  1147. gui_ItemRowData[playerid][r][gui_row_td2] = CreatePlayerTextDraw(playerid, gui_ItemRowData[playerid][r][gui_row_X], gui_ItemRowData[playerid][r][gui_row_Y], gui_ItemRowData[playerid][r][gui_row_Text]);
  1148. PlayerTextDrawBackgroundColor(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 55);
  1149. PlayerTextDrawFont(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 1);
  1150. PlayerTextDrawLetterSize(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 0.175000, gui_ItemRowData[playerid][r][gui_row_Height]*UNIT);
  1151. PlayerTextDrawColor(playerid, gui_ItemRowData[playerid][r][gui_row_td2], -1);
  1152. PlayerTextDrawSetOutline(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 1);
  1153. PlayerTextDrawSetProportional(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 1);
  1154. PlayerTextDrawUseBox(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 1);
  1155. PlayerTextDrawBoxColor(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 0xFF000033);
  1156. PlayerTextDrawTextSize(playerid, gui_ItemRowData[playerid][r][gui_row_td2], gui_ItemRowData[playerid][r][gui_row_Width], gui_ItemRowData[playerid][r][gui_row_Height]);
  1157. }
  1158. }
  1159. if (id)
  1160. {
  1161. if (GetTextDrawVisibilityForPlayer(playerid, gui_ItemRowData[playerid][rowid][gui_row_td]))
  1162. {
  1163. for(new r; r <= gui_ItemlistData[playerid][listid][gui_list_RowMax]; r++)
  1164. {
  1165. if (!gui_ItemRowData[playerid][r][gui_row_ID]) continue;
  1166. if (gui_ItemRowData[playerid][r][gui_row_List] != l) continue;
  1167. if (gui_ItemRowData[playerid][r][gui_row_Order] >= gui_ItemRowData[playerid][rowid][gui_row_Order])
  1168. PlayerTextDrawShow(playerid, gui_ItemRowData[playerid][r][gui_row_td]);
  1169. }
  1170. }
  1171. TextDrawDestroyEx(playerid, gui_ItemRowData[playerid][rowid][gui_row_td]);
  1172. TextDrawDestroyEx(playerid, gui_ItemRowData[playerid][rowid][gui_row_td2]);
  1173. strdel(gui_ItemRowData[playerid][rowid][gui_row_Text], 0, strlen(gui_ItemRowData[playerid][rowid][gui_row_Text]));
  1174. gui_ItemRowData[playerid][rowid][gui_row_ID] = 0;
  1175. gui_ItemRowData[playerid][rowid][gui_row_X] = 0.0;
  1176. gui_ItemRowData[playerid][rowid][gui_row_Y] = 0.0;
  1177. gui_ItemRowData[playerid][rowid][gui_row_Height] = 0.0;
  1178. gui_ItemRowData[playerid][rowid][gui_row_Width] = 0.0;
  1179. gui_ItemRowData[playerid][rowid][gui_row_List] = 0;
  1180. gui_ItemRowData[playerid][rowid][gui_row_Order] = 0;
  1181. gui_ItemlistData[playerid][listid][gui_list_RowY] -= 9.5;
  1182. gui_ItemlistData[playerid][listid][gui_list_RowMax]--;
  1183. return 1;
  1184. }
  1185. return 0;
  1186. }
  1187. function guiItemListSetRowOrder(playerid, listid, rowid, orderid)
  1188. {
  1189. if (!(listid > 0)) return !print("ERROR GUI: Itemlist ID required to remove row!");
  1190. if (!(rowid > 0)) return !print("ERROR GUI: Row ID required to remove row!");
  1191. new id = -1, l = listid;
  1192. listid = guiGetID(playerid, GUI_TYPE_ITEMLIST, listid);
  1193. if (listid == -1) return !print("ERROR GUI: Invalid list ID.");
  1194. for(new r; r <= gui_ItemlistData[playerid][listid][gui_list_RowMax]; r++)
  1195. {
  1196. if (gui_ItemRowData[playerid][r][gui_row_ID] == rowid)
  1197. {
  1198. rowid = r;
  1199. id = 1;
  1200. break;
  1201. }
  1202. }
  1203. if (id == -1) return !print("ERROR GUI: Invalid row ID.");
  1204. if (orderid == gui_ItemRowData[playerid][rowid][gui_row_Order]) return 0;
  1205. new current = gui_ItemRowData[playerid][rowid][gui_row_Order];
  1206. for(new r; r <= gui_ItemlistData[playerid][listid][gui_list_RowMax]; r++)
  1207. {
  1208. if (!gui_ItemRowData[playerid][r][gui_row_ID]) continue;
  1209. if (gui_ItemRowData[playerid][r][gui_row_List] != l) continue;
  1210. new oldid;
  1211. oldid = gui_ItemRowData[playerid][r][gui_row_Order];
  1212. if (gui_ItemRowData[playerid][r][gui_row_Order] == orderid && orderid > current) gui_ItemRowData[playerid][r][gui_row_Order]--;
  1213. else if (gui_ItemRowData[playerid][r][gui_row_Order] == orderid && orderid < current) gui_ItemRowData[playerid][r][gui_row_Order]++;
  1214. else if (gui_ItemRowData[playerid][r][gui_row_Order] >= orderid && orderid < current && gui_ItemRowData[playerid][r][gui_row_Order] < current) gui_ItemRowData[playerid][r][gui_row_Order]++;
  1215. else if (gui_ItemRowData[playerid][r][gui_row_Order] <= orderid && orderid > current && gui_ItemRowData[playerid][r][gui_row_Order] > current) gui_ItemRowData[playerid][r][gui_row_Order]--;
  1216. else if (gui_ItemRowData[playerid][r][gui_row_Order] <= orderid && orderid == current && gui_ItemRowData[playerid][r][gui_row_Order] > current) gui_ItemRowData[playerid][r][gui_row_Order]--;
  1217. new Float:y = 9.0*gui_ItemRowData[playerid][r][gui_row_Order];
  1218. gui_ItemRowData[playerid][r][gui_row_Y] = (gui_ItemRowData[playerid][r][gui_row_Y]-(9.0*oldid))+y;
  1219. PlayerTextDrawDestroy(playerid, gui_ItemRowData[playerid][r][gui_row_td]);
  1220. gui_ItemRowData[playerid][r][gui_row_td] = CreatePlayerTextDraw(playerid, gui_ItemRowData[playerid][r][gui_row_X], gui_ItemRowData[playerid][r][gui_row_Y], gui_ItemRowData[playerid][r][gui_row_Text]);
  1221. PlayerTextDrawBackgroundColor(playerid, gui_ItemRowData[playerid][r][gui_row_td], 55);
  1222. PlayerTextDrawFont(playerid, gui_ItemRowData[playerid][r][gui_row_td], 1);
  1223. PlayerTextDrawLetterSize(playerid, gui_ItemRowData[playerid][r][gui_row_td], 0.150000, gui_ItemRowData[playerid][r][gui_row_Height]*UNIT);
  1224. PlayerTextDrawColor(playerid, gui_ItemRowData[playerid][r][gui_row_td], -1);
  1225. PlayerTextDrawSetOutline(playerid, gui_ItemRowData[playerid][r][gui_row_td], 1);
  1226. PlayerTextDrawSetProportional(playerid, gui_ItemRowData[playerid][r][gui_row_td], 1);
  1227. PlayerTextDrawUseBox(playerid, gui_ItemRowData[playerid][r][gui_row_td], 1);
  1228. PlayerTextDrawBoxColor(playerid, gui_ItemRowData[playerid][r][gui_row_td], 0x00000000);
  1229. PlayerTextDrawTextSize(playerid, gui_ItemRowData[playerid][r][gui_row_td], gui_ItemRowData[playerid][r][gui_row_Width], gui_ItemRowData[playerid][r][gui_row_Height]);
  1230. PlayerTextDrawSetSelectable(playerid, gui_ItemRowData[playerid][r][gui_row_td], 1);
  1231. PlayerTextDrawDestroy(playerid, gui_ItemRowData[playerid][r][gui_row_td2]);
  1232. gui_ItemRowData[playerid][r][gui_row_td2] = CreatePlayerTextDraw(playerid, gui_ItemRowData[playerid][r][gui_row_X], gui_ItemRowData[playerid][r][gui_row_Y], gui_ItemRowData[playerid][r][gui_row_Text]);
  1233. PlayerTextDrawBackgroundColor(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 55);
  1234. PlayerTextDrawFont(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 1);
  1235. PlayerTextDrawLetterSize(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 0.150000, gui_ItemRowData[playerid][r][gui_row_Height]*UNIT);
  1236. PlayerTextDrawColor(playerid, gui_ItemRowData[playerid][r][gui_row_td2], -1);
  1237. PlayerTextDrawSetOutline(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 1);
  1238. PlayerTextDrawSetProportional(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 1);
  1239. PlayerTextDrawUseBox(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 1);
  1240. PlayerTextDrawBoxColor(playerid, gui_ItemRowData[playerid][r][gui_row_td2], 0xFF000033);
  1241. PlayerTextDrawTextSize(playerid, gui_ItemRowData[playerid][r][gui_row_td2], gui_ItemRowData[playerid][r][gui_row_Width], gui_ItemRowData[playerid][r][gui_row_Height]);
  1242. }
  1243. if (id)
  1244. {
  1245. gui_ItemRowData[playerid][rowid][gui_row_Y] = (gui_ItemRowData[playerid][rowid][gui_row_Y]-(9.0*gui_ItemRowData[playerid][rowid][gui_row_Order]))+(9.0*orderid);
  1246. PlayerTextDrawDestroy(playerid, gui_ItemRowData[playerid][rowid][gui_row_td]);
  1247. gui_ItemRowData[playerid][rowid][gui_row_td] = CreatePlayerTextDraw(playerid, gui_ItemRowData[playerid][rowid][gui_row_X], gui_ItemRowData[playerid][rowid][gui_row_Y], gui_ItemRowData[playerid][rowid][gui_row_Text]);
  1248. PlayerTextDrawBackgroundColor(playerid, gui_ItemRowData[playerid][rowid][gui_row_td], 55);
  1249. PlayerTextDrawFont(playerid, gui_ItemRowData[playerid][rowid][gui_row_td], 1);
  1250. PlayerTextDrawLetterSize(playerid, gui_ItemRowData[playerid][rowid][gui_row_td], 0.150000, gui_ItemRowData[playerid][rowid][gui_row_Height]*UNIT);
  1251. PlayerTextDrawColor(playerid, gui_ItemRowData[playerid][rowid][gui_row_td], -1);
  1252. PlayerTextDrawSetOutline(playerid, gui_ItemRowData[playerid][rowid][gui_row_td], 1);
  1253. PlayerTextDrawSetProportional(playerid, gui_ItemRowData[playerid][rowid][gui_row_td], 1);
  1254. PlayerTextDrawUseBox(playerid, gui_ItemRowData[playerid][rowid][gui_row_td], 1);
  1255. PlayerTextDrawBoxColor(playerid, gui_ItemRowData[playerid][rowid][gui_row_td], 0x00000000);
  1256. PlayerTextDrawTextSize(playerid, gui_ItemRowData[playerid][rowid][gui_row_td], gui_ItemRowData[playerid][rowid][gui_row_Width], gui_ItemRowData[playerid][rowid][gui_row_Height]);
  1257. PlayerTextDrawSetSelectable(playerid, gui_ItemRowData[playerid][rowid][gui_row_td], 1);
  1258. PlayerTextDrawDestroy(playerid, gui_ItemRowData[playerid][rowid][gui_row_td2]);
  1259. gui_ItemRowData[playerid][rowid][gui_row_td2] = CreatePlayerTextDraw(playerid, gui_ItemRowData[playerid][rowid][gui_row_X], gui_ItemRowData[playerid][rowid][gui_row_Y], gui_ItemRowData[playerid][rowid][gui_row_Text]);
  1260. PlayerTextDrawBackgroundColor(playerid, gui_ItemRowData[playerid][rowid][gui_row_td2], 55);
  1261. PlayerTextDrawFont(playerid, gui_ItemRowData[playerid][rowid][gui_row_td2], 1);
  1262. PlayerTextDrawLetterSize(playerid, gui_ItemRowData[playerid][rowid][gui_row_td2], 0.150000, gui_ItemRowData[playerid][rowid][gui_row_Height]*UNIT);
  1263. PlayerTextDrawColor(playerid, gui_ItemRowData[playerid][rowid][gui_row_td2], -1);
  1264. PlayerTextDrawSetOutline(playerid, gui_ItemRowData[playerid][rowid][gui_row_td2], 1);
  1265. PlayerTextDrawSetProportional(playerid, gui_ItemRowData[playerid][rowid][gui_row_td2], 1);
  1266. PlayerTextDrawUseBox(playerid, gui_ItemRowData[playerid][rowid][gui_row_td2], 1);
  1267. PlayerTextDrawBoxColor(playerid, gui_ItemRowData[playerid][rowid][gui_row_td2], 0xFF000033);
  1268. PlayerTextDrawTextSize(playerid, gui_ItemRowData[playerid][rowid][gui_row_td2], gui_ItemRowData[playerid][rowid][gui_row_Width], gui_ItemRowData[playerid][rowid][gui_row_Height]);
  1269. if (GetTextDrawVisibilityForPlayer(playerid, gui_ItemRowData[playerid][rowid][gui_row_td]) || GetTextDrawVisibilityForPlayer(playerid, gui_ItemRowData[playerid][rowid][gui_row_td2]))
  1270. {
  1271. PlayerTextDrawShow(playerid, gui_ItemRowData[playerid][rowid][gui_row_td]);
  1272. for(new r; r <= gui_ItemlistData[playerid][listid][gui_list_RowMax]; r++)
  1273. {
  1274. if (!gui_ItemRowData[playerid][r][gui_row_ID]) continue;
  1275. if (gui_ItemRowData[playerid][r][gui_row_List] != l) continue;
  1276. if (p_row[playerid] == r) PlayerTextDrawShow(playerid, gui_ItemRowData[playerid][r][gui_row_td2]);
  1277. else PlayerTextDrawShow(playerid, gui_ItemRowData[playerid][r][gui_row_td]);
  1278. }
  1279. }
  1280. gui_ItemRowData[playerid][rowid][gui_row_Order] = orderid;
  1281. return 1;
  1282. }
  1283. return 0;
  1284. }
  1285. function guiItemListGetSelectedRow(playerid)
  1286. {
  1287. return gui_ItemRowData[playerid][p_row[playerid]][gui_row_ID];
  1288. }
  1289. function guiItemListGetRowText(playerid, listid, rowid, string[])
  1290. {
  1291. if (rowid >= MAX_GUI || listid >= MAX_GUI) return 0;
  1292. new r;
  1293. for(new g; g < MAX_GUI; g++)
  1294. {
  1295. if (gui_ItemRowData[playerid][g][gui_row_ID] == rowid && gui_ItemRowData[playerid][g][gui_row_List] == listid)
  1296. {
  1297. rowid = g;
  1298. r = 1;
  1299. break;
  1300. }
  1301. }
  1302. if (!r) return 0;
  1303. if (!gui_ItemRowData[playerid][rowid][gui_row_ID]) return 0;
  1304. strins(string, gui_ItemRowData[playerid][rowid][gui_row_Text], 0, strlen(gui_ItemRowData[playerid][rowid][gui_row_Text]));
  1305. return 1;
  1306. }
  1307. function guiItemListGetCount(playerid, listid)
  1308. {
  1309. if (listid >= MAX_GUI) return 0;
  1310. new r;
  1311. for(new g; g < MAX_GUI; g++)
  1312. {
  1313. if (gui_ItemlistData[playerid][g][gui_list_ID] == listid)
  1314. {
  1315. listid = g;
  1316. r = 1;
  1317. break;
  1318. }
  1319. }
  1320. if (!r) return 0;
  1321. if (!gui_ItemlistData[playerid][listid][gui_list_ID]) return 0;
  1322. return gui_ItemlistData[playerid][listid][gui_list_RowMax];
  1323. }
  1324. function guiItemListGetRowList(playerid, rowid)
  1325. {
  1326. if (rowid >= MAX_GUI) return 0;
  1327. for(new g; g < MAX_GUI; g++)
  1328. {
  1329. if (gui_ItemRowData[playerid][g][gui_row_ID] == rowid)
  1330. {
  1331. return gui_ItemRowData[playerid][g][gui_row_List];
  1332. }
  1333. }
  1334. return 0;
  1335. }
  1336. function guiCreateCheckBox(playerid, windowid, tabid, Float:x, Float:y)
  1337. {
  1338. new id = -1, wind = windowid, t = tabid;
  1339. for(new c; c < MAX_GUI; c++)
  1340. {
  1341. if (!gui_CheckboxData[playerid][c][gui_check_ID])
  1342. {
  1343. id = c;
  1344. break;
  1345. }
  1346. }
  1347. if (id == -1) return !printf("ERROR GUI: You cannot exceed the GUI checkbox limit! (%d)", MAX_GUI);
  1348. if (windowid > 0) // If you set the tab under a GUI Window ...
  1349. {
  1350. windowid = guiGetID(playerid, GUI_TYPE_WINDOW, windowid);
  1351. if (tabid > 0)
  1352. {
  1353. tabid = guiGetID(playerid, GUI_TYPE_TAB, tabid);
  1354. x += (gui_TabData[playerid][tabid][gui_tab_panelX] - (gui_TabData[playerid][tabid][gui_tab_Width]/2) + 4.0);
  1355. y += (gui_TabData[playerid][tabid][gui_tab_panelY] +2.0);
  1356. }
  1357. else
  1358. {
  1359. x += gui_WindowData[playerid][windowid][gui_win_X];
  1360. y += (gui_WindowData[playerid][windowid][gui_win_Y]+10.5);
  1361. }
  1362. }
  1363. gui_CheckboxData[playerid][id][gui_check_X] = x;
  1364. gui_CheckboxData[playerid][id][gui_check_Y] = y;
  1365. gui_CheckboxData[playerid][id][gui_check_Window] = wind;
  1366. gui_CheckboxData[playerid][id][gui_check_Tab] = t;
  1367. gui_CheckboxData[playerid][id][gui_check_Type] = GUI_TYPE_CHECKBOX;
  1368. gui_CheckboxData[playerid][id][gui_check_P] = playerid;
  1369. gui_CheckboxData[playerid][id][gui_check_ID] = id+1;
  1370. gui_CheckboxData[playerid][id][gui_check_td] = CreatePlayerTextDraw(playerid, x, y, "O");
  1371. PlayerTextDrawBackgroundColor(playerid, gui_CheckboxData[playerid][id][gui_check_td], 0xFFFFFFFF);
  1372. PlayerTextDrawFont(playerid, gui_CheckboxData[playerid][id][gui_check_td], 1);
  1373. PlayerTextDrawLetterSize(playerid, gui_CheckboxData[playerid][id][gui_check_td], 0.179998, 0.800000);
  1374. PlayerTextDrawColor(playerid, gui_CheckboxData[playerid][id][gui_check_td], 0xFFFFFFFF);
  1375. PlayerTextDrawSetOutline(playerid, gui_CheckboxData[playerid][id][gui_check_td], 1);
  1376. PlayerTextDrawSetProportional(playerid, gui_CheckboxData[playerid][id][gui_check_td], 1);
  1377. PlayerTextDrawTextSize(playerid, gui_CheckboxData[playerid][id][gui_check_td], x+8.0, 10.0);
  1378. PlayerTextDrawSetSelectable(playerid, gui_CheckboxData[playerid][id][gui_check_td], 1);
  1379. //printf("%f %f", x, y);
  1380. gui_CheckboxData[playerid][id][gui_check_td2] = CreatePlayerTextDraw(playerid, x, y, "O");
  1381. PlayerTextDrawBackgroundColor(playerid, gui_CheckboxData[playerid][id][gui_check_td2], 0xFFFFFFFF);
  1382. PlayerTextDrawFont(playerid, gui_CheckboxData[playerid][id][gui_check_td2], 1);
  1383. PlayerTextDrawLetterSize(playerid, gui_CheckboxData[playerid][id][gui_check_td2], 0.179998, 0.800000);
  1384. PlayerTextDrawColor(playerid, gui_CheckboxData[playerid][id][gui_check_td2], 0x00000000);
  1385. PlayerTextDrawSetOutline(playerid, gui_CheckboxData[playerid][id][gui_check_td2], 1);
  1386. PlayerTextDrawSetProportional(playerid, gui_CheckboxData[playerid][id][gui_check_td2], 1);
  1387. PlayerTextDrawTextSize(playerid, gui_CheckboxData[playerid][id][gui_check_td2], x+8.0, 10.0);
  1388. PlayerTextDrawSetSelectable(playerid, gui_CheckboxData[playerid][id][gui_check_td2], 1);
  1389. return gui_CheckboxData[playerid][id][gui_check_ID];
  1390. }
  1391. function guiCheckBoxGetSelected(playerid, checkboxid)
  1392. {
  1393. if (checkboxid >= MAX_GUI) return -1;
  1394. new r;
  1395. for(new g; g < MAX_GUI; g++)
  1396. {
  1397. if (gui_CheckboxData[playerid][g][gui_check_ID] == checkboxid)
  1398. {
  1399. checkboxid = g;
  1400. r = 1;
  1401. break;
  1402. }
  1403. }
  1404. if (!r) return -1;
  1405. if (!gui_CheckboxData[playerid][checkboxid][gui_check_ID]) return -1;
  1406. return GetTextDrawVisibilityForPlayer(playerid, gui_CheckboxData[playerid][checkboxid][gui_check_td2]);
  1407. }
  1408. function guiCheckBoxSetSelected(playerid, checkboxid)
  1409. {
  1410. if (checkboxid >= MAX_GUI) return 0;
  1411. new r;
  1412. for(new g; g < MAX_GUI; g++)
  1413. {
  1414. if (gui_CheckboxData[playerid][g][gui_check_ID] == checkboxid)
  1415. {
  1416. checkboxid = g;
  1417. r = 1;
  1418. break;
  1419. }
  1420. }
  1421. if (!r) return 0;
  1422. if (!gui_CheckboxData[playerid][checkboxid][gui_check_ID]) return 0;
  1423. PlayerTextDrawHide(playerid, gui_CheckboxData[playerid][checkboxid][gui_check_td]);
  1424. PlayerTextDrawShow(playerid, gui_CheckboxData[playerid][checkboxid][gui_check_td2]);
  1425. return 1;
  1426. }
  1427. function guiGetCheckBoxPos(playerid, checkboxid, &Float:x, &Float:y)
  1428. {
  1429. if (checkboxid >= MAX_GUI) return 0;
  1430. new r;
  1431. for(new g; g < MAX_GUI; g++)
  1432. {
  1433. if (gui_CheckboxData[playerid][g][gui_check_ID] == checkboxid)
  1434. {
  1435. checkboxid = g;
  1436. r = 1;
  1437. break;
  1438. }
  1439. }
  1440. if (!r) return 0;
  1441. if (!gui_CheckboxData[playerid][checkboxid][gui_check_ID]) return 0;
  1442. x = gui_CheckboxData[playerid][checkboxid][gui_check_X];
  1443. y = gui_CheckboxData[playerid][checkboxid][gui_check_Y];
  1444. return 1;
  1445. }
  1446. function guiCreateButton(playerid, windowid, tabid, Float:x, Float:y, Float:height, Float:width, text[])
  1447. {
  1448. new id = -1, wind = windowid, t = tabid;
  1449. for(new c; c < MAX_GUI; c++)
  1450. {
  1451. if (!gui_ButtonData[playerid][c][gui_but_ID])
  1452. {
  1453. id = c;
  1454. break;
  1455. }
  1456. }
  1457. if (id == -1) return !printf("ERROR GUI: You cannot exceed the GUI button limit! (%d)", MAX_GUI);
  1458. if (windowid > 0) // If you set the label under a GUI Window ...
  1459. {
  1460. windowid = guiGetID(playerid, GUI_TYPE_WINDOW, windowid);
  1461. if (tabid > 0) // if it's under a tab panel
  1462. {
  1463. tabid = guiGetID(playerid, GUI_TYPE_TAB, tabid);
  1464. x += (gui_TabData[playerid][tabid][gui_tab_panelX]-(gui_TabData[playerid][tabid][gui_tab_Width]/2))+10.0;
  1465. y += (gui_TabData[playerid][tabid][gui_tab_panelY]-(gui_TabData[playerid][tabid][gui_tab_Height]/2))+6.0; // relative positioning
  1466. }
  1467. else // only under a window gui
  1468. {
  1469. x += (gui_WindowData[playerid][windowid][gui_win_X]-(gui_WindowData[playerid][windowid][gui_win_SizeX]/2));
  1470. y += (gui_WindowData[playerid][windowid][gui_win_Y]+7.0); // relative positioning
  1471. }
  1472. }
  1473. new Float:len = strlen(text)*4.0;
  1474. if (width == 0.0) width = len+16.0;
  1475. if (height == 0.0) height = 20.0;
  1476. x += (width/2)-8.0;
  1477. gui_ButtonData[playerid][id][gui_but_X] = x;
  1478. gui_ButtonData[playerid][id][gui_but_Y] = y;
  1479. gui_ButtonData[playerid][id][gui_but_Height] = height;
  1480. gui_ButtonData[playerid][id][gui_but_Width] = width;
  1481. gui_ButtonData[playerid][id][gui_but_Window] = wind;
  1482. gui_ButtonData[playerid][id][gui_but_Tab] = t;
  1483. strins(gui_ButtonData[playerid][id][gui_but_Text], text, 0);
  1484. gui_ButtonData[playerid][id][gui_but_Type] = GUI_TYPE_BUTTON;
  1485. gui_ButtonData[playerid][id][gui_but_P] = playerid;
  1486. gui_ButtonData[playerid][id][gui_but_ID] = id+1;
  1487. gui_ButtonData[playerid][id][gui_but_tdbg] = CreatePlayerTextDraw(playerid, x, y, "_");
  1488. PlayerTextDrawAlignment(playerid, gui_ButtonData[playerid][id][gui_but_tdbg], 2);
  1489. PlayerTextDrawBackgroundColor(playerid, gui_ButtonData[playerid][id][gui_but_tdbg], 255);
  1490. PlayerTextDrawFont(playerid, gui_ButtonData[playerid][id][gui_but_tdbg], 1);
  1491. PlayerTextDrawLetterSize(playerid, gui_ButtonData[playerid][id][gui_but_tdbg], 0.179998, (height*UNIT));
  1492. PlayerTextDrawColor(playerid, gui_ButtonData[playerid][id][gui_but_tdbg], -1);
  1493. PlayerTextDrawSetOutline(playerid, gui_ButtonData[playerid][id][gui_but_tdbg], 1);
  1494. PlayerTextDrawSetProportional(playerid, gui_ButtonData[playerid][id][gui_but_tdbg], 1);
  1495. PlayerTextDrawUseBox(playerid, gui_ButtonData[playerid][id][gui_but_tdbg], 1);
  1496. PlayerTextDrawBoxColor(playerid, gui_ButtonData[playerid][id][gui_but_tdbg], 255);
  1497. PlayerTextDrawTextSize(playerid, gui_ButtonData[playerid][id][gui_but_tdbg], height, width);
  1498. PlayerTextDrawSetSelectable(playerid, gui_ButtonData[playerid][id][gui_but_tdbg], 1);
  1499. gui_ButtonData[playerid][id][gui_but_tdout] = CreatePlayerTextDraw(playerid, x, y+1.0, "_");
  1500. PlayerTextDrawAlignment(playerid, gui_ButtonData[playerid][id][gui_but_tdout], 2);
  1501. PlayerTextDrawBackgroundColor(playerid, gui_ButtonData[playerid][id][gui_but_tdout], 255);
  1502. PlayerTextDrawFont(playerid, gui_ButtonData[playerid][id][gui_but_tdout], 1);
  1503. PlayerTextDrawLetterSize(playerid, gui_ButtonData[playerid][id][gui_but_tdout], 0.159998, (height*UNIT)-0.25);
  1504. //PlayerTextDrawLetterSize(playerid, gui_ButtonData[playerid][id][gui_but_tdout], 0.159998, ((height-2.0)*UNIT));
  1505. PlayerTextDrawColor(playerid, gui_ButtonData[playerid][id][gui_but_tdout], -1);
  1506. PlayerTextDrawSetOutline(playerid, gui_ButtonData[playerid][id][gui_but_tdout], 1);
  1507. PlayerTextDrawSetProportional(playerid, gui_ButtonData[playerid][id][gui_but_tdout], 1);
  1508. PlayerTextDrawUseBox(playerid, gui_ButtonData[playerid][id][gui_but_tdout], 1);
  1509. PlayerTextDrawBoxColor(playerid, gui_ButtonData[playerid][id][gui_but_tdout], -892679629);
  1510. PlayerTextDrawTextSize(playerid, gui_ButtonData[playerid][id][gui_but_tdout], height, width-2.0);
  1511. gui_ButtonData[playerid][id][gui_but_tdbox] = CreatePlayerTextDraw(playerid, x, y+2.0, "_");
  1512. PlayerTextDrawAlignment(playerid, gui_ButtonData[playerid][id][gui_but_tdbox], 2);
  1513. PlayerTextDrawBackgroundColor(playerid, gui_ButtonData[playerid][id][gui_but_tdbox], 255);
  1514. PlayerTextDrawFont(playerid, gui_ButtonData[playerid][id][gui_but_tdbox], 1);
  1515. PlayerTextDrawLetterSize(playerid, gui_ButtonData[playerid][id][gui_but_tdbox], 0.159998, (height*UNIT)-0.4741);
  1516. //PlayerTextDrawLetterSize(playerid, gui_ButtonData[playerid][id][gui_but_tdbox], 0.159998, ((height-4.0)*UNIT));
  1517. PlayerTextDrawColor(playerid, gui_ButtonData[playerid][id][gui_but_tdbox], -1);
  1518. PlayerTextDrawSetOutline(playerid, gui_ButtonData[playerid][id][gui_but_tdbox], 1);
  1519. PlayerTextDrawSetProportional(playerid, gui_ButtonData[playerid][id][gui_but_tdbox], 1);
  1520. PlayerTextDrawUseBox(playerid, gui_ButtonData[playerid][id][gui_but_tdbox], 1);
  1521. PlayerTextDrawBoxColor(playerid, gui_ButtonData[playerid][id][gui_but_tdbox], 222);
  1522. PlayerTextDrawTextSize(playerid, gui_ButtonData[playerid][id][gui_but_tdbox], height, width-4.0);
  1523. gui_ButtonData[playerid][id][gui_but_tdtxt] = CreatePlayerTextDraw(playerid, x, y+(height/2)-((0.8/UNIT)/2), text);
  1524. PlayerTextDrawAlignment(playerid, gui_ButtonData[playerid][id][gui_but_tdtxt], 2);
  1525. PlayerTextDrawBackgroundColor(playerid, gui_ButtonData[playerid][id][gui_but_tdtxt], 255);
  1526. PlayerTextDrawFont(playerid, gui_ButtonData[playerid][id][gui_but_tdtxt], 2);
  1527. PlayerTextDrawLetterSize(playerid, gui_ButtonData[playerid][id][gui_but_tdtxt], 0.159999, 0.8);
  1528. PlayerTextDrawColor(playerid, gui_ButtonData[playerid][id][gui_but_tdtxt], -1);
  1529. PlayerTextDrawSetOutline(playerid, gui_ButtonData[playerid][id][gui_but_tdtxt], 1);
  1530. PlayerTextDrawSetProportional(playerid, gui_ButtonData[playerid][id][gui_but_tdtxt], 1);
  1531. PlayerTextDrawTextSize(playerid, gui_ButtonData[playerid][id][gui_but_tdtxt], height-(height/4), width);
  1532. PlayerTextDrawSetSelectable(playerid, gui_ButtonData[playerid][id][gui_but_tdtxt], 1);
  1533. gui_ButtonData[playerid][id][gui_but_tdgl] = CreatePlayerTextDraw(playerid, x, y+2.0, "_");
  1534. PlayerTextDrawAlignment(playerid, gui_ButtonData[playerid][id][gui_but_tdgl], 2);
  1535. PlayerTextDrawBackgroundColor(playerid, gui_ButtonData[playerid][id][gui_but_tdgl], 255);
  1536. PlayerTextDrawFont(playerid, gui_ButtonData[playerid][id][gui_but_tdgl], 1);
  1537. //PlayerTextDrawLetterSize(playerid, gui_ButtonData[playerid][id][gui_but_tdgl], 0.159998, (height*UNIT)-1.075);
  1538. PlayerTextDrawLetterSize(playerid, gui_ButtonData[playerid][id][gui_but_tdgl], 0.159998, (((height/2)-4.0)*UNIT));
  1539. PlayerTextDrawColor(playerid, gui_ButtonData[playerid][id][gui_but_tdgl], -1);
  1540. PlayerTextDrawSetOutline(playerid, gui_ButtonData[playerid][id][gui_but_tdgl], 1);
  1541. PlayerTextDrawSetProportional(playerid, gui_ButtonData[playerid][id][gui_but_tdgl], 1);
  1542. PlayerTextDrawUseBox(playerid, gui_ButtonData[playerid][id][gui_but_tdgl], 1);
  1543. PlayerTextDrawBoxColor(playerid, gui_ButtonData[playerid][id][gui_but_tdgl], -245);
  1544. PlayerTextDrawTextSize(playerid, gui_ButtonData[playerid][id][gui_but_tdgl], height, width-4.0);
  1545. return gui_ButtonData[playerid][id][gui_but_ID];
  1546. }
  1547. function Float:guiGetButtonHeight(playerid, buttonid)
  1548. {
  1549. if (buttonid >= MAX_GUI) return 0.0;
  1550. new r;
  1551. for(new g; g < MAX_GUI; g++)
  1552. {
  1553. if (gui_ButtonData[playerid][g][gui_but_ID]== buttonid)
  1554. {
  1555. buttonid = g;
  1556. r = 1;
  1557. break;
  1558. }
  1559. }
  1560. if (!r) return 0.0;
  1561. if (!gui_ButtonData[playerid][buttonid][gui_but_ID]) return 0.0;
  1562. return gui_ButtonData[playerid][buttonid][gui_but_Height];
  1563. }
  1564. function Float:guiGetButtonWidth(playerid, buttonid)
  1565. {
  1566. if (buttonid >= MAX_GUI) return 0.0;
  1567. new r;
  1568. for(new g; g < MAX_GUI; g++)
  1569. {
  1570. if (gui_ButtonData[playerid][g][gui_but_ID]== buttonid)
  1571. {
  1572. buttonid = g;
  1573. r = 1;
  1574. break;
  1575. }
  1576. }
  1577. if (!r) return 0.0;
  1578. if (!gui_ButtonData[playerid][buttonid][gui_but_ID]) return 0.0;
  1579. return gui_ButtonData[playerid][buttonid][gui_but_Width];
  1580. }
  1581. function guiGetButtonPos(playerid, buttonid, &Float:x, &Float:y)
  1582. {
  1583. if (buttonid >= MAX_GUI) return 0;
  1584. new r;
  1585. for(new g; g < MAX_GUI; g++)
  1586. {
  1587. if (gui_ButtonData[playerid][g][gui_but_ID]== buttonid)
  1588. {
  1589. buttonid = g;
  1590. r = 1;
  1591. break;
  1592. }
  1593. }
  1594. if (!r) return 0;
  1595. if (!gui_ButtonData[playerid][buttonid][gui_but_ID]) return 0;
  1596. x = gui_ButtonData[playerid][buttonid][gui_but_X];
  1597. y = gui_ButtonData[playerid][buttonid][gui_but_Y];
  1598. return 1;
  1599. }
  1600. function guiGetID(playerid, type, gui)
  1601. {
  1602. switch (type)
  1603. {
  1604. case GUI_TYPE_WINDOW:
  1605. {
  1606. for(new g; g < MAX_GUI; g++)
  1607. {
  1608. if (gui_WindowData[playerid][g][gui_win_ID] == gui)
  1609. return g;
  1610. }
  1611. }
  1612. case GUI_TYPE_TAB:
  1613. {
  1614. for(new g; g < MAX_GUI; g++)
  1615. {
  1616. if (gui_TabData[playerid][g][gui_tab_ID] == gui)
  1617. return g;
  1618. }
  1619. }
  1620. case GUI_TYPE_LABEL:
  1621. {
  1622. for(new g; g < MAX_GUI; g++)
  1623. {
  1624. if (gui_LabelData[playerid][g][gui_label_ID] == gui)
  1625. return g;
  1626. }
  1627. }
  1628. case GUI_TYPE_BAR:
  1629. {
  1630. for(new g; g < MAX_GUI; g++)
  1631. {
  1632. if (gui_BarData[playerid][g][gui_bar_ID] == gui)
  1633. return g;
  1634. }
  1635. }
  1636. case GUI_TYPE_ITEMLIST:
  1637. {
  1638. for(new g; g < MAX_GUI; g++)
  1639. {
  1640. if (gui_ItemlistData[playerid][g][gui_list_ID] == gui)
  1641. return g;
  1642. }
  1643. }
  1644. case GUI_TYPE_CHECKBOX:
  1645. {
  1646. for(new g; g < MAX_GUI; g++)
  1647. {
  1648. if (gui_CheckboxData[playerid][g][gui_check_ID] == gui)
  1649. return g;
  1650. }
  1651. }
  1652. case GUI_TYPE_BUTTON:
  1653. {
  1654. for(new g; g < MAX_GUI; g++)
  1655. {
  1656. if (gui_ButtonData[playerid][g][gui_but_ID] == gui)
  1657. return g;
  1658. }
  1659. }
  1660. }
  1661. return -1;
  1662. }
  1663. function guiIsVisible(playerid, type, gui)
  1664. {
  1665. switch (type)
  1666. {
  1667. case GUI_TYPE_WINDOW:
  1668. {
  1669. for(new g; g < MAX_GUI; g++)
  1670. {
  1671. if (gui_WindowData[playerid][g][gui_win_ID] == gui)
  1672. return GetTextDrawVisibilityForPlayer(playerid, gui_WindowData[playerid][g][gui_win_td]);
  1673. }
  1674. }
  1675. case GUI_TYPE_TAB:
  1676. {
  1677. for(new g; g < MAX_GUI; g++)
  1678. {
  1679. if (gui_TabData[playerid][g][gui_tab_ID] == gui)
  1680. {
  1681. if (!GetTextDrawVisibilityForPlayer(playerid, gui_TabData[playerid][g][gui_tab_td])) return GetTextDrawVisibilityForPlayer(playerid, gui_TabData[playerid][g][gui_tab_td2]);
  1682. else GetTextDrawVisibilityForPlayer(playerid, gui_TabData[playerid][g][gui_tab_td]);
  1683. }
  1684. }
  1685. }
  1686. case GUI_TYPE_LABEL:
  1687. {
  1688. for(new g; g < MAX_GUI; g++)
  1689. {
  1690. if (gui_LabelData[playerid][g][gui_label_ID] == gui)
  1691. return GetTextDrawVisibilityForPlayer(playerid, gui_LabelData[playerid][g][gui_label_td]);
  1692. }
  1693. }
  1694. case GUI_TYPE_BAR:
  1695. {
  1696. for(new g; g < MAX_GUI; g++)
  1697. {
  1698. if (gui_BarData[playerid][g][gui_bar_ID] == gui)
  1699. return GetTextDrawVisibilityForPlayer(playerid, gui_BarData[playerid][g][gui_bar_tdbg]);
  1700. }
  1701. }
  1702. case GUI_TYPE_ITEMLIST:
  1703. {
  1704. for(new g; g < MAX_GUI; g++)
  1705. {
  1706. if (gui_ItemlistData[playerid][g][gui_list_ID] == gui)
  1707. return GetTextDrawVisibilityForPlayer(playerid, gui_ItemlistData[playerid][g][gui_list_tdbox]);
  1708. }
  1709. }
  1710. case GUI_TYPE_CHECKBOX:
  1711. {
  1712. for(new g; g < MAX_GUI; g++)
  1713. {
  1714. if (gui_CheckboxData[playerid][g][gui_check_ID] == gui)
  1715. {
  1716. if (!GetTextDrawVisibilityForPlayer(playerid, gui_CheckboxData[playerid][g][gui_check_td])) return GetTextDrawVisibilityForPlayer(playerid, gui_CheckboxData[playerid][g][gui_check_td2]);
  1717. else GetTextDrawVisibilityForPlayer(playerid, gui_CheckboxData[playerid][g][gui_check_td]);
  1718. }
  1719. }
  1720. }
  1721. case GUI_TYPE_BUTTON:
  1722. {
  1723. for(new g; g < MAX_GUI; g++)
  1724. {
  1725. if (gui_ButtonData[playerid][g][gui_but_ID] == gui)
  1726. return GetTextDrawVisibilityForPlayer(playerid, gui_ButtonData[playerid][g][gui_but_tdtxt]);
  1727. }
  1728. }
  1729. }
  1730. return 0;
  1731. }
  1732. function guiDestroy(playerid, type, gui)
  1733. {
  1734. if (!IsPlayerConnected(playerid)) return 0;
  1735. switch (type)
  1736. {
  1737. case GUI_TYPE_WINDOW:
  1738. {
  1739. for(new g; g < MAX_GUI; g++)
  1740. {
  1741. if (gui_WindowData[playerid][g][gui_win_ID] == gui)
  1742. {
  1743. gui_WindowData[playerid][g][gui_win_ID] = 0;
  1744. TextDrawDestroyEx(playerid, gui_WindowData[playerid][g][gui_win_td]);
  1745. TextDrawDestroyEx(playerid, gui_WindowData[playerid][g][gui_win_tdtop]);
  1746. TextDrawDestroyEx(playerid, gui_WindowData[playerid][g][gui_win_tdtitle]);
  1747. return 1;
  1748. }
  1749. }
  1750. }
  1751. case GUI_TYPE_TAB:
  1752. {
  1753. for(new g; g < MAX_GUI; g++)
  1754. {
  1755. if (gui_TabData[playerid][g][gui_tab_ID] == gui)
  1756. {
  1757. gui_TabData[playerid][g][gui_tab_ID] = 0;
  1758. TextDrawDestroyEx(playerid, gui_TabData[playerid][g][gui_tab_td]);
  1759. TextDrawDestroyEx(playerid, gui_TabData[playerid][g][gui_tab_td2]);
  1760. TextDrawDestroyEx(playerid, gui_TabData[playerid][gui_TabData[playerid][g][gui_tab_panel]][gui_tab_tdbg]);
  1761. TextDrawDestroyEx(playerid, gui_TabData[playerid][gui_TabData[playerid][g][gui_tab_panel]][gui_tab_tdbox]);
  1762. return 1;
  1763. }
  1764. }
  1765. }
  1766. case GUI_TYPE_LABEL:
  1767. {
  1768. for(new g; g < MAX_GUI; g++)
  1769. {
  1770. if (gui_LabelData[playerid][g][gui_label_ID] == gui)
  1771. {
  1772. gui_LabelData[playerid][g][gui_label_ID] = 0;
  1773. TextDrawDestroyEx(playerid, gui_LabelData[playerid][g][gui_label_td]);
  1774. return 1;
  1775. }
  1776. }
  1777. }
  1778. case GUI_TYPE_BAR:
  1779. {
  1780. for(new g; g < MAX_GUI; g++)
  1781. {
  1782. if (gui_BarData[playerid][g][gui_bar_ID] == gui)
  1783. {
  1784. gui_BarData[playerid][g][gui_bar_ID] = 0;
  1785. TextDrawDestroyEx(playerid, gui_BarData[playerid][g][gui_bar_tdbg]);
  1786. TextDrawDestroyEx(playerid, gui_BarData[playerid][g][gui_bar_tdbox]);
  1787. TextDrawDestroyEx(playerid, gui_BarData[playerid][g][gui_bar_tdbar]);
  1788. return 1;
  1789. }
  1790. }
  1791. }
  1792. case GUI_TYPE_ITEMLIST:
  1793. {
  1794. for(new g; g < MAX_GUI; g++)
  1795. {
  1796. if (gui_ItemlistData[playerid][g][gui_list_ID] == gui)
  1797. {
  1798. gui_ItemlistData[playerid][g][gui_list_ID] = 0;
  1799. TextDrawDestroyEx(playerid, gui_ItemlistData[playerid][g][gui_list_tdbox]);
  1800. TextDrawDestroyEx(playerid, gui_ItemlistData[playerid][g][gui_list_tdline]);
  1801. TextDrawDestroyEx(playerid, gui_ItemlistData[playerid][g][gui_list_tdtitle]);
  1802. for(new r; r <= gui_ItemlistData[playerid][g][gui_list_RowMax]; r++)
  1803. {
  1804. if (gui_ItemRowData[playerid][r][gui_row_ID] > 0)
  1805. {
  1806. gui_ItemRowData[playerid][r][gui_row_ID] = 0;
  1807. TextDrawDestroyEx(playerid, gui_ItemRowData[playerid][r][gui_row_td]);
  1808. TextDrawDestroyEx(playerid, gui_ItemRowData[playerid][r][gui_row_td2]);
  1809. }
  1810. }
  1811. return 1;
  1812. }
  1813. }
  1814. }
  1815. case GUI_TYPE_CHECKBOX:
  1816. {
  1817. for(new g; g < MAX_GUI; g++)
  1818. {
  1819. if (gui_CheckboxData[playerid][g][gui_check_ID] == gui)
  1820. {
  1821. gui_CheckboxData[playerid][g][gui_check_ID] = 0;
  1822. TextDrawDestroyEx(playerid, gui_CheckboxData[playerid][g][gui_check_td]);
  1823. TextDrawDestroyEx(playerid, gui_CheckboxData[playerid][g][gui_check_td2]);
  1824. return 1;
  1825. }
  1826. }
  1827. }
  1828. case GUI_TYPE_BUTTON:
  1829. {
  1830. for(new g; g < MAX_GUI; g++)
  1831. {
  1832. if (gui_ButtonData[playerid][g][gui_but_ID] == gui)
  1833. {
  1834. gui_ButtonData[playerid][g][gui_but_ID] = 0;
  1835. TextDrawDestroyEx(playerid, gui_ButtonData[playerid][g][gui_but_tdbg]);
  1836. TextDrawDestroyEx(playerid, gui_ButtonData[playerid][g][gui_but_tdout]);
  1837. TextDrawDestroyEx(playerid, gui_ButtonData[playerid][g][gui_but_tdbox]);
  1838. TextDrawDestroyEx(playerid, gui_ButtonData[playerid][g][gui_but_tdtxt]);
  1839. TextDrawDestroyEx(playerid, gui_ButtonData[playerid][g][gui_but_tdgl]);
  1840. return 1;
  1841. }
  1842. }
  1843. }
  1844. }
  1845. return 0;
  1846. }
  1847. function guiDestroyAll(playerid, type) // 0 = all
  1848. {
  1849. if (!IsPlayerConnected(playerid)) return 0;
  1850. new follow;
  1851. START:
  1852. switch (type)
  1853. {
  1854. case 0:
  1855. {
  1856. follow = 1;
  1857. type = GUI_TYPE_WINDOW;
  1858. goto START;
  1859. }
  1860. case GUI_TYPE_WINDOW:
  1861. {
  1862. for(new g; g < MAX_GUI; g++)
  1863. {
  1864. if (gui_WindowData[playerid][g][gui_win_ID] > 0)
  1865. {
  1866. gui_WindowData[playerid][g][gui_win_ID] = 0;
  1867. TextDrawDestroyEx(playerid, gui_WindowData[playerid][g][gui_win_td]);
  1868. TextDrawDestroyEx(playerid, gui_WindowData[playerid][g][gui_win_tdtop]);
  1869. TextDrawDestroyEx(playerid, gui_WindowData[playerid][g][gui_win_tdtitle]);
  1870. }
  1871. }
  1872. if (follow)
  1873. {
  1874. type = GUI_TYPE_TAB;
  1875. goto START;
  1876. }
  1877. }
  1878. case GUI_TYPE_TAB:
  1879. {
  1880. for(new g; g < MAX_GUI; g++)
  1881. {
  1882. if (gui_TabData[playerid][g][gui_tab_ID] > 0)
  1883. {
  1884. gui_TabData[playerid][g][gui_tab_ID] = 0;
  1885. TextDrawDestroyEx(playerid, gui_TabData[playerid][g][gui_tab_td]);
  1886. TextDrawDestroyEx(playerid, gui_TabData[playerid][g][gui_tab_td2]);
  1887. TextDrawDestroyEx(playerid, gui_TabData[playerid][gui_TabData[playerid][g][gui_tab_panel]][gui_tab_tdbg]);
  1888. TextDrawDestroyEx(playerid, gui_TabData[playerid][gui_TabData[playerid][g][gui_tab_panel]][gui_tab_tdbox]);
  1889. }
  1890. }
  1891. if (follow)
  1892. {
  1893. type = GUI_TYPE_LABEL;
  1894. goto START;
  1895. }
  1896. }
  1897. case GUI_TYPE_LABEL:
  1898. {
  1899. for(new g; g < MAX_GUI; g++)
  1900. {
  1901. if (gui_LabelData[playerid][g][gui_label_ID] > 0)
  1902. {
  1903. gui_LabelData[playerid][g][gui_label_ID] = 0;
  1904. TextDrawDestroyEx(playerid, gui_LabelData[playerid][g][gui_label_td]);
  1905. }
  1906. }
  1907. if (follow)
  1908. {
  1909. type = GUI_TYPE_BAR;
  1910. goto START;
  1911. }
  1912. }
  1913. case GUI_TYPE_BAR:
  1914. {
  1915. for(new g; g < MAX_GUI; g++)
  1916. {
  1917. if (gui_BarData[playerid][g][gui_bar_ID] > 0)
  1918. {
  1919. gui_BarData[playerid][g][gui_bar_ID] = 0;
  1920. TextDrawDestroyEx(playerid, gui_BarData[playerid][g][gui_bar_tdbg]);
  1921. TextDrawDestroyEx(playerid, gui_BarData[playerid][g][gui_bar_tdbox]);
  1922. TextDrawDestroyEx(playerid, gui_BarData[playerid][g][gui_bar_tdbar]);
  1923. }
  1924. }
  1925. if (follow)
  1926. {
  1927. type = GUI_TYPE_ITEMLIST;
  1928. goto START;
  1929. }
  1930. }
  1931. case GUI_TYPE_ITEMLIST:
  1932. {
  1933. for(new g; g < MAX_GUI; g++)
  1934. {
  1935. if (gui_ItemlistData[playerid][g][gui_list_ID] > 0)
  1936. {
  1937. gui_ItemlistData[playerid][g][gui_list_ID] = 0;
  1938. TextDrawDestroyEx(playerid, gui_ItemlistData[playerid][g][gui_list_tdbox]);
  1939. TextDrawDestroyEx(playerid, gui_ItemlistData[playerid][g][gui_list_tdline]);
  1940. TextDrawDestroyEx(playerid, gui_ItemlistData[playerid][g][gui_list_tdtitle]);
  1941. for(new r; r <= gui_ItemlistData[playerid][g][gui_list_RowMax]; r++)
  1942. {
  1943. if (gui_ItemRowData[playerid][r][gui_row_ID] > 0)
  1944. {
  1945. gui_ItemRowData[playerid][r][gui_row_ID] = 0;
  1946. TextDrawDestroyEx(playerid, gui_ItemRowData[playerid][r][gui_row_td]);
  1947. TextDrawDestroyEx(playerid, gui_ItemRowData[playerid][r][gui_row_td2]);
  1948. }
  1949. }
  1950. }
  1951. }
  1952. if (follow)
  1953. {
  1954. type = GUI_TYPE_CHECKBOX;
  1955. goto START;
  1956. }
  1957. }
  1958. case GUI_TYPE_CHECKBOX:
  1959. {
  1960. for(new g; g < MAX_GUI; g++)
  1961. {
  1962. if (gui_CheckboxData[playerid][g][gui_check_ID] > 0)
  1963. {
  1964. gui_CheckboxData[playerid][g][gui_check_ID] = 0;
  1965. TextDrawDestroyEx(playerid, gui_CheckboxData[playerid][g][gui_check_td]);
  1966. TextDrawDestroyEx(playerid, gui_CheckboxData[playerid][g][gui_check_td2]);
  1967. }
  1968. }
  1969. if (follow)
  1970. {
  1971. type = GUI_TYPE_BUTTON;
  1972. goto START;
  1973. }
  1974. }
  1975. case GUI_TYPE_BUTTON:
  1976. {
  1977. for(new g; g < MAX_GUI; g++)
  1978. {
  1979. if (gui_ButtonData[playerid][g][gui_but_ID] > 0)
  1980. {
  1981. gui_ButtonData[playerid][g][gui_but_ID] = 0;
  1982. TextDrawDestroyEx(playerid, gui_ButtonData[playerid][g][gui_but_tdbg]);
  1983. TextDrawDestroyEx(playerid, gui_ButtonData[playerid][g][gui_but_tdout]);
  1984. TextDrawDestroyEx(playerid, gui_ButtonData[playerid][g][gui_but_tdbox]);
  1985. TextDrawDestroyEx(playerid, gui_ButtonData[playerid][g][gui_but_tdtxt]);
  1986. TextDrawDestroyEx(playerid, gui_ButtonData[playerid][g][gui_but_tdgl]);
  1987. }
  1988. }
  1989. }
  1990. }
  1991. return 1;
  1992. }
  1993. forward gui_OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid);
  1994. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  1995. {
  1996. if ((tickcount()-GetPVarInt(playerid, "guiinc_i")) < 500) return 0; // Preventing spam, because of loop.
  1997. for(new c; c < MAX_GUI; c++)
  1998. {
  1999. if (gui_TabData[playerid][c][gui_tab_ID] > 0)
  2000. {
  2001. if (playerid != gui_TabData[playerid][c][gui_tab_P]) continue;
  2002. if (playertextid == gui_TabData[playerid][c][gui_tab_td])
  2003. {
  2004. PlayerTextDrawHide(playerid, gui_TabData[playerid][p_tab[playerid]][gui_tab_td2]);
  2005. guiSetVisible(playerid, GUI_TYPE_TAB, gui_TabData[playerid][p_tab[playerid]][gui_tab_ID], false);
  2006. PlayerTextDrawHide(playerid, gui_TabData[playerid][c][gui_tab_td]);
  2007. p_tab[playerid] = c;
  2008. guiSetVisible(playerid, GUI_TYPE_TAB, gui_TabData[playerid][c][gui_tab_ID], true);
  2009. OnPlayerClickTab(playerid, gui_TabData[playerid][c][gui_tab_ID]);
  2010. break;
  2011. }
  2012. }
  2013. if (gui_ButtonData[playerid][c][gui_but_ID] > 0)
  2014. {
  2015. if (playerid != gui_ButtonData[playerid][c][gui_but_P]) continue;
  2016. if (playertextid == gui_ButtonData[playerid][c][gui_but_tdtxt] || playertextid == gui_ButtonData[playerid][c][gui_but_tdbg])
  2017. {
  2018. OnPlayerClickButton(playerid, gui_ButtonData[playerid][c][gui_but_ID]);
  2019. break;
  2020. }
  2021. }
  2022. if (gui_ItemRowData[playerid][c][gui_row_ID] > 0)
  2023. {
  2024. if (playertextid == gui_ItemRowData[playerid][c][gui_row_td])
  2025. {
  2026. PlayerTextDrawHide(playerid, gui_ItemRowData[playerid][p_row[playerid]][gui_row_td2]);
  2027. PlayerTextDrawShow(playerid, gui_ItemRowData[playerid][p_row[playerid]][gui_row_td]);
  2028. PlayerTextDrawHide(playerid, gui_ItemRowData[playerid][c][gui_row_td]);
  2029. PlayerTextDrawShow(playerid, gui_ItemRowData[playerid][c][gui_row_td2]);
  2030. p_row[playerid] = c;
  2031. break;
  2032. }
  2033. }
  2034. if (gui_CheckboxData[playerid][c][gui_check_ID] > 0)
  2035. {
  2036. if (playerid != gui_CheckboxData[playerid][c][gui_check_P]) continue;
  2037. if (playertextid == gui_CheckboxData[playerid][c][gui_check_td])
  2038. {
  2039. PlayerTextDrawHide(playerid, gui_CheckboxData[playerid][c][gui_check_td]);
  2040. PlayerTextDrawShow(playerid, gui_CheckboxData[playerid][c][gui_check_td2]);
  2041. break;
  2042. }
  2043. if (playertextid == gui_CheckboxData[playerid][c][gui_check_td2])
  2044. {
  2045. PlayerTextDrawHide(playerid, gui_CheckboxData[playerid][c][gui_check_td2]);
  2046. PlayerTextDrawShow(playerid, gui_CheckboxData[playerid][c][gui_check_td]);
  2047. break;
  2048. }
  2049. }
  2050. }
  2051. SetPVarInt(playerid, "guiinc_i", tickcount());
  2052. return gui_OnPlayerClickPlayerTextDraw(playerid, playertextid);
  2053. //return 0;
  2054. }
  2055. #define OnPlayerClickPlayerTextDraw gui_OnPlayerClickPlayerTextDraw
  2056. // END
  2057. #if defined function
  2058. #undef function
  2059. #endif