Advertisement
Guest User

Untitled

a guest
May 16th, 2012
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.67 KB | None | 0 0
  1. //-----------------------------------------------------------------------------------|
  2. // [svText] |
  3. // |
  4. // |
  5. // - You may not remove these credits |
  6. // - You may not claim this script as yours |
  7. // |
  8. // |
  9. // |
  10. // [VERSION 1.0] Created by SuperViper |
  11. //-----------------------------------------------------------------------------------|
  12.  
  13. #include <a_samp>
  14.  
  15. #define MAX_TEXT MAX_OBJECTS/5
  16.  
  17. // ================================================================================ ///
  18. // DO NOT TOUCH ANYTHING BELOW THIS ///
  19. // ================================================================================ ///
  20.  
  21. forward svText_OnPlayerTouchText(playerid, textID);
  22.  
  23. enum e_svText_Text
  24. {
  25. bool: svBeingUsed,
  26. svColor,
  27. Float: svPosition[4],
  28. svSize,
  29. svText[150],
  30. svFont[20],
  31. svAlignment,
  32. svObject,
  33. svPickup,
  34. bool: svPlayerObject,
  35. svPlayer,
  36. }
  37.  
  38. new svText_Text[MAX_TEXT][e_svText_Text], bool: svText_Debugging;
  39.  
  40. stock svText_Debug(bool: toggleDebug)
  41. {
  42. if(toggleDebug == true)
  43. {
  44. print("(svText) Debugging has been turned on");
  45. }
  46. else if(toggleDebug == false)
  47. {
  48. print("(svText) Debugging has been turned off");
  49. }
  50.  
  51. return svText_Debugging = toggleDebug;
  52. }
  53.  
  54. stock svText_Create3DText(text[], color, Float: posX, Float: posY, Float: posZ, Float: rotX = 0.0, Float: rotY = 0.0, Float: rotZ = 0.0, size = 20, font[] = "Arial", alignment = 0)
  55. {
  56. if(svText_Debugging == true)
  57. {
  58. printf("(svText) Create3DText(text = %s, color = %d, posX = %f, posY = %f, posZ = %f, rotZ = %f, size = %d, font = %s, alignment = %d", text, color ,posX, posY, posZ, rotZ, size, font, alignment);
  59. }
  60.  
  61. new i;
  62.  
  63. for(new t = 0; t < MAX_TEXT; t++)
  64. {
  65. if(svText_Text[t][svBeingUsed] == false)
  66. {
  67. i = t;
  68. break;
  69. }
  70. }
  71.  
  72. svText_Text[i][svBeingUsed] = true;
  73. svText_Text[i][svColor] = color;
  74. svText_Text[i][svPosition][0] = posX, svText_Text[i][svPosition][1] = posY, svText_Text[i][svPosition][2] = posZ, svText_Text[i][svPosition][3] = rotZ;
  75. svText_Text[i][svSize] = size;
  76. svText_Text[i][svAlignment] = alignment;
  77. format(svText_Text[i][svText], 150, text);
  78. format(svText_Text[i][svFont], 20, font);
  79. svText_Text[i][svPlayerObject] = false;
  80.  
  81. svText_Text[i][svPickup] = CreatePickup(19300, 23, posX, posY, posZ);
  82. svText_Text[i][svObject] = CreateObject(19479, posX, posY, posZ, rotX, rotY, rotZ);
  83. SetObjectMaterialText(svText_Text[i][svObject], text, 0, OBJECT_MATERIAL_SIZE_512x256, font, size, 1, color, 0, alignment);
  84. return i;
  85. }
  86.  
  87. stock svText_CreatePlayer3DText(playerid, text[], color, Float: posX, Float: posY, Float: posZ, Float: rotX = 0.0, Float: rotY = 0.0, Float: rotZ = 0.0, size = 20, font[] = "Arial", alignment = 0)
  88. {
  89. if(svText_Debugging == true)
  90. {
  91. printf("(svText) CreatePlayer3DText(playerid = %d, text = %s, color = %d, posX = %f, posY = %f, posZ = %f, rotZ = %f, size = %d, font = %s, alignment = %d", text, color ,posX, posY, posZ, rotZ, size, font, alignment);
  92. }
  93.  
  94. new i;
  95.  
  96. for(new t = 0; t < MAX_TEXT; t++)
  97. {
  98. if(svText_Text[t][svBeingUsed] == false)
  99. {
  100. i = t;
  101. break;
  102. }
  103. }
  104.  
  105. svText_Text[i][svBeingUsed] = true;
  106. svText_Text[i][svColor] = color;
  107. svText_Text[i][svPosition][0] = posX, svText_Text[i][svPosition][1] = posY, svText_Text[i][svPosition][2] = posZ, svText_Text[i][svPosition][3] = rotZ;
  108. svText_Text[i][svSize] = size;
  109. svText_Text[i][svAlignment] = alignment;
  110. format(svText_Text[i][svText], 150, text);
  111. format(svText_Text[i][svFont], 20, font);
  112. svText_Text[i][svPlayerObject] = true;
  113. svText_Text[i][svPlayer] = playerid;
  114.  
  115. svText_Text[i][svPickup] = CreatePickup(19300, 23, posX, posY, posZ);
  116. svText_Text[i][svObject] = CreatePlayerObject(playerid, 19479, posX, posY, posZ, rotX, rotY, rotZ);
  117. SetObjectMaterialText(svText_Text[i][svObject], text, 0, OBJECT_MATERIAL_SIZE_512x256, font, size, 1, color, 0, alignment);
  118. return i;
  119. }
  120.  
  121. stock svText_Destroy3DText(textID)
  122. {
  123. if(svText_Debugging == true)
  124. {
  125. printf("(svText) Destroy3DText(textID = %d)", textID);
  126. }
  127.  
  128. if(svText_Text[textID][svBeingUsed] == true)
  129. {
  130. if((svText_Text[textID][svPlayerObject] == false) ? DestroyObject(svText_Text[textID][svObject]) : DestroyPlayerObject(svText_Text[textID][svPlayer], svText_Text[textID][svObject])) { }
  131. DestroyPickup(svText_Text[textID][svPickup]);
  132. svText_Text[textID][svBeingUsed] = false;
  133. }
  134.  
  135. return 1;
  136. }
  137.  
  138. stock svText_IsValid3DText(textID)
  139. {
  140. if(svText_Debugging == true)
  141. {
  142. printf("(svText) IsValid3DText(textID = %d)", textID);
  143. }
  144.  
  145. return svText_Text[textID][svBeingUsed];
  146. }
  147.  
  148. stock svText_Attach3DTextToPlayer(textID, playerid, Float: offsetX = 0.0, Float: offsetY = 0.0, Float: offsetZ = 0.0, Float: offsetRotX = 0.0, Float: offsetRotY = 0.0, Float: offsetRotZ = 0.0)
  149. {
  150. if(svText_Debugging == true)
  151. {
  152. printf("(svText) Attach3DTextToPlayer(textID = %d, playerid = %d, offsetX = %f, offsetY = %f, offsetZ = %f, offsetRotX = %f, offsetRotY = %f, offsetRotZ = %f)", textID, playerid, offsetX, offsetY, offsetZ, offsetRotX, offsetRotY, offsetRotZ);
  153. }
  154.  
  155. if(svText_Text[textID][svBeingUsed] == true)
  156. {
  157. if((svText_Text[textID][svPlayerObject] == false) ? AttachObjectToPlayer(svText_Text[textID][svObject], playerid, offsetX, offsetY, offsetZ, offsetRotX, offsetRotY, offsetRotZ) : AttachPlayerObjectToPlayer(svText_Text[textID][svPlayer], svText_Text[textID][svObject], playerid, offsetX, offsetY, offsetZ, offsetRotX, offsetRotY, offsetRotZ)) { }
  158. }
  159.  
  160. return 1;
  161. }
  162.  
  163. stock svText_Attach3DTextToObject(textID, objectid, Float: offsetX = 0.0, Float: offsetY = 0.0, Float: offsetZ = 0.0, Float: offsetRotX = 0.0, Float: offsetRotY = 0.0, Float: offsetRotZ = 0.0)
  164. {
  165. if(svText_Debugging == true)
  166. {
  167. printf("(svText) Attach3DTextToObject(textID = %d, objectid = %d, offsetX = %f, offsetY = %f, offsetZ = %f, offsetRotX = %f, offsetRotY = %f, offsetRotZ = %f)", textID, playerid, offsetX, offsetY, offsetZ, offsetRotX, offsetRotY, offsetRotZ);
  168. }
  169.  
  170. if(svText_Text[textID][svBeingUsed] == true)
  171. {
  172. if((svText_Text[textID][svPlayerObject] == false) ? AttachObjectToObject(svText_Text[textID][svObject], objectid, offsetX, offsetY, offsetZ, offsetRotX, offsetRotY, offsetRotZ) : AttachPlayerObjectToObject(svText_Text[textID][svPlayer], svText_Text[textID][svObject], objectid, offsetX, offsetY, offsetZ, offsetRotX, offsetRotY, offsetRotZ)) { }
  173. }
  174.  
  175. return 1;
  176. }
  177.  
  178. stock svText_Attach3DTextToVehicle(textID, vehicleid, Float: offsetX = 0.0, Float: offsetY = 0.0, Float: offsetZ = 0.0, Float: offsetRotX = 0.0, Float: offsetRotY = 0.0, Float: offsetRotZ = 0.0)
  179. {
  180. if(svText_Debugging == true)
  181. {
  182. printf("(svText) Attach3DTextToVehicle(textID = %d, vehicleid = %d, offsetX = %f, offsetY = %f, offsetZ = %f, offsetRotX = %f, offsetRotY = %f, offsetRotZ = %f)", textID, playerid, offsetX, offsetY, offsetZ, offsetRotX, offsetRotY, offsetRotZ);
  183. }
  184.  
  185. if(svText_Text[textID][svBeingUsed] == true)
  186. {
  187. if((svText_Text[textID][svPlayerObject] == false) ? AttachObjectToVehicle(svText_Text[textID][svObject], vehicleid, offsetX, offsetY, offsetZ, offsetRotX, offsetRotY, offsetRotZ) : AttachPlayerObjectToVehicle(svText_Text[textID][svPlayer], svText_Text[textID][svObject], vehicleid, offsetX, offsetY, offsetZ, offsetRotX, offsetRotY, offsetRotZ)) { }
  188. }
  189.  
  190. return 1;
  191. }
  192.  
  193. stock svText_Detach3DText(textID)
  194. {
  195. if(svText_Debugging == true)
  196. {
  197. printf("(svText) svText_DetachText(textID = %d)", textID);
  198. }
  199.  
  200. if(svText_Text[textID][svBeingUsed] == true)
  201. {
  202. new Float: textInfo[6];
  203. DestroyPickup(svText_Text[textID][svPickup]);
  204. svText_Text[textID][svPickup] = CreatePickup(19300, 23, textInfo[0], textInfo[1], textInfo[2]);
  205.  
  206. if(svText_Text[textID][svPlayerObject] == false)
  207. {
  208. GetObjectPos(svText_Text[textID][svObject], textInfo[0], textInfo[1], textInfo[2]);
  209. GetObjectRot(svText_Text[textID][svObject], textInfo[3], textInfo[4], textInfo[5]);
  210. DestroyObject(svText_Text[textID][svObject]);
  211. svText_Text[textID][svObject] = CreateObject(19479, textInfo[0], textInfo[1], textInfo[2], textInfo[3], textInfo[4], textInfo[5]);
  212. SetObjectMaterialText(svText_Text[textID][svObject], svText_Text[textID][svText], 0, OBJECT_MATERIAL_SIZE_512x256, svText_Text[textID][svFont], svText_Text[textID][svSize], 1, svText_Text[textID][svColor], 0, svText_Text[textID][svAlignment]);
  213. }
  214. else
  215. {
  216. GetPlayerObjectPos(svText_Text[textID][svPlayer], svText_Text[textID][svObject], textInfo[0], textInfo[1], textInfo[2]);
  217. GetPlayerObjectRot(svText_Text[textID][svPlayer], svText_Text[textID][svObject], textInfo[3], textInfo[4], textInfo[5]);
  218. DestroyPlayerObject(svText_Text[textID][svPlayer], svText_Text[textID][svObject]);
  219. svText_Text[textID][svObject] = CreatePlayerObject(svText_Text[textID][svPlayer], 19479, textInfo[0], textInfo[1], textInfo[2], textInfo[3], textInfo[4], textInfo[5]);
  220. SetPlayerObjectMaterialText(svText_Text[textID][svPlayer], svText_Text[textID][svObject], svText_Text[textID][svText], 0, OBJECT_MATERIAL_SIZE_512x256, svText_Text[textID][svFont], svText_Text[textID][svSize], 1, svText_Text[textID][svColor], 0, svText_Text[textID][svAlignment]);
  221. }
  222. }
  223. return 1;
  224. }
  225.  
  226. stock svText_Move3DText(textID, Float: posX, Float: posY, Float: posZ, Float: speed = 1.0, Float: rotX = -1000.0, Float: rotY = -1000.0, Float: rotZ = -1000.0)
  227. {
  228. if(svText_Debugging == true)
  229. {
  230. printf("(svText) Move3DText(textID = %d, posX = %f, posY = %f, posZ = %f, speed = %f, rotX = %f, rotY = %f, rotZ = %f)", textID, posX, posY, posZ, speed, rotX, rotY, rotZ);
  231. }
  232.  
  233. if(svText_Text[textID][svBeingUsed] == true)
  234. {
  235. if((svText_Text[textID][svPlayerObject] == false) ? MoveObject(svText_Text[textID][svObject], posX, posY, posZ, speed, rotX, rotY, rotZ) : MovePlayerObject(svText_Text[textID][svPlayer], svText_Text[textID][svObject], posX, posY, posZ, speed, rotX, rotY, rotZ)) { }
  236. }
  237.  
  238. return 1;
  239. }
  240.  
  241. stock svText_Adjust3DTextData(textID, text[], color = -1, size = -1, font[] = "-1", alignment = -1)
  242. {
  243. if(svText_Debugging == true)
  244. {
  245. printf("(svText) Adjust3DTextData(textID = %d, text = %s, color = %d, size = %d, font = %s, alignment = %d)", textID, text, color, size, font, alignment);
  246. }
  247.  
  248. if(svText_Text[textID][svBeingUsed] == true)
  249. {
  250. format(svText_Text[textID][svText], 150, text);
  251.  
  252. if(color > -1)
  253. {
  254. svText_Text[textID][svColor] = color;
  255. }
  256.  
  257. if(size > -1)
  258. {
  259. svText_Text[textID][svSize] = size;
  260. }
  261.  
  262. if(strcmp(font, "-1"))
  263. {
  264. format(svText_Text[textID][svFont], 20, font);
  265. }
  266.  
  267. if(alignment > -1)
  268. {
  269. svText_Text[textID][svAlignment] = alignment;
  270. }
  271.  
  272. if(svText_Text[textID][svPlayerObject] == false)
  273. {
  274. SetObjectMaterialText(svText_Text[textID][svObject], text, 0, OBJECT_MATERIAL_SIZE_512x256, svText_Text[textID][svFont], svText_Text[textID][svSize], 1, svText_Text[textID][svColor], 0, svText_Text[textID][svAlignment]);
  275. }
  276. else
  277. {
  278. SetPlayerObjectMaterialText(svText_Text[textID][svPlayer], svText_Text[textID][svObject], text, 0, OBJECT_MATERIAL_SIZE_512x256, svText_Text[textID][svFont], svText_Text[textID][svSize], 1, svText_Text[textID][svColor], 0, svText_Text[textID][svAlignment]);
  279. }
  280. }
  281.  
  282. return 1;
  283. }
  284.  
  285. stock svText_BeginEditing3DText(playerid, textID)
  286. {
  287. if(svText_Debugging == true)
  288. {
  289. printf("(svText) BeginEditing3DText(playerid = %d, textID = %d)", playerid, textID);
  290. }
  291.  
  292. return (svText_Text[textID][svPlayerObject] == false) ? EditObject(playerid, svText_Text[textID][svObject]) : EditPlayerObject(svText_Text[textID][svPlayer], svText_Text[textID][svObject]);
  293. }
  294.  
  295. stock svText_StopEditing3DText(playerid)
  296. {
  297. if(svText_Debugging == true)
  298. {
  299. printf("(svText) StopEditing3DText(playerid = %d)", playerid);
  300. }
  301.  
  302. return CancelEdit(playerid);
  303. }
  304.  
  305. forward svText_OnPlayerPickUpPickup(playerid, pickupid);
  306. public OnPlayerPickUpPickup(playerid, pickupid)
  307. {
  308. for(new i = 0; i < MAX_TEXT; i++)
  309. {
  310. if(svText_Text[i][svPickup] == pickupid)
  311. {
  312. CallRemoteFunction("svText_OnPlayerTouchText", "dd", playerid, i);
  313. break;
  314. }
  315. }
  316. return CallRemoteFunction("svText_OnPlayerPickUpPickup", "dd", playerid, pickupid);
  317. }
  318.  
  319. #if defined _ALS_OnPlayerPickUpPickup
  320. #undef OnPlayerPickUpPickup
  321. #else
  322. #define _ALS_OnPlayerPickUpPickup
  323. #endif
  324. #define OnPlayerPickUpPickup svText_OnPlayerPickUpPickup
  325.  
  326. forward svText_OnPlayerEditObject(playerid, playerobject, objectid, response, Float: fX, Float: fY, Float: fZ, Float: fRotX, Float: fRotY, Float: fRotZ);
  327. public OnPlayerEditObject(playerid, playerobject, objectid, response, Float: fX, Float: fY, Float: fZ, Float: fRotX, Float: fRotY, Float: fRotZ)
  328. {
  329. for(new i = 0; i < MAX_TEXT; i++)
  330. {
  331. if(svText_Text[i][svObject] == objectid)
  332. {
  333. svText_Text[i][svPosition][0] = fX, svText_Text[i][svPosition][1] = fY, svText_Text[i][svPosition][2] = fZ;
  334. break;
  335. }
  336. }
  337.  
  338. return 1;
  339. }
  340.  
  341. #if defined _ALS_OnPlayerEditObject
  342. #undef OnPlayerEditObject
  343. #else
  344. #define _ALS_OnPlayerEditObject
  345. #endif
  346. #define OnPlayerEditObject svText_OnPlayerEditObject
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement