[Shoebill] Includes and Snippets

    Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

    • [Shoebill] Includes and Snippets

      Ich dachte mir, dass es mal nützlich wäre, wenigstens ein Thema mit nützlichen Snippets für Shoebill zu haben, also einfach eure Snippets immer dazu posten.

      Erstelle einen TextDraw nach GameText Style mit Timerfunktion (Animation):

      youtube.com/watch?v=d_KfqeKoirM
      (Credits: Video von Fynn630)
      Das habe ich gestern erstellt, um mich mal mit Textdraws auseinanderzusetzen und alles ein wenig 'hübscher' (soweit es von SAMP aus möglich ist^^) zu machen, mit Transitions und Timer. Diese TextdrawObjekte kann man reaktivieren, stoppen, zurücksetzen, im Hintergrund weiterlaufen lassen, statisch, mit Transitions oder einfach nur mit Animation laufen lassen und von der Dauer der Effekte verändern.

      Java-Quellcode: GameTextTD.java

      1. package me.alf21.objects;
      2. import java.util.ArrayList;
      3. import net.gtaun.shoebill.Shoebill;
      4. import net.gtaun.shoebill.constant.TextDrawAlign;
      5. import net.gtaun.shoebill.constant.TextDrawFont;
      6. import net.gtaun.shoebill.data.Color;
      7. import net.gtaun.shoebill.object.Destroyable;
      8. import net.gtaun.shoebill.object.Player;
      9. import net.gtaun.shoebill.object.Textdraw;
      10. import net.gtaun.shoebill.object.Timer;
      11. /**
      12. * @author Alf21
      13. * create some styled GameTexts with timer effects visible as bar width increasing and transitions
      14. */
      15. public class GameTextTD implements Destroyable {
      16. //delay between each animation update
      17. private final static int updateDelay = 50;
      18. //to calculate transition
      19. private static Color backgroundColor = new Color(255,0,0,60),
      20. textColor = new Color(255,255,255,255),
      21. textBackgroundColor = new Color(0,0,0,255),
      22. barColor = new Color(255,255,255,255),
      23. barBackgroundColor = new Color(0,0,0,150);
      24. private Textdraw textTD,
      25. backgroundTD,
      26. topBarTD,
      27. bottomBarTD,
      28. topBarBackgroundTD,
      29. bottomBarBackgroundTD;
      30. private boolean destroyable,
      31. hided,
      32. useAnimation,
      33. useTransition;
      34. private int count,
      35. milliseconds,
      36. transitionMilliseconds;
      37. private Player player;
      38. private Timer timer;
      39. /**
      40. * create static GameTextTD Class without timer
      41. * @param player the target
      42. * @param text the text of TextDraw
      43. */
      44. public GameTextTD(Player player, String text) {
      45. this.player = player;
      46. destroyable = false;
      47. hided = false;
      48. milliseconds = -1;
      49. useAnimation = false;
      50. transitionMilliseconds = 500;
      51. useTransition = false;
      52. createGameTextTD(text);
      53. }
      54. /**
      55. * create GameTextTD Class with timer to disappear TextDraw Construction after the specified duration
      56. * @param player the target
      57. * @param text the text of TextDraw
      58. * @param milliseconds the duration (MUST be bigger than the updateDelay!)
      59. * @param useAnimation the use of animation
      60. */
      61. public GameTextTD(Player player, String text, int milliseconds, boolean useAnimation) {
      62. this(player, text);
      63. this.milliseconds = milliseconds;
      64. this.useAnimation = useAnimation;
      65. if(milliseconds >= updateDelay)
      66. initializeTimer();
      67. }
      68. /**
      69. * create GameTextTD Class with timer to disappear TextDraw Construction after the specified duration and transition
      70. * @param player the target
      71. * @param text the text of TextDraw
      72. * @param milliseconds the duration (MUST be bigger than the updateDelay!)
      73. * @param useAnimation the use of animation
      74. * @param useTransition the use of transition (alpha color effects)
      75. */
      76. public GameTextTD(Player player, String text, int milliseconds, boolean useAnimation, boolean useTransition) {
      77. this(player, text);
      78. this.milliseconds = milliseconds;
      79. this.useAnimation = useAnimation;
      80. this.useTransition = useTransition;
      81. if(milliseconds >= updateDelay)
      82. initializeTimer();
      83. }
      84. /**
      85. * create GameTextTD Class with timer to disappear TextDraw Construction after the specified duration with specified transition delay
      86. * @param player the target
      87. * @param text the text of TextDraw
      88. * @param milliseconds the duration (MUST be bigger than the updateDelay!)
      89. * @param useAnimation the use of animation
      90. * @param transitionMilliseconds the milliseconds of transition (IMPORTANT! need to be bigger than the half of milliseconds)
      91. */
      92. public GameTextTD(Player player, String text, int milliseconds, boolean useAnimation, int transitionMilliseconds) {
      93. this(player, text);
      94. this.milliseconds = milliseconds;
      95. this.useAnimation = useAnimation;
      96. this.transitionMilliseconds = transitionMilliseconds;
      97. this.useTransition = true;
      98. if(milliseconds >= updateDelay && milliseconds/2 >= transitionMilliseconds)
      99. initializeTimer();
      100. }
      101. /**
      102. * @return the player
      103. */
      104. public Player getPlayer() {
      105. return player;
      106. }
      107. /**
      108. * to stop, resume or modify the timer / animation
      109. * @return the timer
      110. */
      111. public Timer getTimer() {
      112. return timer;
      113. }
      114. /**
      115. * to modify the text
      116. * @return the TextDraw
      117. */
      118. public Textdraw getTextdraw() {
      119. return textTD;
      120. }
      121. /**
      122. * to modify the background
      123. * @return the backgroundTD
      124. */
      125. public Textdraw getBackgroundTextdraw() {
      126. return backgroundTD;
      127. }
      128. /**
      129. * to modify the bar TextDraws
      130. * @return the barTextdraws an ArrayList of TextDraws
      131. */
      132. public ArrayList<Textdraw> getBarTextdraws() {
      133. ArrayList<Textdraw> barTextdraws = new ArrayList<Textdraw>();
      134. barTextdraws.add(topBarTD);
      135. barTextdraws.add(bottomBarTD);
      136. return barTextdraws;
      137. }
      138. /**
      139. * to modify the bar background TextDraws
      140. * @return the barBackgroundTextdraws an ArrayList of TextDraws
      141. */
      142. public ArrayList<Textdraw> getBarBackgroundTextdraws() {
      143. ArrayList<Textdraw> barBackgroundTextdraws = new ArrayList<Textdraw>();
      144. barBackgroundTextdraws.add(topBarBackgroundTD);
      145. barBackgroundTextdraws.add(bottomBarBackgroundTD);
      146. return barBackgroundTextdraws;
      147. }
      148. /**
      149. * @return the destroyable
      150. */
      151. public boolean isDestroyable() {
      152. return destroyable;
      153. }
      154. /**
      155. * @return the hided
      156. */
      157. public boolean isHided() {
      158. return hided;
      159. }
      160. //The functions
      161. /**
      162. * hide TextDraw for player
      163. */
      164. public void hide() {
      165. hided = true;
      166. textTD.hide(player);
      167. topBarTD.hide(player);
      168. bottomBarTD.hide(player);
      169. topBarBackgroundTD.hide(player);
      170. bottomBarBackgroundTD.hide(player);
      171. backgroundTD.hide(player);
      172. }
      173. /**
      174. * hide TextDraw for player
      175. * @param stopTimer stop background calculation of the animation
      176. */
      177. public void hide(boolean stopTimer) {
      178. if(stopTimer && timer != null && timer.isRunning())
      179. timer.stop();
      180. hide();
      181. }
      182. /**
      183. * show TextDraw for player
      184. */
      185. public void show() {
      186. hided = false;
      187. backgroundTD.show(player);
      188. topBarBackgroundTD.show(player);
      189. bottomBarBackgroundTD.show(player);
      190. topBarTD.show(player);
      191. bottomBarTD.show(player);
      192. textTD.show(player);
      193. if(timer != null && timer.isDestroyed()) {
      194. reset();
      195. initializeTimer();
      196. }
      197. if(timer != null && !timer.isRunning()) {
      198. timer.start();
      199. }
      200. }
      201. //Advanced timer functions
      202. /**
      203. * initializes the Timer
      204. */
      205. private void initializeTimer() {
      206. if(milliseconds > 0) {
      207. reset();
      208. timer = Timer.create(updateDelay, (int) milliseconds/updateDelay, (factualInterval) -> {
      209. Shoebill.get().runOnSampThread(() -> {
      210. if(useAnimation) {
      211. float factor = (int) milliseconds/updateDelay;
      212. int transitionFactor = (int) factor;
      213. factor = (640-20) / factor;
      214. if(!hided) {
      215. topBarTD.hide(player);
      216. bottomBarTD.hide(player);
      217. if(useTransition) {
      218. int step = (int) transitionMilliseconds/updateDelay;
      219. if(count <= step-1 || count == step || count >= transitionFactor-(step-2)) {
      220. textTD.hide(player);
      221. topBarBackgroundTD.hide(player);
      222. bottomBarBackgroundTD.hide(player);
      223. backgroundTD.hide(player);
      224. if(count <= step-1) {
      225. backgroundTD.setBoxColor(new Color(backgroundColor.getR(), backgroundColor.getG(), backgroundColor.getB(), backgroundColor.getA()*(count+1)/step));
      226. topBarBackgroundTD.setBoxColor(new Color(barBackgroundColor.getR(), barBackgroundColor.getG(), barBackgroundColor.getB(), barBackgroundColor.getA()*(count+1)/step));
      227. bottomBarBackgroundTD.setBoxColor(new Color(barBackgroundColor.getR(), barBackgroundColor.getG(), barBackgroundColor.getB(), barBackgroundColor.getA()*(count+1)/step));
      228. topBarTD.setBoxColor(new Color(barColor.getR(), barColor.getG(), barColor.getB(), barColor.getA()*(count+1)/step));
      229. bottomBarTD.setBoxColor(new Color(barColor.getR(), barColor.getG(), barColor.getB(), barColor.getA()*(count+1)/step));
      230. textTD.setBackgroundColor(new Color(textBackgroundColor.getR(), textBackgroundColor.getG(), textBackgroundColor.getB(), textBackgroundColor.getA()*(count+1)/step));
      231. textTD.setColor(new Color(textColor.getR(), textColor.getG(), textColor.getB(), textColor.getA()*(count+1)/step));
      232. }
      233. else if(count >= transitionFactor-(step-2)) {
      234. backgroundTD.setBoxColor(new Color(backgroundColor.getR(), backgroundColor.getG(), backgroundColor.getB(), backgroundColor.getA()*(transitionFactor+1-count)/step));
      235. topBarBackgroundTD.setBoxColor(new Color(barBackgroundColor.getR(), barBackgroundColor.getG(), barBackgroundColor.getB(), barBackgroundColor.getA()*(transitionFactor+1-count)/step));
      236. bottomBarBackgroundTD.setBoxColor(new Color(barBackgroundColor.getR(), barBackgroundColor.getG(), barBackgroundColor.getB(), barBackgroundColor.getA()*(transitionFactor+1-count)/step));
      237. topBarTD.setBoxColor(new Color(barColor.getR(), barColor.getG(), barColor.getB(), barColor.getA()*(transitionFactor+1-count)/step));
      238. bottomBarTD.setBoxColor(new Color(barColor.getR(), barColor.getG(), barColor.getB(), barColor.getA()*(transitionFactor+1-count)/step));
      239. textTD.setBackgroundColor(new Color(textBackgroundColor.getR(), textBackgroundColor.getG(), textBackgroundColor.getB(), textBackgroundColor.getA()*(transitionFactor+1-count)/step));
      240. textTD.setColor(new Color(textColor.getR(), textColor.getG(), textColor.getB(), textColor.getA()*(transitionFactor+1-count)/step));
      241. }
      242. else if(count == step) {
      243. backgroundTD.setBoxColor(backgroundColor);
      244. topBarBackgroundTD.setBoxColor(barBackgroundColor);
      245. bottomBarBackgroundTD.setBoxColor(barBackgroundColor);
      246. topBarTD.setBoxColor(barColor);
      247. bottomBarTD.setBoxColor(barColor);
      248. textTD.setBackgroundColor(textBackgroundColor);
      249. textTD.setColor(textColor);
      250. }
      251. backgroundTD.show(player);
      252. topBarBackgroundTD.show(player);
      253. bottomBarBackgroundTD.show(player);
      254. textTD.show(player);
      255. }
      256. }
      257. topBarTD.setTextSize(0, 20+count*factor);
      258. bottomBarTD.setTextSize(0, 20+count*factor);
      259. topBarTD.show(player);
      260. bottomBarTD.show(player);
      261. }
      262. }
      263. if(count == (int) milliseconds/updateDelay) {
      264. reset();
      265. destroyable = true;
      266. }
      267. else count++;
      268. });
      269. });
      270. }
      271. }
      272. /**
      273. * reset the data for timer
      274. */
      275. private void reset() {
      276. hide(false);
      277. count = 1;
      278. if(useAnimation) {
      279. if(useTransition) {
      280. int i = (int) transitionMilliseconds/updateDelay;
      281. backgroundTD.setBoxColor(new Color(backgroundColor.getR(), backgroundColor.getG(), backgroundColor.getB(), backgroundColor.getA()/i));
      282. topBarBackgroundTD.setBoxColor(new Color(barBackgroundColor.getR(), barBackgroundColor.getG(), barBackgroundColor.getB(), barBackgroundColor.getA()/i));
      283. bottomBarBackgroundTD.setBoxColor(new Color(barBackgroundColor.getR(), barBackgroundColor.getG(), barBackgroundColor.getB(), barBackgroundColor.getA()/i));
      284. topBarTD.setBoxColor(new Color(barColor.getR(), barColor.getG(), barColor.getB(), barColor.getA()/i));
      285. bottomBarTD.setBoxColor(new Color(barColor.getR(), barColor.getG(), barColor.getB(), barColor.getA()/i));
      286. textTD.setBackgroundColor(new Color(textBackgroundColor.getR(), textBackgroundColor.getG(), textBackgroundColor.getB(), textBackgroundColor.getA()/i));
      287. textTD.setColor(new Color(textColor.getR(), textColor.getG(), textColor.getB(), textColor.getA()/i));
      288. }
      289. topBarTD.setTextSize(0, 20);
      290. bottomBarTD.setTextSize(0, 20);
      291. }
      292. destroyable = false;
      293. }
      294. //The TextDraws
      295. /**
      296. * create the textDraws
      297. * @param text the text of TextDraw
      298. */
      299. private void createGameTextTD(String text) {
      300. backgroundTD = Textdraw.create(320, 177);
      301. backgroundTD.setText("_");
      302. backgroundTD.setAlignment(TextDrawAlign.CENTER);
      303. backgroundTD.setBackgroundColor(Color.BLACK);
      304. backgroundTD.setFont(TextDrawFont.get(1));
      305. backgroundTD.setLetterSize(0.5f, 9.7f);
      306. backgroundTD.setColor(Color.WHITE);
      307. backgroundTD.setOutlineSize(0);
      308. backgroundTD.setProportional(true);
      309. backgroundTD.setUseBox(true);
      310. backgroundTD.setBoxColor(backgroundColor);
      311. backgroundTD.setTextSize(0, 640);
      312. backgroundTD.setSelectable(false);
      313. topBarBackgroundTD = Textdraw.create(320, 177);
      314. topBarBackgroundTD.setText("_");
      315. topBarBackgroundTD.setAlignment(TextDrawAlign.CENTER);
      316. topBarBackgroundTD.setBackgroundColor(Color.BLACK);
      317. topBarBackgroundTD.setFont(TextDrawFont.get(1));
      318. topBarBackgroundTD.setLetterSize(0.5f, -0.3f);
      319. topBarBackgroundTD.setColor(Color.WHITE);
      320. topBarBackgroundTD.setOutlineSize(0);
      321. topBarBackgroundTD.setProportional(true);
      322. topBarBackgroundTD.setUseBox(true);
      323. topBarBackgroundTD.setBoxColor(barBackgroundColor);
      324. topBarBackgroundTD.setTextSize(0, 640);
      325. topBarBackgroundTD.setSelectable(false);
      326. bottomBarBackgroundTD = Textdraw.create(320, 267);
      327. bottomBarBackgroundTD.setText("_");
      328. bottomBarBackgroundTD.setAlignment(TextDrawAlign.CENTER);
      329. bottomBarBackgroundTD.setBackgroundColor(Color.BLACK);
      330. bottomBarBackgroundTD.setFont(TextDrawFont.get(1));
      331. bottomBarBackgroundTD.setLetterSize(0.5f, -0.3f);
      332. bottomBarBackgroundTD.setColor(Color.WHITE);
      333. bottomBarBackgroundTD.setOutlineSize(0);
      334. bottomBarBackgroundTD.setProportional(true);
      335. bottomBarBackgroundTD.setUseBox(true);
      336. bottomBarBackgroundTD.setBoxColor(barBackgroundColor);
      337. bottomBarBackgroundTD.setTextSize(0, 640);
      338. bottomBarBackgroundTD.setSelectable(false);
      339. topBarTD = Textdraw.create(320, 177);
      340. topBarTD.setText("_");
      341. topBarTD.setAlignment(TextDrawAlign.CENTER);
      342. topBarTD.setBackgroundColor(Color.BLACK);
      343. topBarTD.setFont(TextDrawFont.get(1));
      344. topBarTD.setLetterSize(0.5f, -0.3f);
      345. topBarTD.setColor(Color.WHITE);
      346. topBarTD.setOutlineSize(0);
      347. topBarTD.setProportional(true);
      348. topBarTD.setUseBox(true);
      349. topBarTD.setBoxColor(barColor);
      350. topBarTD.setTextSize(0, 640);
      351. topBarTD.setSelectable(false);
      352. bottomBarTD = Textdraw.create(320, 267);
      353. bottomBarTD.setText("_");
      354. bottomBarTD.setAlignment(TextDrawAlign.CENTER);
      355. bottomBarTD.setBackgroundColor(Color.BLACK);
      356. bottomBarTD.setFont(TextDrawFont.get(1));
      357. bottomBarTD.setLetterSize(0.5f, -0.3f);
      358. bottomBarTD.setColor(Color.WHITE);
      359. bottomBarTD.setOutlineSize(0);
      360. bottomBarTD.setProportional(true);
      361. bottomBarTD.setUseBox(true);
      362. bottomBarTD.setBoxColor(barColor);
      363. bottomBarTD.setTextSize(0, 640);
      364. bottomBarTD.setSelectable(false);
      365. textTD = Textdraw.create(320, 214);
      366. textTD.setText(text);
      367. textTD.setAlignment(TextDrawAlign.CENTER);
      368. textTD.setBackgroundColor(textBackgroundColor);
      369. textTD.setFont(TextDrawFont.get(2));
      370. textTD.setLetterSize(0.56f, 1.4f);
      371. textTD.setColor(textColor);
      372. textTD.setOutlineSize(1);
      373. textTD.setProportional(true);
      374. textTD.setUseBox(true);
      375. textTD.setBoxColor(new Color(0,0,0,0));
      376. textTD.setTextSize(89, 620);
      377. textTD.setSelectable(false);
      378. }
      379. /* (non-Javadoc)
      380. * @see net.gtaun.shoebill.object.Destroyable#destroy()
      381. */
      382. @Override
      383. public void destroy() {
      384. if(timer != null) {
      385. if(timer.isRunning())
      386. timer.stop();
      387. timer.destroy();
      388. timer = null;
      389. }
      390. hide();
      391. textTD.destroy();
      392. bottomBarTD.destroy();
      393. topBarTD.destroy();
      394. bottomBarBackgroundTD.destroy();
      395. topBarBackgroundTD.destroy();
      396. backgroundTD.destroy();
      397. textTD = bottomBarTD = topBarTD = backgroundTD = bottomBarBackgroundTD = topBarBackgroundTD = null;
      398. }
      399. /* (non-Javadoc)
      400. * @see net.gtaun.shoebill.object.Destroyable#isDestroyed()
      401. */
      402. @Override
      403. public boolean isDestroyed() {
      404. if(textTD != null
      405. || bottomBarTD != null
      406. || topBarTD != null
      407. || backgroundTD != null
      408. || bottomBarBackgroundTD != null
      409. || topBarBackgroundTD != null)
      410. return false;
      411. return true;
      412. }
      413. }
      Alles anzeigen

      Nutzung:
      Z.B. im PlayerLifeCycleObject registieren

      Java-Quellcode

      1. /**
      2. * @param gameTextTD the gameTextTD to set
      3. */
      4. public void setGameTextTD(GameTextTD gameTextTD) {
      5. if(this.gameTextTD != null && !this.gameTextTD.isDestroyed())
      6. this.gameTextTD.destroy();
      7. this.gameTextTD = gameTextTD;
      8. }
      9. /**
      10. * @return the gameTextTD
      11. */
      12. public GameTextTD getGameTextTD() {
      13. return gameTextTD;
      14. }
      Alles anzeigen

      und dann z.B. in einer Command Object diese Commands registrieren:

      Java-Quellcode

      1. @Command
      2. @CommandHelp("/gttd")
      3. public boolean gttd(Player player) {
      4. PlayerData playerPlayerData = EventSystem.getInstance().getPlayerLifecycleHolder().getObject(player, PlayerData.class);
      5. GameTextTD gameTextTD = new GameTextTD(player, "Static Textdraw");
      6. playerPlayerData.setGameTextTD(gameTextTD);
      7. gameTextTD.show();
      8. return true;
      9. }
      10. @Command
      11. @CommandHelp("/gttd [milliseconds]")
      12. public boolean gttd(Player player, int milliseconds) {
      13. PlayerData playerPlayerData = EventSystem.getInstance().getPlayerLifecycleHolder().getObject(player, PlayerData.class);
      14. GameTextTD gameTextTD = new GameTextTD(player, "Animated Textdraw", milliseconds, true);
      15. playerPlayerData.setGameTextTD(gameTextTD);
      16. gameTextTD.show();
      17. return true;
      18. }
      19. @Command
      20. @CommandHelp("/gttdt [milliseconds]")
      21. public boolean gttdt(Player player, int milliseconds) {
      22. PlayerData playerPlayerData = EventSystem.getInstance().getPlayerLifecycleHolder().getObject(player, PlayerData.class);
      23. GameTextTD gameTextTD = new GameTextTD(player, "Animated Textdraw with Transitions", milliseconds, true, true);
      24. playerPlayerData.setGameTextTD(gameTextTD);
      25. gameTextTD.show();
      26. return true;
      27. }
      28. @Command
      29. @CommandHelp("/gttdt [milliseconds] [transitionMilliseconds]")
      30. public boolean gttdt(Player player, int milliseconds, int transitionMilliseconds) {
      31. PlayerData playerPlayerData = EventSystem.getInstance().getPlayerLifecycleHolder().getObject(player, PlayerData.class);
      32. GameTextTD gameTextTD = new GameTextTD(player, "Animated Textdraw with Transitions", milliseconds, true, transitionMilliseconds);
      33. playerPlayerData.setGameTextTD(gameTextTD);
      34. gameTextTD.show();
      35. return true;
      36. }
      37. @Command
      38. @CommandHelp("/gttdhfalse")
      39. public boolean gttdhfalse(Player player) {
      40. PlayerData playerPlayerData = EventSystem.getInstance().getPlayerLifecycleHolder().getObject(player, PlayerData.class);
      41. if(playerPlayerData.getGameTextTD() != null)
      42. playerPlayerData.getGameTextTD().hide(false);
      43. return true;
      44. }
      45. @Command
      46. @CommandHelp("/gttdhtrue")
      47. public boolean gttdhtrue(Player player) {
      48. PlayerData playerPlayerData = EventSystem.getInstance().getPlayerLifecycleHolder().getObject(player, PlayerData.class);
      49. if(playerPlayerData.getGameTextTD() != null)
      50. playerPlayerData.getGameTextTD().hide(true);
      51. return true;
      52. }
      53. @Command
      54. @CommandHelp("/gttds")
      55. public boolean gttds(Player player) {
      56. PlayerData playerPlayerData = EventSystem.getInstance().getPlayerLifecycleHolder().getObject(player, PlayerData.class);
      57. if(playerPlayerData.getGameTextTD() != null)
      58. playerPlayerData.getGameTextTD().show();
      59. return true;
      60. }
      61. @Command
      62. @CommandHelp("/gttdh")
      63. public boolean gttdh(Player player) {
      64. player.sendMessage("/gttd - create, /gttdhfalse - hide, /gttdhtrue - hide, /gttds - show");
      65. player.sendMessage("/gttdh - help, /gttdstop - stop /gttdresume - resume, /gttdt - transitions");
      66. return true;
      67. }
      68. @Command
      69. @CommandHelp("/gttdstop")
      70. public boolean gttdstop(Player player) {
      71. PlayerData playerPlayerData = EventSystem.getInstance().getPlayerLifecycleHolder().getObject(player, PlayerData.class);
      72. if(playerPlayerData.getGameTextTD() != null && playerPlayerData.getGameTextTD().getTimer() != null)
      73. playerPlayerData.getGameTextTD().getTimer().stop();
      74. return true;
      75. }
      76. @Command
      77. @CommandHelp("/gttdresume")
      78. public boolean gttdresume(Player player) {
      79. PlayerData playerPlayerData = EventSystem.getInstance().getPlayerLifecycleHolder().getObject(player, PlayerData.class);
      80. if(playerPlayerData.getGameTextTD() != null && playerPlayerData.getGameTextTD().getTimer() != null)
      81. playerPlayerData.getGameTextTD().getTimer().start();
      82. return true;
      83. }
      Alles anzeigen
      //edit

      Converter (SAMP Map = Shoebill Map):
      Hier noch ein Converter, der SAMP Maps in ShoebillMaps ändert. Um diese Objekte dann alle zu nutzen, müsst ihr den Output in eine Methode wie zB
      public ArrayList<DynamicSampObject> getObjects() packen

      Java-Quellcode: SampDynamicObjectConverter2.java

      1. package me.alf21.converter;
      2. import java.io.BufferedReader;
      3. import java.io.File;
      4. import java.io.FileOutputStream;
      5. import java.io.FileReader;
      6. import java.io.PrintStream;
      7. public class SampDynamicObjectConverter2 {
      8. public static void main(String[] args) throws Exception {
      9. //loadObjectData("C:/Users/Username/Desktop/maps/dedust22.txt");
      10. //change the path to your file of SAMP Objects
      11. loadObjectData("C:/Users/Username/Desktop/maps/jail.txt");
      12. }
      13. public static void loadObjectData(String filename) throws Exception {
      14. PrintStream out = new PrintStream(new FileOutputStream(filename + "-converted.txt"));
      15. File file = new File(filename + "-converted.txt");
      16. if(file.exists()) {
      17. file.delete();
      18. file.createNewFile();
      19. }
      20. System.setOut(out);
      21. String str, lineText = "";
      22. try {
      23. File fl = new File(filename);
      24. if (fl.exists()) {
      25. BufferedReader br = new BufferedReader(new FileReader(fl));
      26. boolean bool = false;
      27. System.out.println("ArrayList<DynamicSampObject> tmpobjs = new ArrayList<DynamicSampObject>();");
      28. System.out.println("DynamicSampObject tmpobj;");
      29. while((lineText = br.readLine()) != null)
      30. {
      31. str = lineText.trim();
      32. if (str.matches("\\b.*CreateDynamicObject\\b.*")) {
      33. if(bool) System.out.println("tmpobjs.add(tmpobj);");
      34. bool = true;
      35. str = str.split("CreateDynamicObject\\(")[1];
      36. str = str.replaceAll("\\)\\;", "");
      37. String commentString;
      38. try {
      39. commentString = str.split("\\/\\/")[1];
      40. } catch(Exception e) {
      41. commentString = "...";
      42. }
      43. str = str.split("\\/\\/")[0];
      44. String[] parts = str.split("[,]");
      45. int modelId = Integer.parseInt(parts[0].trim());
      46. float x = Float.parseFloat(parts[1].trim());
      47. float y = Float.parseFloat(parts[2].trim());
      48. float z = Float.parseFloat(parts[3].trim());
      49. float rX = Float.parseFloat(parts[4].trim());
      50. float rY = Float.parseFloat(parts[5].trim());
      51. float rZ = Float.parseFloat(parts[6].trim());
      52. System.out.println("tmpobj = DynamicSampObject.create(" + modelId + ", " +
      53. x + "f, " +
      54. y + "f, " +
      55. z + "f, " +
      56. rX + "f, " +
      57. rY + "f, " +
      58. rZ + "f, " +
      59. "worldId, " +
      60. "interiorId, " +
      61. "streamDistance, " +
      62. "drawDistance" +
      63. "); //" + commentString);
      64. }
      65. else if (str.matches("\\b.*CreateObject\\b.*")) {
      66. if(bool) System.out.println("tmpobjs.add(tmpobj);");
      67. bool = true;
      68. str = str.split("CreateObject\\(")[1];
      69. str = str.replaceAll("\\)\\;", "");
      70. String commentString;
      71. try {
      72. commentString = str.split("\\/\\/")[1];
      73. } catch(Exception e) {
      74. commentString = "...";
      75. }
      76. str = str.split("\\/\\/")[0];
      77. String[] parts = str.split("[,]");
      78. int modelId = Integer.parseInt(parts[0].trim());
      79. float x = Float.parseFloat(parts[1].trim());
      80. float y = Float.parseFloat(parts[2].trim());
      81. float z = Float.parseFloat(parts[3].trim());
      82. float rX = Float.parseFloat(parts[4].trim());
      83. float rY = Float.parseFloat(parts[5].trim());
      84. float rZ = Float.parseFloat(parts[6].trim());
      85. System.out.println("DynamicSampObject tmpobj = DynamicSampObject.create(" + modelId + ", " +
      86. x + "f, " +
      87. y + "f, " +
      88. z + "f, " +
      89. rX + "f, " +
      90. rY + "f, " +
      91. rZ + "f, " +
      92. "worldId, " +
      93. "interiorId, " +
      94. "streamDistance, " +
      95. "drawDistance" +
      96. "); //" + commentString);
      97. }
      98. else if(str.matches("\\b.*SetDynamicObjectMaterial\\b.*")) {
      99. str = str.replaceAll("SetDynamicObjectMaterial\\(", "");
      100. str = str.replaceAll("\\)\\;", "");
      101. str = str.split("\\/\\/")[0];
      102. String[] parts = str.split("[,]");
      103. int materialIndex = Integer.parseInt(parts[1].trim());
      104. int modelId = Integer.parseInt(parts[2].trim());
      105. String txdname = parts[3].trim();
      106. String texturename = parts[4].trim();
      107. // java.awt.Color materialcolor = Color.parseColor(parts[5].trim()); TODO
      108. System.out.println("tmpobj.setObjectMaterial(" + materialIndex + ", " +
      109. modelId + ", " +
      110. txdname + ", " +
      111. texturename + ", " +
      112. "new Color(0)" + //TODO
      113. ");");
      114. /* ????
      115. int r = (argb)&0xFF;
      116. int g = (argb>>8)&0xFF;
      117. int b = (argb>>16)&0xFF;
      118. int a = (argb>>24)&0xFF;
      119. */
      120. }
      121. else {
      122. continue;
      123. }
      124. }
      125. System.out.println("tmpobjs.add(tmpobj);");
      126. System.out.println("return tmpobjs;");
      127. br.close();
      128. }
      129. } catch (Exception ex) {
      130. System.out.println("[Fehler] Verbindung zur Datei '"+filename+"' konnte nicht hergestellt werden!");
      131. ex.printStackTrace();
      132. }
      133. }
      134. }
      Alles anzeigen
      Bilder
      • Grand Theft Auto San Andreas Multiplayer-01-27-2016 17-48-47.jpg

        247,32 kB, 1.280×800, 45 mal angesehen
      • Grand Theft Auto San Andreas Multiplayer-01-27-2016 17-48-50.jpg

        231,04 kB, 1.280×800, 47 mal angesehen

      Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von Alf21 ()