Zmajk0

Untitled

Sep 29th, 2019
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Alternative chat
  3. Author: Xunder
  4.  
  5. * Functions:
  6. native sendAltChatMessage(playerid, message[]);
  7. - Salje poruku igracu
  8. - Return 1 (uspjesno) : 0 (nije prikazan alt-chat/ne salje poruku)
  9.  
  10. native createAltChat(playerid);
  11. - Kreira textdrawove za igraca
  12. - Return: 1 (uspjesno)
  13.  
  14. native destroyAltChat(playerid);
  15. - Unistava textdrawove za igraca
  16. - Return: 1 (uspjesno)
  17.  
  18. native toggleAltChat(playerid, bool: toggle = true);
  19. - Prikazuje/brise textdrawove za igraca
  20. - Return: 1 (uspjesno)
  21.  
  22. native resetAltChat(playerid);
  23. - "Brise" svaki red u chatu
  24. - Return: 1 (uspjesno)
  25.  
  26. native isAltChatToggled(playerid);
  27. - Dobijate povratnu informaciju da li je chat prikazan
  28. - Return: 1 (prikazan) : 0 (nije prikazan)
  29.  
  30. v1.1
  31. * Promijenjena hook metoda
  32. v1.2
  33. * Nove funkcije za dodatno manipulisanje
  34. */
  35. #if !defined _samp_included
  36. #error include a_samp first
  37. #endif
  38.  
  39. #if !defined MAX_LINES
  40. #define MAX_LINES 10
  41. #endif
  42.  
  43. new PlayerText: AltChatTD_Player[MAX_LINES],
  44. AltChatTD_Text[MAX_PLAYERS][MAX_LINES][128],
  45. altchatToggled[MAX_PLAYERS] = false;
  46.  
  47. stock sendAltChatMessage(playerid, message[]) {
  48. if (!altchatToggled[playerid])
  49. return 0;
  50.  
  51. for(new i = 0; i < MAX_LINES; i ++) {
  52. if (i == MAX_LINES - 1) {
  53. strmid(AltChatTD_Text[playerid][i], message, 0, 128);
  54. break;
  55. }
  56. strmid(AltChatTD_Text[playerid][i], AltChatTD_Text[playerid][i + 1], 0, 128);
  57. }
  58.  
  59. for(new i = 0; i < MAX_LINES; i ++) {
  60. PlayerTextDrawSetString(playerid, AltChatTD_Player[i], AltChatTD_Text[playerid][i]);
  61. }
  62. return 1;
  63. }
  64.  
  65. stock createAltChat(playerid) {
  66. new Float: AltChat_posY = 229.573348;
  67.  
  68. for(new i = 0; i < MAX_LINES; i ++) {
  69. AltChatTD_Player[i] = CreatePlayerTextDraw(playerid, 35.599971, AltChat_posY, " ");
  70. PlayerTextDrawLetterSize(playerid, AltChatTD_Player[i], 0.21, 0.9);
  71. PlayerTextDrawAlignment(playerid, AltChatTD_Player[i], 1);
  72. PlayerTextDrawColor(playerid, AltChatTD_Player[i], -1);
  73. PlayerTextDrawSetOutline(playerid, AltChatTD_Player[i], 1);
  74. PlayerTextDrawBackgroundColor(playerid, AltChatTD_Player[i], 255);
  75. PlayerTextDrawFont(playerid, AltChatTD_Player[i], 1);
  76. PlayerTextDrawSetProportional(playerid, AltChatTD_Player[i], 1);
  77.  
  78. AltChat_posY += (240.026733 - 229.573348);
  79. }
  80.  
  81. altchatToggled[playerid] = false;
  82.  
  83. return 1;
  84. }
  85.  
  86. stock destroyAltChat(playerid) {
  87. for(new i = 0; i < MAX_LINES; i ++) {
  88. PlayerTextDrawDestroy(playerid, AltChatTD_Player[i]);
  89. AltChatTD_Player[i] = INVALID_TEXT_DRAW;
  90. }
  91.  
  92. altchatToggled[playerid] = false;
  93.  
  94. return 1;
  95. }
  96.  
  97. stock resetAltChat(playerid) {
  98. for(new i = 0; i < MAX_LINES; i ++) {
  99. strmid(AltChatTD_Text[playerid][i], " ", 0, 2, 2);
  100. if (_: AltChatTD_Player[i] != INVALID_TEXT_DRAW) PlayerTextDrawSetString(playerid, AltChatTD_Player[i], " ");
  101. }
  102.  
  103. return 1;
  104. }
  105.  
  106. stock toggleAltChat(playerid, bool: toggle = true) {
  107. if (toggle) for(new i = 0; i < MAX_LINES; i ++) PlayerTextDrawShow(playerid, AltChatTD_Player[i]);
  108. else for(new i = 0; i < MAX_LINES; i ++) PlayerTextDrawHide(playerid, AltChatTD_Player[i]);
  109.  
  110. altchatToggled[playerid] = toggle;
  111. return 1;
  112. }
  113.  
  114. stock isAltChatToggled(playerid) {
  115. if (altchatToggled[playerid]) return 1;
  116. return 0;
  117. }
RAW Paste Data