AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   WhiteList Script (https://forums.alliedmods.net/showthread.php?t=214321)

Crizzatu 04-25-2013 12:39

WhiteList Script
 
How can create WHITELIST for this Plugin ?

Plugin is for NAME RESTRICTION [ Names Console Ex: [ ` ] and [ ~ ] etc... ]
I want the name that is put in whitelist the player can enter the server to not kick

Code:

#include <amxmodx>
#include <amxmisc>
#include <colorchat>

static const PLUGIN[] = "Name Changer & Restriction";
static const VERSION[] = "1.0";
static const AUTHOR[] = "Mata";

static const Motiv[] = "Nu poti intra!! Ai in componenta numelui: [ ~ ] sau [ ` ]";

#define MAX_WORDS 128

new PluginOn, TimeS, Sync, TimeR;
new Check[33];
new ListNames[MAX_WORDS][32], Num;
new CvarMode, CvarMin, NameChange;

public plugin_init()
{
  register_plugin(PLUGIN, VERSION, AUTHOR)
 
  // Cvars
  PluginOn = register_cvar("NameCR_On","1"); // Plugin 1= pornit / 2= oprit
  TimeR = register_cvar("NameCR_Time","1"); // Timpul in cat da afara un jucator daca nu schimba numele / default 10 sec
  CvarMode = register_cvar("NameCR_Mode","2"); // Modul in care il obligati pe jucator / 0= schimba numele, 1= slay, 2= kick, 3= ban pe ip
  CvarMin = register_cvar("NameCR_TimeBan","10"); // cate minute ii dati ban daca NameCR_Mode este 3.
     
  NameChange = register_cvar("NameCR_ChangeName","Baka"); // schimbi numele jucatorului.
     
  Sync = CreateHudSyncObj();
 
  // Event
  register_event("RoundTime", "StartCheckAfterRound", "b")
  register_event("SendAudio", "EndRound", "b", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw")
}


public plugin_cfg()
{
 
  static Dir[64], File[64], i = 0, len;
 
  get_configsdir(Dir, sizeof Dir - 1);
 
  formatex(File, sizeof File - 1, "%s/Name_Restriction.cfg",Dir); 
  server_cmd("exec %s", File);
 
  if(!file_exists(File))
  {
      console_print(0, "****** Fisierul ^"%s^" nu exista.... ******", File)
      return;
  }
 
  while(read_file(File, i++, ListNames[Num],sizeof File -1,len))
      if(len)
        ++Num;
 
  console_print(0, "****** Numarul de Cuvinte incarcate sunt %d.... ******", Num)
 
}

public client_connect(id)
{
  set_task(1.0,"CheckPlayer",id);
  Check[id] = 1;
}

public StartCheckAfterRound(id)
{
  set_task(3.0,"CheckPlayer",id,_,_,"a",1);
  Check[id] = 1;
}
 
public client_disconnect(id)
{
  Check[id] = 0;
  remove_task(id);
}

public EndRound(id)
{
  Check[id] = 0;
  remove_task(id);
}
 
 
public client_infochanged(id)
{
  if(is_user_connected(id))
  {
      set_task(1.0,"CheckPlayer",id);
      Check[id] = 1;
  }
  return PLUGIN_HANDLED;
}

 
public CheckPlayer(id)
{
  if(!(get_pcvar_num(PluginOn) == 1))
      return PLUGIN_HANDLED;

  static Name[32];
 
  new Id = get_user_userid(id);
 
  TimeS = get_pcvar_num(TimeR);
 
  get_user_name(id, Name, sizeof Name -1);
           
  for(new i = 0 ;i < Num; i++)
  {
      if(containi(Name, ListNames[i]) != -1)
      {
        if(is_user_connecting(id))
        {
            server_cmd("kick #%d ^"%s^"",Id, Motiv);
            return PLUGIN_HANDLED;
        }
        else
            set_task(1.0,"TimeRem",id,_,_,"a",1);
        break;
      }
      else
      remove_task(id);     
  }
  return PLUGIN_CONTINUE;
}



public TimeRem(id)
{
  static Name[32];
 
  get_user_name(id, Name, sizeof Name -1);
 
  set_hudmessage(0, 255, 0, 0.10, 0.33, 0, 6.0, 3.0, 0.5, 0.3, 3);
 
  switch(get_pcvar_num(CvarMode))
  {
      case 0: ShowSyncHudMsg(id, Sync, "*** Ai %d sec pentru ati schimba numele daca nu til schimbam noi... ***", TimeS);
      case 1: ShowSyncHudMsg(id, Sync, "*** Ai %d sec pentru ati schimba numele daca nu iei slay... ***", TimeS);
      case 2: ShowSyncHudMsg(id, Sync, "*** Ai %d sec pentru ati schimba numele daca nu iei kick... ***", TimeS); 
      case 3: ShowSyncHudMsg(id, Sync, "*** Ai %d sec pentru ati schimba numele daca nu iei ban... ***", TimeS); 
  }
 
  if(TimeS >= 0)
  {
      if(TimeS < 6)
      {
        new voice_[64]
        num_to_word(TimeS, voice_, 63)
        client_cmd(id, "spk ^"vox/%s _comma^"", voice_)
      }
     
      if(TimeS < 1)
      {
        switch(get_pcvar_num(CvarMode))
        {
            case 0: ChangeName(id);
            case 1: SlayPlayer(id);     
            case 2: KickPlayer(id);
            case 3: BanPlayer(id);
        }
      } 
      TimeS--;
      set_task(1.1,"TimeRem",id);
  }
  return PLUGIN_HANDLED;
}


SlayPlayer(id)

  static Name[32];
 
  get_user_name(id, Name, sizeof Name -1);

  if(is_user_alive(id))
  {
      user_silentkill(id);
      ColorChat(id,GREEN,"[NameRestriction]^x01 Ai luat slay....");
  }
  ColorChat(0,GREEN,"[NameRestriction]^x01 %s a primit slay pentru nume obscen",Name);
 
}

ChangeName(id)
{
  static Name[32], CR[64];
 
  get_user_name(id, Name, sizeof Name -1);
 
  get_pcvar_string(NameChange, CR, 63);
 
  if(is_user_alive(id))
  {
      client_cmd(id, "name ^"%s^"",CR);
      ColorChat(id,GREEN,"[NameRestriction]^x01 Numele tau a fost schimbat");
  }
  ColorChat(0,GREEN,"[NameRestriction]^x01 Lui %s are acum un nume nou",Name);
}


KickPlayer(id)
{
  static Name[32];
 
  get_user_name(id, Name, sizeof Name -1);
 
  new Id = get_user_userid(id);
 
  server_cmd("kick #%d ^"%s^"",Id, Motiv);
 //  ColorChat(0,GREEN,"[NameRestriction]^x01 %s a fost dat afara pentru nume obscen",Name);
 
}


BanPlayer(id)
{
  static Name[32], Ip[32];
 
  new Id = get_user_userid(id);
  new Minutes = get_pcvar_num(CvarMin);
 
  get_user_name(id, Name, sizeof Name -1);
  get_user_ip(id, Ip, sizeof Ip -1);
 
 
  server_cmd("kick #%d ^"%s^";wait;addip ^"%d^" ^"%s^";wait;writeip",Id, Motiv, Minutes, Ip);
  ColorChat(0,GREEN,"[NameRestriction]^x01 %s a fost banat pentru nume obscen",Name);
 
}

Sorry for my Language ! Is not the BEST !


All times are GMT -4. The time now is 10:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.