Advertisement
Biesmen

SDMessage 1.0 [OUTDATED]

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