Advertisement
Guest User

Seif

a guest
Sep 18th, 2008
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.75 KB | None | 0 0
  1. /*
  2.                                 Seifalk - Chatbox by Seif
  3.                                
  4.                  ����������������������������������������������������������������������������
  5.                     ADD THIS IN YOUR GAMEMODE IF YOU WANT TO FORBID PLAYERS USING COLORS
  6.             ��                                                                                  ��
  7.         ��                                                                                          ��
  8.     ��                                                                                                  ��
  9. ��                                                                                                          ��
  10.  
  11. public OnPlayerText(playerid, text[])
  12. {
  13.     new name[MAX_PLAYER_NAME];
  14.     GetPlayerName(playerid, name, sizeof(name));
  15.     new color = GetPlayerColor(playerid);
  16.     if (!IsPlayerAdmin(playerid))
  17.     {
  18.         for(new i = 0; i < strlen(text); i++)
  19.         {
  20.             if (text[i] == '~')
  21.             {
  22.                 if (text[i+1] == 'r' || text[i+1] == 'g' || text[i+1] == 'w' || text[i+1] == 'l' || text[i+1] == 'b' || text[i+1] == 'p' || text[i+1] == 'y' || text[i+1] == '>' || text[i+1] == '<')
  23.                 {
  24.                     if (text[i+2] == '~') return SendClientText(playerid, 0xFFFFFFFF, "SERVER: You can not color your text."), 0;
  25.                 }
  26.             }
  27.         }
  28.     }
  29.     format(text, 256, "%s: ~w~%s", name, text);
  30.     SendClientTextToAll(color, text);
  31.     return 0;
  32. }
  33. */
  34. /*x---------------------------------Important-------------------------------------x*/
  35. //**INCLUDES**//
  36. #include <a_samp>
  37. //**PRAGMAS**//
  38.  
  39. //**MISC**//
  40. //native SendClientText(playerid, color, text[]);
  41. //native SendClientTextToAll(color, text[]);
  42. //native Seifalk_OnPlayerConnect(playerid);
  43. //native Seifalk_OnPlayerDisconnect(playerid, reason);
  44. //native Seifalk_OnInit();
  45. //native Seifalk_OnExit();
  46. //native Seifalk_ClearSAMPChat()
  47. /*x---------------------------------Defining-------------------------------------x*/
  48. //**COLORS*//
  49. /*#define GREEN             0x21DD00FF
  50. #define RED             0xE60000FF
  51. #define ADMIN_RED       0xFB0000FF
  52. #define YELLOW          0xFFFF00FF
  53. #define ORANGE          0xF97804FF
  54. #define LIGHTRED        0xFF8080FF
  55. #define LIGHTBLUE       0x00C2ECFF
  56. #define PURPLE          0xB360FDFF
  57. #define PLAYER_COLOR    0xFFFFFFFF
  58. #define BLUE            0x1229FAFF
  59. #define LIGHTGREEN      0x38FF06FF
  60. #define DARKPINK        0xE100E1FF
  61. #define DARKGREEN       0x008040FF
  62. #define ANNOUNCEMENT    0x6AF7E1FF
  63. #define COLOR_SYSTEM    0xEFEFF7AA
  64. #define GREY            0xCECECEFF
  65. #define PINK            0xD52DFFFF
  66. #define DARKGREY        0x626262FF
  67. #define AQUAGREEN       0x03D687FF
  68. #define NICESKY         0x99FFFFAA
  69. #define WHITE           0xFFFFFFFF*/
  70. //**MISC**//
  71. #define MAX_TEXTS                   20
  72. #define MAX_ERASED_SAMPMESSAGES     10
  73. //**VARIABLES**//
  74. new TextInBox[MAX_PLAYERS][MAX_TEXTS][256];
  75. new TextColor[MAX_TEXTS];
  76. new Text:TextdrawInBox[MAX_PLAYERS][MAX_TEXTS];
  77. new Float:ChatBoxX = 16.000000;
  78. new Float:ChatBoxY = 120.000000;
  79. // **FORWARDS** //
  80. forward Seifalk_ClearSAMPChat();
  81. forward Seifalk_MakeChatBox(id, Float:x, Float:y);
  82. forward Seifalk_OnInit();
  83. forward Seifalk_OnExit();
  84. forward Seifalk_OnPlayerConnect(playerid);
  85. forward Seifalk_OnPlayerDisconnect(playerid, reason);
  86. /*x---------------------------------CallBacks-------------------------------------x*/
  87. public Seifalk_OnPlayerConnect(playerid)
  88. {
  89.     Seifalk_ClearSAMPChat();
  90.     for(new i = 0; i < MAX_TEXTS; i++) SendClientText(playerid, 0xFFFFFFFF, " ");
  91.     for(new i = 0; i < MAX_TEXTS; i++) TextDrawShowForPlayer(playerid, TextdrawInBox[playerid][i]);
  92.     return 1;
  93. }
  94.  
  95. public Seifalk_OnPlayerDisconnect(playerid, reason)
  96. {
  97.     for(new i = 0; i < MAX_TEXTS; i++) TextDrawHideForPlayer(playerid, TextdrawInBox[playerid][i]);
  98.     return 1;
  99. }
  100.  
  101. public Seifalk_OnInit()
  102. {
  103.     for(new i = 0; i < MAX_TEXTS; i++)
  104.     {
  105.         Seifalk_MakeChatBox(i, ChatBoxX, ChatBoxY);
  106.         ChatBoxY -= 6.000000;
  107.         //printf("%f",ChatBoxY);
  108.     }
  109.    
  110.     SetTimer("Seifalk_ClearSAMPChat",60000, 1);
  111. }
  112.  
  113. public Seifalk_OnExit()
  114. {
  115.     for(new p = 0; p < MAX_PLAYERS; p++)
  116.     {
  117.         for(new i = 0; i < MAX_TEXTS; i++) TextDrawDestroy(TextdrawInBox[p][i]);
  118.     }
  119. }
  120.  
  121. public Seifalk_ClearSAMPChat()
  122. {
  123.     for(new i = 0; i < MAX_ERASED_SAMPMESSAGES; i++) SendClientMessageToAll(0xFFFFFFFF, " ");
  124. }
  125.  
  126. public Seifalk_MakeChatBox(id, Float:x, Float:y)
  127. {
  128.     for(new playerid = 0; playerid < GetMaxPlayers(); playerid++)
  129.     {
  130.         TextdrawInBox[playerid][id] = TextDrawCreate(x, y, " ");
  131.         TextDrawUseBox(TextdrawInBox[playerid][id],0);
  132.         TextDrawBoxColor(TextdrawInBox[playerid][id],0x000000ff);
  133.         TextDrawTextSize(TextdrawInBox[playerid][id],612.000000,-150.000000);
  134.         TextDrawAlignment(TextdrawInBox[playerid][id],0);
  135.         TextDrawBackgroundColor(TextdrawInBox[playerid][id],0x000000ff);
  136.         TextDrawFont(TextdrawInBox[playerid][id],1);
  137.         TextDrawLetterSize(TextdrawInBox[playerid][id],0.250000,0.750000);
  138.         TextDrawColor(TextdrawInBox[playerid][id],0xFFFFFFFF);
  139.         TextDrawSetOutline(TextdrawInBox[playerid][id],1);
  140.         TextDrawSetProportional(TextdrawInBox[playerid][id],1);
  141.         TextDrawSetShadow(TextdrawInBox[playerid][id],1);
  142.  
  143.         TextColor[id] = 0xFFFFFFFF;
  144.         strmid(TextInBox[playerid][id], " ", 0, strlen(" "), 128);
  145.     }
  146. }
  147.  
  148. stock SendClientText(playerid, color, text[])
  149. {
  150.     for(new t = MAX_TEXTS-1; t > 0; t--)
  151.     {
  152.         TextDrawSetString(TextdrawInBox[playerid][t], TextInBox[playerid][t-1]);
  153.         strmid(TextInBox[playerid][t], TextInBox[playerid][t-1], 0, strlen(TextInBox[playerid][t-1]), 128);
  154.         TextColor[t] = TextColor[t-1];
  155.         TextDrawColor(TextdrawInBox[playerid][t], TextColor[t]);
  156.         TextDrawShowForPlayer(playerid, TextdrawInBox[playerid][t]);
  157.     }
  158.     TextDrawColor(TextdrawInBox[playerid][0], color);
  159.     TextDrawSetString(TextdrawInBox[playerid][0], text);
  160.     strmid(TextInBox[playerid][0], text, 0, strlen(text), 128);
  161.     TextColor[0] = color;
  162.     TextDrawShowForPlayer(playerid, TextdrawInBox[playerid][0]);
  163.     return 1;
  164. }
  165.  
  166. stock SendClientTextToAll(color, text[])
  167. {
  168.     for(new i = 0; i < MAX_PLAYERS; i++)
  169.     {
  170.         if (IsPlayerConnected(i)) SendClientText(i, color, text);
  171.     }
  172. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement