Guest User

FuNkY's Dynamic Material Text System [fMAT] v2.0

a guest
Mar 24th, 2018
1,135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.03 KB | None | 0 0
  1. /*
  2. ___________________________________________________________________
  3. | |
  4. | Dynamic Material Text v2.0 System By |
  5. | ____ ____ ___ |
  6. | |___ U N K Y | HE | __ R E A T |
  7. | | | |___| |
  8. |__________________________________________________________________|*/
  9.  
  10. #define FILTERSCRIPT
  11.  
  12. #include <a_samp>
  13. #include <YSI\y_ini>
  14. #include <zcmd>
  15. #include <streamer>
  16. #include <foreach>
  17. #include <sscanf2>
  18. // *** Defines *** ///
  19.  
  20. #define MPATH "Materials/%d.txt" // Path where the Material saves.
  21. #define MAX_FONT_NAME 30 // The limit of Max font name !
  22. #define MAX_TEXT 50 // The limit of Max text, That can be used !
  23. #define MAX_MATERIALS 69 // Max amount of Materials
  24. #define MAT_DEFAULT_OBJECT 19480 // The default object of material (when created)
  25. #define MATERIAL_DEFAULT_INDEX 0 // The default index to set material text (when created)
  26. #define dValue 100 // Dialog value - starting from this Number.
  27.  
  28. /// ******************** ///
  29. #define MYRED "{FF0000}"
  30. #define MYBLUE "{0000FF}"
  31. #define MYYELLOW "{FFFF00}"
  32. #define MYORANGE "{FFA500}"
  33. #define MYPURPLE "{800080}"
  34. #define MYGREEN "{008000}"
  35. #define MYLBLUE "{0080FF}"
  36. #define MYWHITE "{FFFFFF}"
  37. #define MYBLACK "{000000}"
  38. #define MYCYAN "{00FFFF}"
  39. #define MYPINK "{FF00FF}"
  40. #define MYBROWN "{6A0000}"
  41. #define MYLPURPLE "{8080C0}"
  42. #define MYLGREEN "{00FF00}"
  43. #define MYGREY "{676767}"
  44.  
  45. #define MRED 0xFFFF0000
  46. #define MBLUE 0xFF0000FF
  47. #define MYELLOW 0xFFFFFF00
  48. #define MORANGE 0xFFFF8000
  49. #define MPURPLE 0xFF400080
  50. #define MGREEN 0xFF008000
  51. #define MLBLUE 0xFF0080FF
  52. #define MWHITE 0xFFFFFFFF
  53. #define MBLACK 0xFF000000
  54. #define MCYAN 0xFF00FFFF
  55. #define MPINK 0xFFFF00FF
  56. #define MBROWN 0xFF6A0000
  57. #define MLPURPLE 0xFF8080C0
  58. #define MLGREEN 0xFF00FF00
  59. #define MGRAY 0xFF676767
  60.  
  61. enum MaterialInfo
  62. {
  63. Float:MatX,
  64. Float:MatY,
  65. Float:MatZ,
  66. Float:MatRX,
  67. Float:MatRY,
  68. Float:MatRZ,
  69. MatText[MAX_TEXT],
  70. MatObj,
  71. MatSize,
  72. MatBGC,
  73. MatALG,
  74. MatFont[MAX_FONT_NAME],
  75. MatColor,
  76. MatBold,
  77. MatRes,
  78. MatObjectID,
  79. MatIndex,
  80. }
  81. new matInfo[MAX_MATERIALS][MaterialInfo];
  82.  
  83. new Iterator:MatsItr<MAX_MATERIALS>;
  84. new SOID[MAX_PLAYERS];
  85. forward CreateMat(type,id,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz);
  86.  
  87. #define DIALOG_MATS dValue+2
  88. #define DIALOG_TEXT dValue+3
  89. #define DIALOG_FONT dValue+4
  90. #define DIALOG_DELETE dValue+5
  91. #define DIALOG_FONTCOLOR dValue+6
  92. #define DIALOG_FONTSIZE dValue+7
  93. #define DIALOG_BGCOLOR dValue+8
  94. #define DIALOG_ALLIGNMENT dValue+9
  95. #define DIALOG_RESOLUTION dValue+10
  96. #define DIALOG_CHANGEOBJECT dValue+11
  97. #define DIALOG_CHANGEINDEX dValue+12
  98.  
  99. enum FontInformation
  100. {
  101. FontName[MAX_FONT_NAME],
  102. };
  103. new FontInfo[][FontInformation] = // All the fonts, You can also add new one, Check example below.
  104. {
  105. {"Lucida Console"},
  106. {"Verdana"},
  107. {"Webdings"},
  108. {"Wingdings"},
  109. {"Times New Roman"},
  110. {"Microsoft Sans Serif"},
  111. {"GTAWEAPON3"},
  112. {"Impact"},
  113. {"Georgia"},
  114. {"Arial"},
  115. {"Arial Black"},
  116. {"Comic Sans MS"},
  117. {"Trebuchet MS"}
  118. // {"YOUR FONT NAME"}
  119. };
  120. public OnFilterScriptInit()
  121. {
  122. print("\n===================================");
  123. print("| Dynamic Material Text System v2.0 |");
  124. print("| By FuNkYTheGreat [LOADED] |");
  125. print("=====================================\n");
  126. new string[25];
  127. for(new i = 0; i < MAX_MATERIALS; i++)
  128. {
  129. format(string, sizeof(string), MPATH, i);
  130. if(fexist(string))
  131. {
  132. INI_ParseFile(string, "loadmat", .bExtra = true, .extra = i);
  133. CreateMat(2,i,matInfo[i][MatX],matInfo[i][MatY],matInfo[i][MatZ],matInfo[i][MatRX],matInfo[i][MatRY],matInfo[i][MatRZ]);
  134. }
  135. }
  136. return 1;
  137. }
  138. public OnFilterScriptExit()
  139. {
  140. for(new i = 0; i < MAX_MATERIALS; i++)
  141. {
  142. if(Iter_Contains(MatsItr,i))
  143. {
  144. SaveMat(i);
  145. DeleteMat(i);
  146. }
  147. }
  148. return 1;
  149. }
  150. CMD:createmat(playerid,params[])
  151. {
  152. new string[90];
  153. new Float:x, Float:y, Float:z, Float:a;
  154. GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, a);
  155. if(Iter_Count(MatsItr) > MAX_MATERIALS) return SendClientMessage(playerid, -1 , ""MYRED"[MATERIAL]"MYWHITE" You've reached the total amount of Materials, Max Materials: "#MAX_MATERIALS");
  156. new id = Iter_Free(MatsItr);
  157. format(string, sizeof(string), ""MYRED"[MATERIAL]"MYWHITE" Material created succesfully, The Material id is %d", id);
  158. SendClientMessage(playerid, -1 , string);
  159. SetPVarInt(playerid,"matID",id);
  160. format(matInfo[id][MatText],30,"NEW MATERIAL");
  161. format(matInfo[id][MatFont],30,"Arial");
  162. matInfo[id][MatColor] = MRED;
  163. matInfo[id][MatObjectID] = MAT_DEFAULT_OBJECT;
  164. CreateMat(1,id,x,y,z,0,0,a);
  165. EditDynamicObject(playerid,matInfo[id][MatObj]);
  166. return 1;
  167. }
  168. CMD:nearmat(playerid, params[])
  169. {
  170. new string[128],count = 0;
  171. for(new i = 0; i < MAX_MATERIALS; i++)
  172. {
  173. if(IsPlayerInRangeOfPoint(playerid, 15.0, matInfo[i][MatX], matInfo[i][MatY], matInfo[i][MatZ]))
  174. {
  175. count = 1;
  176. SendClientMessage(playerid,-1,""MYRED" _________________________________Material Info _________________________________");
  177. format(string, sizeof(string), ""MYWHITE"ID: %d , Text: %s , Font Size: %d , Font Name: %s", i, matInfo[i][MatText] , matInfo[i][MatSize],matInfo[i][MatFont]);
  178. SendClientMessage(playerid,-1,string);
  179. SendClientMessage(playerid,-1,""MYRED"_________________________________________________________________________________");
  180. return 1;
  181. }
  182. }
  183. if(count == 0) return SendClientMessage(playerid,-1,""MYRED"[MATERIAL]"MYWHITE" You are not near any Material");
  184. return 1;
  185. }
  186. CMD:editmat(playerid, params[])
  187. {
  188. new ID;
  189. if(sscanf(params, "i",ID)) return SendClientMessage(playerid, -1, ""MYRED"[MATERIAL]"MYWHITE" /editmat(erial) [id]");
  190. if(!Iter_Contains(MatsItr,ID)) return SendClientMessage(playerid, -1, ""MYRED"[MATERIAL]"MYWHITE" Material ID doesn't exists");
  191. ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  192. SOID[playerid] = ID;
  193. return 1;
  194. }
  195. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  196. {
  197. new string[356];
  198. new ID = SOID[playerid];
  199. if(dialogid == DIALOG_MATS)
  200. {
  201. if(!response) return 1;
  202. switch(listitem)
  203. {
  204. case 0: ShowPlayerDialog(playerid, DIALOG_TEXT , DIALOG_STYLE_INPUT, "Material System - Change Text", "Please input the text", "Select", "Back");
  205. case 1:
  206. {
  207. for(new a=0; a<sizeof(FontInfo); a++)
  208. {
  209. format(string, sizeof(string), "%s%s\n", string, FontInfo[a][FontName]);
  210. }
  211. ShowPlayerDialog(playerid, DIALOG_FONT , DIALOG_STYLE_LIST, "Material System - Choose Font", string, "Select", "Back");
  212. }
  213. case 2: ShowPlayerDialog(playerid, DIALOG_FONTCOLOR , DIALOG_STYLE_LIST, "Material System - Choose Color", ""MYRED"Red\n"MYBLUE"Blue\n"MYYELLOW"Yellow\n"MYORANGE"Orange\n"MYPURPLE"Purple\n"MYGREEN"Green\n"MYLBLUE"Light Blue\n"MYWHITE"White\n"MYBLACK"Black\n"MYCYAN"Cyan\n"MYPINK"Pink\n"MYBROWN"Brown\n"MYLPURPLE"Light Purple\n"MYLGREEN"Light Green\n"MYGREY"Gray", "Select", "Back");
  214. case 3: ShowPlayerDialog(playerid, DIALOG_FONTSIZE , DIALOG_STYLE_INPUT, "Material System - Font Size","Please enter a font size for your Material\nMust be Numeric.", "Enter", "Back");
  215. case 4: ShowPlayerDialog(playerid, DIALOG_BGCOLOR , DIALOG_STYLE_LIST, "Material System - Background Color",""MYRED"Red\n"MYBLUE"Blue\n"MYYELLOW"Yellow\n"MYORANGE"Orange\n"MYPURPLE"Purple\n"MYGREEN"Green\n"MYLBLUE"Light Blue\n"MYWHITE"White\n"MYBLACK"Black\n"MYCYAN"Cyan\n"MYPINK"Pink\n"MYBROWN"Brown\n"MYLPURPLE"Light Purple\n"MYLGREEN"Light Green\n"MYGREY"Gray\nNo Background", "Select", "Back");
  216. case 5: ShowPlayerDialog(playerid, DIALOG_ALLIGNMENT , DIALOG_STYLE_LIST, "Material System - Choose Allignment", "Left Allignment\nCenter Allignment\nRight Allignment", "Select", "Back");
  217. case 6:
  218. {
  219. format(string, sizeof(string), ""MYRED"[MATERIAL]"MYWHITE" Material Text %s", (matInfo[ID][MatBold] == 1) ? ("Un-Bolded") : ("Bolded"));
  220. SendClientMessage(playerid,-1,string);
  221. matInfo[ID][MatBold] =! matInfo[ID][MatBold];
  222. SetDynamicObjectMaterialText(matInfo[ID][MatObj] , matInfo[ID][MatIndex] , matInfo[ID][MatText] , matInfo[ID][MatRes], matInfo[ID][MatFont], matInfo[ID][MatSize], matInfo[ID][MatBold], matInfo[ID][MatColor], matInfo[ID][MatBGC],matInfo[ID][MatALG]);
  223. ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  224. }
  225. case 7: ShowPlayerDialog(playerid, DIALOG_RESOLUTION , DIALOG_STYLE_LIST, "Material System - Choose Resolution", "32x32\n64x32\n64x64\n128x32\n128x64\n128x128\n256x32\n256x64\n256x128\n256x256\n512x64\n512x128\n512x256\n512x512", "Select", "Back");
  226. case 8:
  227. {
  228. EditDynamicObject(playerid,matInfo[ID][MatObj]);
  229. SetPVarInt(playerid,"matID",ID);
  230. }
  231. case 9:
  232. {
  233. new id = Iter_Free(MatsItr);
  234. matInfo[id][MatX] = matInfo[ID][MatX];
  235. matInfo[id][MatY] = matInfo[ID][MatY];
  236. matInfo[id][MatZ] = matInfo[ID][MatZ];
  237. matInfo[id][MatRX] = matInfo[ID][MatRX];
  238. matInfo[id][MatRY] = matInfo[ID][MatRY];
  239. matInfo[id][MatRZ] = matInfo[ID][MatRZ];
  240. matInfo[id][MatSize] = matInfo[ID][MatSize];
  241. matInfo[id][MatBGC] = matInfo[ID][MatBGC];
  242. matInfo[id][MatALG] = matInfo[ID][MatALG];
  243. matInfo[id][MatBold] = matInfo[ID][MatBold];
  244. matInfo[id][MatRes] = matInfo[ID][MatRes];
  245. matInfo[id][MatColor] = matInfo[ID][MatColor];
  246. matInfo[id][MatObjectID] = matInfo[ID][MatObjectID];
  247. matInfo[id][MatIndex] = matInfo[ID][MatIndex];
  248. SetPVarInt(playerid,"matID",id);
  249. format(matInfo[id][MatText],30,matInfo[ID][MatText]);
  250. format(matInfo[id][MatFont],30,matInfo[ID][MatFont]);
  251. CreateMat(2,id,matInfo[ID][MatX],matInfo[ID][MatY],matInfo[ID][MatZ],matInfo[ID][MatRX],matInfo[ID][MatY],matInfo[ID][MatZ]);
  252. EditDynamicObject(playerid,matInfo[id][MatObj]);
  253. format(string,sizeof(string),""MYRED"[MATERIAL]"MYWHITE" Material ID %d has been duplicated on ID: %d !",ID,id);
  254. SendClientMessage(playerid,-1,string);
  255. }
  256. case 10:
  257. {
  258. DeleteMat(ID);
  259. format(string,sizeof(string),""MYRED"[MATERIAL]"MYWHITE" Material ID: %d has been deleted !",ID);
  260. SendClientMessage(playerid,-1,string);
  261. format(string, sizeof(string), MPATH, ID);
  262. fremove(string);
  263. }
  264. case 11: ShowPlayerDialog(playerid, DIALOG_CHANGEOBJECT , DIALOG_STYLE_INPUT, "Material System - Object ID","Please enter an object ID to change!.", "Enter", "Back");
  265. case 12: ShowPlayerDialog(playerid, DIALOG_CHANGEINDEX , DIALOG_STYLE_INPUT, "Material System - Material Index","Please enter an material index to set the Text on, (0 to 15)!.", "Enter", "Back");
  266. }
  267. }
  268. if(dialogid == DIALOG_TEXT)
  269. {
  270. if(!response) return ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  271. if(strlen(inputtext) >= MAX_TEXT || strlen(inputtext) <= 0 ) return SendClientMessage(playerid, -1 ,""MYRED"[MATERIAL]"MYWHITE" Text may not be less than 0 or more than "#MAX_TEXT"!");
  272.  
  273. SetDynamicObjectMaterialText(matInfo[ID][MatObj] , matInfo[ID][MatIndex] , inputtext , matInfo[ID][MatRes] , matInfo[ID][MatFont], matInfo[ID][MatSize], matInfo[ID][MatBold], matInfo[ID][MatColor], matInfo[ID][MatBGC],matInfo[ID][MatALG]);
  274. format(matInfo[ID][MatText],128,inputtext);
  275. ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  276. }
  277. if(dialogid == DIALOG_ALLIGNMENT)
  278. {
  279. if(!response) return ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  280. matInfo[ID][MatALG] = listitem;
  281. ShowPlayerDialog(playerid, DIALOG_ALLIGNMENT , DIALOG_STYLE_LIST, "Material System - Choose Allignment", "Left Allignment\nCenter Allignment\nRight Allignment", "Select", "Back");
  282. SetDynamicObjectMaterialText(matInfo[ID][MatObj] , matInfo[ID][MatIndex] , matInfo[ID][MatText] , matInfo[ID][MatRes], matInfo[ID][MatFont], matInfo[ID][MatSize], matInfo[ID][MatBold], matInfo[ID][MatColor], matInfo[ID][MatBGC],matInfo[ID][MatALG]);
  283. }
  284. if(dialogid == DIALOG_RESOLUTION)
  285. {
  286. if(!response) return ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  287. matInfo[ID][MatRes] = (listitem+1) * 10;
  288. ShowPlayerDialog(playerid, DIALOG_RESOLUTION , DIALOG_STYLE_LIST, "Material System - Choose Resolution", "32x32\n64x32\n64x64\n128x32\n128x64\n128x128\n256x32\n256x64\n256x128\n256x256\n512x64\n512x128\n512x256\n512x512", "Select", "Back");
  289. SetDynamicObjectMaterialText(matInfo[ID][MatObj] , matInfo[ID][MatIndex] , matInfo[ID][MatText] , matInfo[ID][MatRes], matInfo[ID][MatFont], matInfo[ID][MatSize], matInfo[ID][MatBold], matInfo[ID][MatColor], matInfo[ID][MatBGC],matInfo[ID][MatALG]);
  290. }
  291. if(dialogid == DIALOG_FONTSIZE)
  292. {
  293. if(!response) return ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  294. if(!isnumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_FONTSIZE , DIALOG_STYLE_INPUT, "Material System - Font Size","Enter a Font Size\nMust be numeric", "Enter", "Close");
  295. matInfo[ID][MatSize] = strval(inputtext);
  296. SetDynamicObjectMaterialText(matInfo[ID][MatObj] , matInfo[ID][MatIndex] , matInfo[ID][MatText] , matInfo[ID][MatRes] ,matInfo[ID][MatFont], matInfo[ID][MatSize] , matInfo[ID][MatBold], matInfo[ID][MatColor], matInfo[ID][MatBGC],matInfo[ID][MatALG]);
  297. ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  298. }
  299. if(dialogid == DIALOG_FONT)
  300. {
  301. if(!response) return ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  302. SetDynamicObjectMaterialText(matInfo[ID][MatObj] , matInfo[ID][MatIndex] , matInfo[ID][MatText] , matInfo[ID][MatRes],inputtext, matInfo[ID][MatSize], matInfo[ID][MatBold], matInfo[ID][MatColor], matInfo[ID][MatBGC],matInfo[ID][MatALG]);
  303. format(matInfo[ID][MatFont],128,inputtext);
  304. for(new a=0; a<sizeof(FontInfo); a++)
  305. {
  306. format(string, sizeof(string), "%s%s\n", string, FontInfo[a][FontName]);
  307. }
  308. ShowPlayerDialog(playerid, DIALOG_FONT , DIALOG_STYLE_LIST, "Material System - Choose Font", string, "Select", "Back");
  309. }
  310. if(dialogid == DIALOG_FONTCOLOR)
  311. {
  312. if(!response) return ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  313. switch(listitem)
  314. {
  315. case 0: matInfo[ID][MatColor] = MRED;
  316. case 1: matInfo[ID][MatColor] = MBLUE;
  317. case 2: matInfo[ID][MatColor] = MYELLOW;
  318. case 3: matInfo[ID][MatColor] = MORANGE;
  319. case 4: matInfo[ID][MatColor] = MPURPLE;
  320. case 5: matInfo[ID][MatColor] = MGREEN;
  321. case 6: matInfo[ID][MatColor] = MLBLUE;
  322. case 7: matInfo[ID][MatColor] = MWHITE;
  323. case 8: matInfo[ID][MatColor] = MBLACK;
  324. case 9: matInfo[ID][MatColor] = MCYAN;
  325. case 10: matInfo[ID][MatColor] = MPINK;
  326. case 11: matInfo[ID][MatColor] = MBROWN;
  327. case 12: matInfo[ID][MatColor] = MLPURPLE;
  328. case 13: matInfo[ID][MatColor] = MLGREEN;
  329. case 14: matInfo[ID][MatColor] = MGRAY;
  330. }
  331. SetDynamicObjectMaterialText(matInfo[ID][MatObj] , matInfo[ID][MatIndex] , matInfo[ID][MatText] , matInfo[ID][MatRes],matInfo[ID][MatFont], matInfo[ID][MatSize], matInfo[ID][MatBold],matInfo[ID][MatColor], matInfo[ID][MatBGC],matInfo[ID][MatALG]);
  332. ShowPlayerDialog(playerid, DIALOG_FONTCOLOR , DIALOG_STYLE_LIST, "Material System - Choose Color", ""MYRED"Red\n"MYBLUE"Blue\n"MYYELLOW"Yellow\n"MYORANGE"Orange\n"MYPURPLE"Purple\n"MYGREEN"Green\n"MYLBLUE"Light Blue\n"MYWHITE"White\n"MYBLACK"Black\n"MYCYAN"Cyan\n"MYPINK"Pink\n"MYBROWN"Brown\n"MYLPURPLE"Light Purple\n"MYLGREEN"Light Green\n"MYGREY"Gray", "Select", "Back");
  333. }
  334. if(dialogid == DIALOG_BGCOLOR)
  335. {
  336. if(!response) return ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  337. switch(listitem)
  338. {
  339. case 0: matInfo[ID][MatBGC] = MRED;
  340. case 1: matInfo[ID][MatBGC] = MBLUE;
  341. case 2: matInfo[ID][MatBGC] = MYELLOW;
  342. case 3: matInfo[ID][MatBGC] = MORANGE;
  343. case 4: matInfo[ID][MatBGC] = MPURPLE;
  344. case 5: matInfo[ID][MatBGC] = MGREEN;
  345. case 6: matInfo[ID][MatBGC] = MLBLUE;
  346. case 7: matInfo[ID][MatBGC] = MWHITE;
  347. case 8: matInfo[ID][MatBGC] = MBLACK;
  348. case 9: matInfo[ID][MatBGC] = MCYAN;
  349. case 10: matInfo[ID][MatBGC] = MPINK;
  350. case 11: matInfo[ID][MatBGC] = MBROWN;
  351. case 12: matInfo[ID][MatBGC] = MLPURPLE;
  352. case 13: matInfo[ID][MatBGC] = MLGREEN;
  353. case 14: matInfo[ID][MatBGC] = MGRAY;
  354. case 15: matInfo[ID][MatBGC] = 0;
  355. }
  356. ShowPlayerDialog(playerid, DIALOG_BGCOLOR , DIALOG_STYLE_LIST, "Material System - Background Color",""MYRED"Red\n"MYBLUE"Blue\n"MYYELLOW"Yellow\n"MYORANGE"Orange\n"MYPURPLE"Purple\n"MYGREEN"Green\n"MYLBLUE"Light Blue\n"MYWHITE"White\n"MYBLACK"Black\n"MYCYAN"Cyan\n"MYPINK"Pink\n"MYBROWN"Brown\n"MYLPURPLE"Light Purple\n"MYLGREEN"Light Green\n"MYGREY"Gray\nNo Background", "Select", "Back");
  357. SetDynamicObjectMaterialText(matInfo[ID][MatObj] , matInfo[ID][MatIndex] , matInfo[ID][MatText] , matInfo[ID][MatRes],matInfo[ID][MatFont], matInfo[ID][MatSize], matInfo[ID][MatBold] ,matInfo[ID][MatColor], matInfo[ID][MatBGC] ,matInfo[ID][MatALG]);
  358. }
  359. if(dialogid == DIALOG_CHANGEOBJECT)
  360. {
  361. if(!response) return ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  362. if(!isnumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_CHANGEOBJECT , DIALOG_STYLE_INPUT, "Material System - Object ID","Please enter an object ID to change!\n{FF0000}ERROR: Must be numeric", "Enter", "Back");
  363.  
  364. DestroyDynamicObject(matInfo[ID][MatObj]);
  365. matInfo[ID][MatObjectID] = strval(inputtext);
  366. CreateMat(0,ID,matInfo[ID][MatX],matInfo[ID][MatY],matInfo[ID][MatZ],matInfo[ID][MatRX],matInfo[ID][MatRY],matInfo[ID][MatRZ]);
  367. ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  368. }
  369. if(dialogid == DIALOG_CHANGEINDEX)
  370. {
  371. if(!response) return ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  372. if(!isnumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_CHANGEINDEX , DIALOG_STYLE_INPUT, "Material System - Material Index","Please enter an material index to set the Text on, (0 to 15)!\n{FF0000}ERROR: Must be numeric.", "Enter", "Back");
  373. if(strval(inputtext) > 15 || strval(inputtext) < 0) return ShowPlayerDialog(playerid, DIALOG_CHANGEINDEX , DIALOG_STYLE_INPUT, "Material System - Material Index","Please enter an material index to set the Text on, (0 to 15)!\n{FF0000}ERROR: Material index ranges from 0 to 15.", "Enter", "Back");
  374. DestroyDynamicObject(matInfo[ID][MatObj]);
  375. matInfo[ID][MatIndex] = strval(inputtext);
  376. CreateMat(0,ID,matInfo[ID][MatX],matInfo[ID][MatY],matInfo[ID][MatZ],matInfo[ID][MatRX],matInfo[ID][MatRY],matInfo[ID][MatRZ]);
  377. ShowPlayerDialog(playerid, DIALOG_MATS , DIALOG_STYLE_LIST, "Material System - v2.0 by FuNkY", "Change Text\nChange Font\nChange Color\nChange Font Size\nChange Background Color\nChange Allignment\nBold Text\nChange Resolution\nEdit Material Pos\nDuplicate Material\nDelete Material\nChange Object ID\nChange Material Index", "Select", "Close");
  378. }
  379. return 0;
  380. }
  381.  
  382. public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
  383. {
  384. new string[100];
  385. new editing = GetPVarInt(playerid,"matID");
  386.  
  387. if(response == EDIT_RESPONSE_UPDATE)
  388. {
  389. SetDynamicObjectPos(objectid, x, y, z);
  390. SetDynamicObjectRot(objectid, rx, ry, rz);
  391. }
  392. if(response == EDIT_RESPONSE_CANCEL)
  393. {
  394. if(editing >= 0)
  395. {
  396. SendClientMessage(playerid, -1 , ""MYRED"[MATERIAL]"MYWHITE" Material editing canceled !");
  397. DeletePVar(playerid, "matID");
  398. }
  399. }
  400. if(response == EDIT_RESPONSE_FINAL)
  401. {
  402. SetDynamicObjectPos(objectid, x, y, z);
  403. SetDynamicObjectRot(objectid, rx, ry, rz);
  404. if(editing >= 0)
  405. {
  406. matInfo[editing][MatX] = x;
  407. matInfo[editing][MatY] = y;
  408. matInfo[editing][MatZ] = z;
  409. matInfo[editing][MatRX] = rx;
  410. matInfo[editing][MatRY] = ry;
  411. matInfo[editing][MatRZ] = rz;
  412. format(string, sizeof(string), ""MYRED"[MATERIAL]"MYWHITE" You have succesfully edited ID: %d's Material", editing);
  413. SendClientMessage(playerid, -1, string);
  414. DeletePVar(playerid, "matID");
  415. SetDynamicObjectPos(objectid, x, y, z);
  416. SetDynamicObjectRot(objectid, rx, ry, rz);
  417. }
  418. }
  419. return 1;
  420. }
  421. forward loadmat(idx,name[], value[]);
  422. public loadmat(idx, name[], value[])
  423. {
  424. INI_Float("MatX", matInfo[idx][MatX]);
  425. INI_Float("MatY", matInfo[idx][MatY]);
  426. INI_Float("MatZ", matInfo[idx][MatZ]);
  427. INI_Float("MatRX", matInfo[idx][MatRX]);
  428. INI_Float("MatRY", matInfo[idx][MatRY]);
  429. INI_Float("MatRZ", matInfo[idx][MatRZ]);
  430. INI_String("MatText", matInfo[idx][MatText],MAX_TEXT);
  431. INI_String("MatFont", matInfo[idx][MatFont],MAX_FONT_NAME);
  432. INI_Int("MatColor", matInfo[idx][MatColor]);
  433. INI_Int("MatSize", matInfo[idx][MatSize]);
  434. INI_Int("MatBGC", matInfo[idx][MatBGC]);
  435. INI_Int("MatALG", matInfo[idx][MatALG]);
  436. INI_Int("MatBold", matInfo[idx][MatBold]);
  437. INI_Int("MatRes", matInfo[idx][MatRes]);
  438. INI_Int("MatObjectID", matInfo[idx][MatObjectID]);
  439. INI_Int("MatIndex", matInfo[idx][MatIndex]);
  440. return 1;
  441. }
  442. SaveMat(id)
  443. {
  444. new string[25];
  445. format(string, sizeof(string), MPATH, id);
  446. new INI:file = INI_Open(string);
  447. INI_WriteFloat(file,"MatX", matInfo[id][MatX]);
  448. INI_WriteFloat(file,"MatY", matInfo[id][MatY]);
  449. INI_WriteFloat(file,"MatZ", matInfo[id][MatZ]);
  450. INI_WriteFloat(file,"MatRX", matInfo[id][MatRX]);
  451. INI_WriteFloat(file,"MatRY", matInfo[id][MatRY]);
  452. INI_WriteFloat(file,"MatRZ", matInfo[id][MatRZ]);
  453. INI_WriteString(file,"MatText", matInfo[id][MatText]);
  454. INI_WriteString(file,"MatFont", matInfo[id][MatFont]);
  455. INI_WriteInt(file,"MatColor", matInfo[id][MatColor]);
  456. INI_WriteInt(file,"MatSize", matInfo[id][MatSize]);
  457. INI_WriteInt(file,"MatBGC", matInfo[id][MatBGC]);
  458. INI_WriteInt(file,"MatALG", matInfo[id][MatALG]);
  459. INI_WriteInt(file,"MatBold", matInfo[id][MatBold]);
  460. INI_WriteInt(file,"MatRes", matInfo[id][MatRes]);
  461. INI_WriteInt(file,"MatObjectID", matInfo[id][MatObjectID]);
  462. INI_WriteInt(file,"MatIndex", matInfo[id][MatIndex]);
  463. INI_Close(file);
  464. return 1;
  465. }
  466. DeleteMat(i)
  467. {
  468. matInfo[i][MatX] = 0;
  469. matInfo[i][MatY] = 0;
  470. matInfo[i][MatZ] = 0;
  471. matInfo[i][MatRX] = 0;
  472. matInfo[i][MatRY] = 0;
  473. matInfo[i][MatRZ] = 0;
  474. matInfo[i][MatText] = 0;
  475. DestroyDynamicObject(matInfo[i][MatObj]);
  476. matInfo[i][MatObj] = 0;
  477. matInfo[i][MatSize] = 0;
  478. matInfo[i][MatFont] = 0;
  479. matInfo[i][MatColor] = 0;
  480. matInfo[i][MatBGC] = 0;
  481. matInfo[i][MatALG] = 0;
  482. matInfo[i][MatBold] = 0;
  483. matInfo[i][MatRes] = 0;
  484. matInfo[i][MatObjectID] = 0;
  485. matInfo[i][MatIndex] = MATERIAL_DEFAULT_INDEX;
  486. Iter_Remove(MatsItr,i);
  487. return 1;
  488. }
  489. public CreateMat(type,id,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz)
  490. {
  491. if(type == 1)
  492. {
  493. matInfo[id][MatX] = x;
  494. matInfo[id][MatY] = y;
  495. matInfo[id][MatZ] = z;
  496. matInfo[id][MatRX] = rx;
  497. matInfo[id][MatRY] = ry;
  498. matInfo[id][MatRZ] = rz;
  499. matInfo[id][MatSize] = 25;
  500. matInfo[id][MatBGC] = MBLUE;
  501. matInfo[id][MatALG] = 1;
  502. matInfo[id][MatBold] = 0;
  503. matInfo[id][MatRes] = 90;
  504. matInfo[id][MatIndex] = MATERIAL_DEFAULT_INDEX;
  505. }
  506. matInfo[id][MatObj] = CreateDynamicObject(matInfo[id][MatObjectID], matInfo[id][MatX] , matInfo[id][MatY], matInfo[id][MatZ], matInfo[id][MatRX], matInfo[id][MatRY], matInfo[id][MatRZ], -1);
  507. SetDynamicObjectMaterialText(matInfo[id][MatObj] , matInfo[id][MatIndex] , matInfo[id][MatText] , matInfo[id][MatRes],matInfo[id][MatFont], matInfo[id][MatSize], matInfo[id][MatBold] , matInfo[id][MatColor],matInfo[id][MatBGC],matInfo[id][MatALG]);
  508. Iter_Add(MatsItr,id);
  509. SaveMat(id);
  510. }
Add Comment
Please, Sign In to add comment