Biesmen

SDMessage 1.1

Nov 10th, 2011
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.28 KB | None | 0 0
  1. //=========================================================================//
  2. //* SendDialogMessage
  3. //* Version: 1.1
  4. //=========================================================================//
  5. //* Created by:
  6. //* Biesmen
  7. //* Reconnect technique thought by JernejL
  8. //* Making the Kick and BanEx function work without modifying the script by:
  9. //* KoczkaHUN
  10. //=========================================================================//
  11. //* How-To-Use:
  12. //              SendDialogMessage(playerid, message);
  13. //              Kick(playerid, reason);
  14. //              Ban(playerid); - Normal
  15. //              BanEx(playerid); - Normal
  16. //              Reconnect(playerid, reason);
  17. //              ToggleDialogMessage(type, true/false); - Toggle the dialog
  18. //                                                       messages.
  19. //              Types:
  20. //                      Kick, Ban, BanEx, Reconnect
  21. //=========================================================================//
  22. #include <a_samp>
  23.  
  24. new PlayerIP[MAX_PLAYERS][16];
  25. new pReconnect[MAX_PLAYERS];
  26. new Activate[4];
  27.  
  28. ToggleDialogMessage(type[], bool:tf)
  29. {
  30.     if(strcmp(type, "Kick", true) == 0)
  31.     {
  32.         if(tf == true)
  33.         {
  34.             Activate[0] = 0;
  35.         }
  36.         else
  37.         if(tf == false)
  38.         {
  39.             Activate[0] = 1;
  40.         }
  41.     }
  42.     else if(strcmp(type, "Ban", true) == 0)
  43.     {
  44.         if(tf == true)
  45.         {
  46.             Activate[1] = 0;
  47.         }
  48.         else
  49.         if(tf == false)
  50.         {
  51.             Activate[1] = 1;
  52.         }
  53.     }
  54.     else if(strcmp(type, "BanEx", true) == 0)
  55.     {
  56.         if(tf == true)
  57.         {
  58.             Activate[2] = 0;
  59.         }
  60.         else
  61.         if(tf == false)
  62.         {
  63.             Activate[2] = 1;
  64.         }
  65.     }
  66.     else if(strcmp(type, "Reconnect", true) == 0)
  67.     {
  68.         if(tf == true)
  69.         {
  70.             Activate[3] = 0;
  71.         }
  72.         else
  73.         if(tf == false)
  74.         {
  75.             Activate[3] = 1;
  76.         }
  77.     }
  78.     else
  79.     {
  80.         printf("ERROR: SendDialogMessage: Type %s is an unkown type.", type);
  81.     }
  82.     return 1;
  83. }
  84.  
  85. stock SendDialogMessage(playerid, message[])
  86. {
  87.     ShowPlayerDialog(playerid, 8743, DIALOG_STYLE_MSGBOX, "SERVER MESSAGE", message, "Close", "");
  88.     return 1;
  89. }
  90.  
  91. KickEx(playerid, reason[]="")
  92. {
  93.     new res[128];
  94.     if(Activate[0] == 0)
  95.     {
  96.         if(strlen(reason) == 0)
  97.         {
  98.             SendDialogMessage(playerid, "You got kicked by the server.");
  99.         }
  100.         else
  101.         {
  102.            format(res, sizeof(res), "You got kicked by the server for: %s", reason);
  103.            SendDialogMessage(playerid, res);
  104.         }
  105.     }
  106.     Kick(playerid);
  107. }
  108. #if defined _ALS_Kick
  109.     #undef Kick
  110. #else
  111.     #define _ALS_Kick
  112. #endif
  113. #define Kick KickEx
  114.  
  115. BanNormal(playerid)
  116. {
  117.     if(Activate[1] == 1)
  118.     {
  119.         SendDialogMessage(playerid, "You got banned by the server.");
  120.     }
  121.     Ban(playerid);
  122. }
  123. #if defined _ALS_Ban
  124.     #undef Ban
  125. #else
  126.     #define _ALS_Ban
  127. #endif
  128. #define Ban BanNormal
  129.  
  130. BanEx2(playerid, reason[], name[]="")
  131. {
  132.     new res[128];
  133.     if(Activate[2] == 0)
  134.     {
  135.         if(strlen(name) == 0)
  136.         {
  137.             format(res, sizeof(res), "You got banned by the server for: %s", reason);
  138.         }
  139.         else
  140.         {
  141.             format(res, sizeof(res), "You got banned by admin: %s for: %s", name, reason);
  142.         }
  143.         SendDialogMessage(playerid, res);
  144.     }
  145.     BanEx(playerid, reason);
  146. }
  147.  
  148. #if defined _ALS_BanEx
  149.     #undef BanEx
  150. #else
  151.     #define _ALS_BanEx
  152. #endif
  153. #define BanEx BanEx2
  154.  
  155. Reconnect(playerid, reason[]="")
  156. {
  157.     new bip[128];
  158.     GetPlayerIp(playerid, PlayerIP[playerid], 16);
  159.     if(Activate[3] == 0)
  160.     {
  161.         if(strlen(reason) == 0)
  162.         {
  163.            format(bip, 44, "You got forced to reconnect by the server.");
  164.         }
  165.         else
  166.         {
  167.             format(bip, 200, "You got forced to reconnect by the server for: %s", reason);
  168.         }
  169.         SendDialogMessage(playerid, bip);
  170.     }
  171.     pReconnect[playerid] = 1;
  172.     TogglePlayerControllable(playerid, false);
  173.     format(bip, sizeof(bip), "banip %s", PlayerIP[playerid]);
  174.     SendRconCommand(bip);
  175.     return 1;
  176. }
  177.  
  178. public OnPlayerDisconnect(playerid, reason)
  179. {
  180.     new unban[30];
  181.     if(pReconnect[playerid] == 1)
  182.     {
  183.         format(unban, sizeof(unban), "unbanip %s", PlayerIP[playerid]);
  184.         SendRconCommand(unban);
  185.         pReconnect[playerid] = 0;
  186.         TogglePlayerControllable(playerid, true);
  187.     }
  188.     return (funcidx("ALSOnPlayerDisconnect") != 1)?CallLocalFunction("ALSOnPlayerDisconnect",""):1;
  189. }
  190. #if defined _ALS_OnPlayerDisconnect
  191.     #undef OnPlayerDisconnect
  192. #else
  193.     #define _ALS_OnPlayerDisconnect
  194. #endif
  195. #define OnPlayerDisconnect ALSOnPlayerDisconnect
  196. forward ALSOnPlayerDisconnect(playerid, reason);
Advertisement
Add Comment
Please, Sign In to add comment