1
0

textlabels.pwn 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Dynamic Textlabel System
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. CMD:tledit(playerid, params[])
  34. {
  35. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pGangModerator] == 2 || PlayerInfo[playerid][pFactionModerator] == 2)
  36. {
  37. new string[128], choice[32], labelid, amount;
  38. if(sscanf(params, "s[32]dD", choice, labelid, amount))
  39. {
  40. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /tledit [name] [labelid] [amount]");
  41. SendClientMessageEx(playerid, COLOR_GREY, "Available names: Position, Color, PickupModel, Delete");
  42. return 1;
  43. }
  44. if(labelid >= MAX_3DLABELS)
  45. {
  46. SendClientMessageEx( playerid, COLOR_WHITE, "Invalid Text Label ID!");
  47. return 1;
  48. }
  49. if(strcmp(choice, "position", true) == 0)
  50. {
  51. GetPlayerPos(playerid, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]);
  52. TxtLabels[labelid][tlInt] = GetPlayerInterior(playerid);
  53. TxtLabels[labelid][tlVW] = GetPlayerVirtualWorld(playerid);
  54. format(string, sizeof(string), "You have changed the position on Text Label #%d.", labelid);
  55. SendClientMessageEx(playerid, COLOR_WHITE, string);
  56. CreateTxtLabel(labelid);
  57. SaveTxtLabel(labelid);
  58. format(string, sizeof(string), "%s has edited Text Label ID %d's position.", GetPlayerNameEx(playerid), labelid);
  59. Log("logs/tledit.log", string);
  60. return 1;
  61. }
  62. else if(strcmp(choice, "color", true) == 0)
  63. {
  64. TxtLabels[labelid][tlColor] = amount;
  65. format(string, sizeof(string), "You have changed the color to %d on Text Label #%d.", amount, labelid);
  66. SendClientMessageEx(playerid, COLOR_WHITE, string);
  67. CreateTxtLabel(labelid);
  68. SaveTxtLabel(labelid);
  69. format(string, sizeof(string), "%s has edited Text Label ID %d's color.", GetPlayerNameEx(playerid), labelid);
  70. Log("logs/tledit.log", string);
  71. return 1;
  72. }
  73. else if(strcmp(choice, "pickupmodel", true) == 0)
  74. {
  75. TxtLabels[labelid][tlPickupModel] = amount;
  76. format(string, sizeof(string), "You have changed the pickup model to %d on Text Label #%d.", amount, labelid);
  77. SendClientMessageEx(playerid, COLOR_WHITE, string);
  78. CreateTxtLabel(labelid);
  79. SaveTxtLabel(labelid);
  80. format(string, sizeof(string), "%s has edited Text Label ID %d's PickupModel.", GetPlayerNameEx(playerid), labelid);
  81. Log("logs/tledit.log", string);
  82. return 1;
  83. }
  84. else if(strcmp(choice, "delete", true) == 0)
  85. {
  86. if(strcmp(TxtLabels[labelid][tlText], "None", true) == 0) {
  87. format(string, sizeof(string), "Text Label %d does not exist.", labelid);
  88. SendClientMessageEx(playerid, COLOR_WHITE, string);
  89. return 1;
  90. }
  91. if(IsValidDynamicPickup(TxtLabels[labelid][tlPickupID])) DestroyDynamicPickup(TxtLabels[labelid][tlPickupID]);
  92. if(IsValidDynamic3DTextLabel(TxtLabels[labelid][tlTextID])) DestroyDynamic3DTextLabel(TxtLabels[labelid][tlTextID]);
  93. TxtLabels[labelid][tlText] = 0;
  94. TxtLabels[labelid][tlPosX] = 0.0;
  95. TxtLabels[labelid][tlPosY] = 0.0;
  96. TxtLabels[labelid][tlPosZ] = 0.0;
  97. TxtLabels[labelid][tlVW] = 0;
  98. TxtLabels[labelid][tlInt] = 0;
  99. TxtLabels[labelid][tlColor] = 0;
  100. TxtLabels[labelid][tlPickupModel] = 0;
  101. SaveTxtLabel(labelid);
  102. format(string, sizeof(string), "You have deleted Text Label #%d.", labelid);
  103. SendClientMessageEx(playerid, COLOR_WHITE, string);
  104. format(string, sizeof(string), "%s has deleted Text Label %d.", GetPlayerNameEx(playerid), labelid);
  105. Log("logs/tledit.log", string);
  106. return 1;
  107. }
  108. }
  109. else return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  110. return 1;
  111. }
  112. CMD:tltext(playerid, params[]) {
  113. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pGangModerator] == 2 || PlayerInfo[playerid][pFactionModerator] == 2)
  114. {
  115. new szName[128], labelid;
  116. if(sscanf(params, "ds[128]", labelid, szName)) {
  117. return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /tltext [labelid] [text]");
  118. }
  119. else if(!(0 <= labelid <= MAX_3DLABELS)) {
  120. return SendClientMessageEx(playerid, COLOR_GREY, "Invalid door specified.");
  121. }
  122. else if(strfind(szName, "\r") != -1 || strfind(szName, "\n") != -1) {
  123. return SendClientMessageEx(playerid, COLOR_GREY, "Newline characters are forbidden.");
  124. }
  125. strcat((TxtLabels[labelid][tlText][0] = 0, TxtLabels[labelid][tlText]), szName, 128);
  126. SendClientMessageEx(playerid, COLOR_WHITE, "You have successfully changed the text on this text label.");
  127. CreateTxtLabel(labelid);
  128. SaveTxtLabel(labelid);
  129. format(szName, sizeof(szName), "%s has edited Text Label ID %d's text to %s.", GetPlayerNameEx(playerid), labelid, TxtLabels[labelid][tlText]);
  130. Log("logs/tledit.log", szName);
  131. }
  132. else return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  133. return 1;
  134. }
  135. CMD:tlstatus(playerid, params[])
  136. {
  137. new labelid;
  138. if(sscanf(params, "i", labelid))
  139. {
  140. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /tlstatus [labelid]");
  141. return 1;
  142. }
  143. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pGangModerator] == 2 || PlayerInfo[playerid][pFactionModerator] == 2)
  144. {
  145. new string[128];
  146. format(string,sizeof(string),"|___________ Text Label Status (ID: %d) ___________|", labelid);
  147. SendClientMessageEx(playerid, COLOR_GREEN, string);
  148. format(string, sizeof(string), "[Position] X: %f | Y: %f | Z: %f | VW: %d | Int: %d", TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt]);
  149. SendClientMessageEx(playerid, COLOR_WHITE, string);
  150. format(string, sizeof(string), "Text: %s | Color: %d | Pickup Model: %d", TxtLabels[labelid][tlText], TxtLabels[labelid][tlColor], TxtLabels[labelid][tlPickupModel]);
  151. SendClientMessageEx(playerid, COLOR_WHITE, string);
  152. }
  153. else return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  154. return 1;
  155. }
  156. CMD:tlnext(playerid, params[])
  157. {
  158. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pGangModerator] == 2 || PlayerInfo[playerid][pFactionModerator] == 2)
  159. {
  160. SendClientMessageEx(playerid, COLOR_RED, "* Listing next available text label...");
  161. for(new x = 0;x<MAX_3DLABELS;x++)
  162. {
  163. if(TxtLabels[x][tlPosX] == 0)
  164. {
  165. new string[128];
  166. format(string, sizeof(string), "%d is available to use.", x);
  167. SendClientMessageEx(playerid, COLOR_WHITE, string);
  168. break;
  169. }
  170. }
  171. }
  172. else return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  173. return 1;
  174. }
  175. CMD:gotolabel(playerid, params[])
  176. {
  177. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pGangModerator] == 2 || PlayerInfo[playerid][pFactionModerator] == 2)
  178. {
  179. new labelnum;
  180. if(sscanf(params, "d", labelnum)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /gotolabel [labelnumber]");
  181. SetPlayerPos(playerid,TxtLabels[labelnum][tlPosX],TxtLabels[labelnum][tlPosY],TxtLabels[labelnum][tlPosZ]);
  182. SetPlayerInterior(playerid,TxtLabels[labelnum][tlInt]);
  183. PlayerInfo[playerid][pInt] = TxtLabels[labelnum][tlInt];
  184. SetPlayerVirtualWorld(playerid, TxtLabels[labelnum][tlVW]);
  185. PlayerInfo[playerid][pVW] = TxtLabels[labelnum][tlVW];
  186. }
  187. return 1;
  188. }
  189. stock CreateTxtLabel(labelid)
  190. {
  191. if(IsValidDynamicPickup(TxtLabels[labelid][tlPickupID])) DestroyDynamicPickup(TxtLabels[labelid][tlPickupID]);
  192. if(IsValidDynamic3DTextLabel(TxtLabels[labelid][tlTextID])) DestroyDynamic3DTextLabel(TxtLabels[labelid][tlTextID]);
  193. new string[128];
  194. format(string, sizeof(string), "%s\nID: %d",TxtLabels[labelid][tlText],labelid);
  195. switch(TxtLabels[labelid][tlColor])
  196. {
  197. case -1:{ /* Disable 3d Textdraw */ }
  198. case 1:{TxtLabels[labelid][tlTextID] = CreateDynamic3DTextLabel(string, COLOR_TWWHITE, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt], -1);}
  199. case 2:{TxtLabels[labelid][tlTextID] = CreateDynamic3DTextLabel(string, COLOR_TWPINK, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt], -1);}
  200. case 3:{TxtLabels[labelid][tlTextID] = CreateDynamic3DTextLabel(string, COLOR_TWRED, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt], -1);}
  201. case 4:{TxtLabels[labelid][tlTextID] = CreateDynamic3DTextLabel(string, COLOR_TWBROWN, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt], -1);}
  202. case 5:{TxtLabels[labelid][tlTextID] = CreateDynamic3DTextLabel(string, COLOR_TWGRAY, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt], -1);}
  203. case 6:{TxtLabels[labelid][tlTextID] = CreateDynamic3DTextLabel(string, COLOR_TWOLIVE, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt], -1);}
  204. case 7:{TxtLabels[labelid][tlTextID] = CreateDynamic3DTextLabel(string, COLOR_TWPURPLE, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt], -1);}
  205. case 8:{TxtLabels[labelid][tlTextID] = CreateDynamic3DTextLabel(string, COLOR_TWORANGE, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt], -1);}
  206. case 9:{TxtLabels[labelid][tlTextID] = CreateDynamic3DTextLabel(string, COLOR_TWAZURE, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt], -1);}
  207. case 10:{TxtLabels[labelid][tlTextID] = CreateDynamic3DTextLabel(string, COLOR_TWGREEN, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt], -1);}
  208. case 11:{TxtLabels[labelid][tlTextID] = CreateDynamic3DTextLabel(string, COLOR_TWBLUE, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt], -1);}
  209. case 12:{TxtLabels[labelid][tlTextID] = CreateDynamic3DTextLabel(string, COLOR_TWBLACK, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt], -1);}
  210. default:{TxtLabels[labelid][tlTextID] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, TxtLabels[labelid][tlVW], TxtLabels[labelid][tlInt], -1);}
  211. }
  212. switch(TxtLabels[labelid][tlPickupModel])
  213. {
  214. case -1: { /* Disable Pickup */ }
  215. case 1:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1210, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  216. case 2:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1212, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  217. case 3:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1239, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  218. case 4:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1240, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  219. case 5:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1241, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  220. case 6:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1242, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  221. case 7:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1247, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  222. case 8:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1248, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  223. case 9:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1252, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  224. case 10:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1253, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  225. case 11:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1254, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  226. case 12:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1313, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  227. case 13:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1272, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  228. case 14:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1273, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  229. case 15:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1274, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  230. case 16:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1275, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  231. case 17:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1276, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  232. case 18:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1277, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  233. case 19:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1279, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  234. case 20:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1314, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  235. case 21:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1316, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  236. case 22:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1317, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  237. case 23:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1559, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  238. case 24:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(1582, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  239. case 25:{TxtLabels[labelid][tlPickupID] = CreateDynamicPickup(2894, 23, TxtLabels[labelid][tlPosX], TxtLabels[labelid][tlPosY], TxtLabels[labelid][tlPosZ], TxtLabels[labelid][tlVW]);}
  240. default: { }
  241. }
  242. }
  243. stock SaveTxtLabels()
  244. {
  245. for(new i = 0; i < MAX_3DLABELS; i++)
  246. {
  247. SaveTxtLabel(i);
  248. }
  249. return 1;
  250. }
  251. stock RehashTxtLabel(labelid)
  252. {
  253. printf("[RehashTxtLabel] Deleting Text Label #%d from server...", labelid);
  254. if(IsValidDynamicPickup(TxtLabels[labelid][tlPickupID])) DestroyDynamicPickup(TxtLabels[labelid][tlPickupID]);
  255. if(IsValidDynamic3DTextLabel(TxtLabels[labelid][tlTextID])) DestroyDynamic3DTextLabel(TxtLabels[labelid][tlTextID]);
  256. TxtLabels[labelid][tlSQLId] = -1;
  257. TxtLabels[labelid][tlPosX] = 0.0;
  258. TxtLabels[labelid][tlPosY] = 0.0;
  259. TxtLabels[labelid][tlPosZ] = 0.0;
  260. TxtLabels[labelid][tlVW] = 0;
  261. TxtLabels[labelid][tlInt] = 0;
  262. TxtLabels[labelid][tlColor] = 0;
  263. TxtLabels[labelid][tlPickupModel] = 0;
  264. LoadTxtLabel(labelid);
  265. }
  266. stock RehashTxtLabels()
  267. {
  268. printf("[RehashTxtLabels] Deleting text labels from server...");
  269. for(new i = 0; i < MAX_3DLABELS; i++)
  270. {
  271. RehashTxtLabel(i);
  272. }
  273. LoadTxtLabels();
  274. }
  275. stock SaveTxtLabel(labelid)
  276. {
  277. new string[1024];
  278. mysql_format(MainPipeline, string, sizeof(string), "UPDATE `text_labels` SET \
  279. `Text`='%e', \
  280. `PosX`=%f, \
  281. `PosY`=%f, \
  282. `PosZ`=%f, \
  283. `VW`=%d, \
  284. `Int`=%d, \
  285. `Color`=%d, \
  286. `PickupModel`=%d WHERE `id`=%d",
  287. TxtLabels[labelid][tlText],
  288. TxtLabels[labelid][tlPosX],
  289. TxtLabels[labelid][tlPosY],
  290. TxtLabels[labelid][tlPosZ],
  291. TxtLabels[labelid][tlVW],
  292. TxtLabels[labelid][tlInt],
  293. TxtLabels[labelid][tlColor],
  294. TxtLabels[labelid][tlPickupModel],
  295. labelid+1
  296. ); // Array starts from zero, MySQL starts at 1 (this is why we are adding one).
  297. mysql_tquery(MainPipeline, string, "OnQueryFinish", "i", SENDDATA_THREAD);
  298. }
  299. stock LoadTxtLabel(labelid)
  300. {
  301. new string[128];
  302. mysql_format(MainPipeline, string, sizeof(string), "SELECT * FROM `text_labels` WHERE `id`=%d", labelid+1); // Array starts at zero, MySQL starts at 1.
  303. mysql_tquery(MainPipeline, string, "OnLoadTxtLabel", "i", labelid);
  304. }
  305. stock LoadTxtLabels()
  306. {
  307. printf("[LoadTxtLabels] Loading data from database...");
  308. mysql_tquery(MainPipeline, "SELECT * FROM `text_labels`", "OnLoadTxtLabels", "");
  309. }
  310. forward OnLoadTxtLabel(index);
  311. public OnLoadTxtLabel(index)
  312. {
  313. new rows;
  314. cache_get_row_count(rows);
  315. for(new row; row < rows; row++)
  316. {
  317. cache_get_value_name_int(row, "id", TxtLabels[index][tlSQLId]);
  318. cache_get_value_name(row, "Text", TxtLabels[index][tlText], 128);
  319. cache_get_value_name_float(row, "PosX", TxtLabels[index][tlPosX]);
  320. cache_get_value_name_float(row, "PosY", TxtLabels[index][tlPosY]);
  321. cache_get_value_name_float(row, "PosZ", TxtLabels[index][tlPosZ]);
  322. cache_get_value_name_int(row, "VW", TxtLabels[index][tlVW]);
  323. cache_get_value_name_int(row, "Int", TxtLabels[index][tlInt]);
  324. cache_get_value_name_int(row, "Color", TxtLabels[index][tlColor]);
  325. cache_get_value_name_int(row, "PickupModel", TxtLabels[index][tlPickupModel]);
  326. if(TxtLabels[index][tlPosX] != 0.0) CreateTxtLabel(index);
  327. }
  328. return 1;
  329. }
  330. forward OnLoadTxtLabels();
  331. public OnLoadTxtLabels()
  332. {
  333. new i, rows;
  334. cache_get_row_count(rows);
  335. while(i < rows)
  336. {
  337. /*TxtLabels[i][tlSQLId] = cache_get_field_content_int(i, "id", MainPipeline);
  338. cache_get_field_content(i, "Text", TxtLabels[i][tlText], MainPipeline, 128);
  339. TxtLabels[i][tlPosX] = cache_get_field_content_float(i, "PosX", MainPipeline);
  340. TxtLabels[i][tlPosY] = cache_get_field_content_float(i, "PosY", MainPipeline);
  341. TxtLabels[i][tlPosZ] = cache_get_field_content_float(i, "PosZ", MainPipeline);
  342. TxtLabels[i][tlVW] = cache_get_field_content_int(i, "VW", MainPipeline);
  343. TxtLabels[i][tlInt] = cache_get_field_content_int(i, "Int", MainPipeline);
  344. TxtLabels[i][tlColor] = cache_get_field_content_int(i, "Color", MainPipeline);
  345. TxtLabels[i][tlPickupModel] = cache_get_field_content_int(i, "PickupModel", MainPipeline);
  346. if(TxtLabels[i][tlPosX] != 0.0) CreateTxtLabel(i);*/
  347. LoadTxtLabel(i);
  348. i++;
  349. }
  350. }