Advertisement
Sants101100

PAWN WhiteList

Sep 13th, 2022 (edited)
3,123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.38 KB | None | 0 0
  1. /*
  2.     * @file                     whitelist.pwn
  3.     * @author                   sants
  4.     * @date                     9/13/2022 at 23:20
  5.     * @version                  Version 1.0.0
  6.     * @codedin                  23 minutes
  7. */
  8.  
  9.  
  10. #define FILTERSCRIPT
  11.  
  12. #include <a_samp>
  13. #include <DOF2>
  14. #include <zcmd>
  15. #include <sscanf2>
  16.  
  17. #define PASTAWLIP "WLIP/%s.ini"
  18. #define PASTAWLNICK "WLNICK/%s.ini"
  19.  
  20. #if defined FILTERSCRIPT
  21.  
  22. new path[50], wlmsg[120];
  23.  
  24. public OnFilterScriptInit()
  25. {
  26.     print("\n--------------------------------------");
  27.     print(" [WhiteList 1.0 by Sants]");
  28.     print("--------------------------------------\n");
  29.     return 1;
  30. }
  31.  
  32. public OnFilterScriptExit()
  33. {
  34.     DOF2_Exit();
  35.     return 1;
  36. }
  37.  
  38. public OnPlayerConnect(playerid)
  39. {
  40.     if(!IsPlayerWListed(playerid)) {
  41.         SendClientMessage(playerid, -1, "[WL] Você não está em nossa WL, favor entre em contato com a administração");
  42.         SetTimerEx("KickPlayer", 2000, 0, "i", playerid);
  43.     } else {
  44.         SendClientMessage(playerid, -1, "[WL] WhitList confirmada! Bem vindo ao nosso servidor");
  45.  
  46.     }
  47.     return 1;
  48. }
  49.  
  50.  
  51. CMD:addwlip(playerid, params[]) {
  52.     new ip[17];
  53.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "(ERRO) Você não tem permissão");
  54.     else {
  55.         if(!sscanf(params, "s[17]", ip)) {
  56.             format(path, sizeof(path), PASTAWLIP, ip);
  57.             if(DOF2_FileExists(path)) return SendClientMessage(playerid, -1, "(ERRO) IP já consta na WL");
  58.             else {
  59.                 DOF2_CreateFile(path);
  60.                 DOF2_SaveFile();
  61.                 format(wlmsg, sizeof(wlmsg), "[WL] Você adicionou o IP [%s] a WhiteList", ip);
  62.                 SendClientMessage(playerid, -1, wlmsg);
  63.             }
  64.         } else return SendClientMessage(playerid, -1, "(ERRO) Uso: /addwlip [IP]");
  65.     }
  66.     return 1;
  67. }
  68.  
  69. CMD:addwlnick(playerid, params[]) {
  70.     new nick[MAX_PLAYER_NAME];
  71.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "(ERRO) Você não tem permissão");
  72.     else {
  73.         if(!sscanf(params, "s[26]", nick)) {
  74.             format(path, sizeof(path), PASTAWLNICK, nick);
  75.             if(DOF2_FileExists(path)) return SendClientMessage(playerid, -1, "(ERRO) Este nick já consta na WL");
  76.             else {
  77.                 DOF2_CreateFile(path);
  78.                 DOF2_SaveFile();
  79.                 format(wlmsg, sizeof(wlmsg), "[WL] Você adicionou o nick [%s] a WhiteList", nick);
  80.                 SendClientMessage(playerid, -1, wlmsg);
  81.             }
  82.         } else return SendClientMessage(playerid, -1, "(ERRO) Uso: /addwlnick [NICK]");
  83.     }
  84.     return 1;
  85. }
  86.  
  87. CMD:remwlip(playerid, params[]) {
  88.     new ip[17];
  89.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "(ERRO) Você não tem permissão");
  90.     else {
  91.         if(!sscanf(params, "s[17]", ip)) {
  92.             format(path, sizeof(path), PASTAWLIP, ip);
  93.             if(!DOF2_FileExists(path)) return SendClientMessage(playerid, -1, "(ERRO) IP não conta na WL");
  94.             else {
  95.                 DOF2_RemoveFile(path);
  96.                 format(wlmsg, sizeof(wlmsg), "[WL] Você removeu o IP [%s] da WhiteList", ip);
  97.                 SendClientMessage(playerid, -1, wlmsg);
  98.             }
  99.         } else return SendClientMessage(playerid, -1, "(ERRO) Uso: /remwlip [IP]");
  100.     }
  101.     return 1;
  102. }
  103.  
  104. CMD:remwlnick(playerid, params[]) {
  105.     new nick[MAX_PLAYER_NAME];
  106.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "(ERRO) Você não tem permissão");
  107.     else {
  108.         if(!sscanf(params, "s[26]", nick)) {
  109.             format(path, sizeof(path), PASTAWLNICK, nick);
  110.             if(!DOF2_FileExists(path)) return SendClientMessage(playerid, -1, "(ERRO) Nick não conta na WL");
  111.             else {
  112.                 DOF2_RemoveFile(path);
  113.                 format(wlmsg, sizeof(wlmsg), "[WL] Você removeu o NICK [%s] da WhiteList", nick);
  114.                 SendClientMessage(playerid, -1, wlmsg);
  115.             }
  116.         } else return SendClientMessage(playerid, -1, "(ERRO) Uso: /remwlip [NICK]");
  117.     }
  118.     return 1;
  119. }
  120.  
  121. IsPlayerWListed(playerid) {
  122.     format(path, sizeof(path), PASTAWLIP, GetPlayerIpEx(playerid));
  123.     if(DOF2_FileExists(path)) return 1;
  124.     else {
  125.         format(path, sizeof(path), PASTAWLNICK, GetPlayerNick(playerid));
  126.         if(DOF2_FileExists(path)) return 1;
  127.     }
  128.     return 0;
  129. }
  130.  
  131. GetPlayerNick(playerid) {
  132.     new nick[MAX_PLAYER_NAME];
  133.     GetPlayerName(playerid, nick, sizeof(nick));
  134.     return nick;
  135. }
  136.  
  137. GetPlayerIpEx(playerid) {
  138.     new ip[17];
  139.     GetPlayerIp(playerid, ip, sizeof(ip));
  140.     return ip;
  141. }
  142.  
  143. stock UpdateWLNick(oldnick, nick) {
  144.     format(path, sizeof(path), PASTAWLNICK, nick);
  145.     DOF2_CreateFile(path);
  146.     DOF2_SaveFile();
  147.     format(path, sizeof(path), PASTAWLNICK, oldnick);
  148.     DOF2_RemoveFile(path);
  149.  
  150.     return 1;
  151. }
  152.  
  153. stock KickPlayer(playerid) {
  154.     Kick(playerid);
  155. }
  156.  
  157. #endif
Tags: whitelist pawn
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement