Advertisement
HoussamMaroc

HMMSG.inc

Aug 14th, 2017
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include a_samp
  2. #include foreach
  3.  
  4. #pragma dynamic 99999999999
  5.  
  6.  
  7. #define AddSymbol(%0); new %0;
  8. #define iLoop(%0) for(new i; i<%0; i++)
  9. #define CheckAllPlayers() foreach(new i:Player)
  10. #define AutoPub:%0(%1)  forward %0(%1);\
  11.                         public %0(%1)
  12.  
  13.  
  14. AddSymbol(PlayerText:HMMSG[ MAX_PLAYERS ],Showed[ MAX_PLAYERS ],TimerEx[ MAX_PLAYERS ]);
  15. /*                                                                */
  16. //-----------------------------------------------------------------|
  17. //|____________________Natives_____________________________________|
  18. //|                                                                |
  19. //|    native GameHMTextShowForPlayer(playerid,text[],time = 3000);|
  20. //|    native GameHMTextShowForAll(text[], time = 3000);                           |
  21. //|________________________________________________________________|
  22. //-----------------------------------------------------------------|
  23. /*                                                                */
  24.  
  25. static stock AutoReturn(input[])
  26. {
  27.     if(strlen(input) > 18)
  28.     {
  29.         for(new i = 18, j = strlen(input); i < j; i += 19, j ++)
  30.         {
  31.             strins(input, "~n~", i, i);
  32.         }
  33.     }
  34.     return 1;
  35. }
  36.  
  37. stock GameHMTextShowForPlayer(playerid,text[],time = 3000)
  38. {
  39.     if(Showed[playerid]) return 1;
  40.     AutoReturn(text);
  41.     Showed[playerid] = true;
  42.     PlayerTextDrawSetString(playerid, HMMSG[playerid], text);
  43.     ShowMsgTextForPlayer(playerid);
  44.     SetTimerEx("HideMSGText",time,false,"d",playerid);
  45.     TimerEx[playerid] = SetTimerEx("HideMSGBar",1,true,"d",playerid);
  46.     return 1;
  47. }
  48.  
  49. stock GameHMTextShowForAll(text[], time = 3000)
  50. {
  51.     CheckAllPlayers()
  52.     {
  53.         GameHMTextShowForPlayer(i, text, time);
  54.     }
  55.     return 1;
  56. }
  57.  
  58. stock CreateMSG(playerid)
  59. {
  60.     HMMSG[playerid] = CreatePlayerTextDraw(playerid, 4.000000, 4.479990, "");
  61.     PlayerTextDrawLetterSize(playerid, HMMSG[playerid], 0.294999, 1.135197);
  62.     PlayerTextDrawTextSize(playerid, HMMSG[playerid], 131.500000, -44.240024);
  63.     PlayerTextDrawAlignment(playerid, HMMSG[playerid], 1);
  64.     PlayerTextDrawColor(playerid, HMMSG[playerid], -1);
  65.     PlayerTextDrawUseBox(playerid, HMMSG[playerid], true);
  66.     PlayerTextDrawBoxColor(playerid, HMMSG[playerid], 75);
  67.     PlayerTextDrawSetShadow(playerid, HMMSG[playerid], 0);
  68.     PlayerTextDrawSetOutline(playerid, HMMSG[playerid], 1);
  69.     PlayerTextDrawBackgroundColor(playerid, HMMSG[playerid], 255);
  70.     PlayerTextDrawFont(playerid, HMMSG[playerid], 1);
  71.     PlayerTextDrawSetProportional(playerid, HMMSG[playerid], 1);
  72.     return 1;
  73. }
  74.  
  75. stock DestroyMSG(playerid)
  76. {
  77.     iLoop(1)
  78.     {
  79.         PlayerTextDrawDestroy(playerid,HMMSG[playerid]);
  80.     }
  81. }
  82.  
  83. stock ShowMsgTextForPlayer(playerid)
  84. {
  85.     iLoop(1)
  86.     {
  87.         PlayerTextDrawShow(playerid,HMMSG[playerid]);
  88.     }
  89. }
  90.  
  91. stock HideMsgTextForPlayer(playerid)
  92. {
  93.     iLoop(1)
  94.     {
  95.         PlayerTextDrawHide(playerid,HMMSG[playerid]);
  96.     }
  97. }
  98.  
  99.  
  100. AutoPub:HideMSGBar(playerid)
  101. {
  102.     iLoop(100)
  103.     {
  104.         SendClientMessage(playerid, -1, "");
  105.         return 1;
  106.     }
  107.     KillTimer(TimerEx[playerid]);
  108.     return 1;
  109. }
  110.  
  111. AutoPub:HideMSGText(playerid)
  112. {
  113.     Showed[playerid] = false;
  114.     HideMsgTextForPlayer(playerid);
  115.     return 1;
  116. }
  117.  
  118.  
  119. public OnPlayerConnect(playerid)
  120. {
  121.     CreateMSG(playerid);
  122.     if(funcidx("HMMSG_OnPlayerConnect") != -1)
  123.     {
  124.         return CallLocalFunction("HMMSG_OnPlayerConnect", "i", playerid);
  125.     }
  126.     return 1;
  127. }
  128.  
  129. public OnPlayerDisconnect(playerid,reason)
  130. {
  131.     DestroyMSG(playerid);
  132.     if(funcidx("HMMSG_OnPlayerDisconnect") != -1)
  133.     {
  134.         return CallLocalFunction("HMMSG_OnPlayerDisconnect", "i", playerid);
  135.     }return 1;
  136. }
  137.  
  138. #if defined _ALS_OnPlayerConnect
  139.     #undef OnPlayerConnect
  140. #else
  141.     #define _ALS_OnPlayerConnect
  142. #endif
  143. #define OnPlayerConnect HMMSG_OnPlayerConnect
  144. #if defined _ALS_OnPlayerDisconnect
  145.     #undef OnPlayerDisconnect
  146. #else
  147.     #define _ALS_OnPlayerDisconnect
  148. #endif
  149. #define OnPlayerDisconnect HMMSG_OnPlayerDisconnect
  150. forward HMMSG_OnPlayerConnect(playerid);
  151. forward HMMSG_OnPlayerDisconnect(playerid,reason);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement