
   /*********************************************************
   * Add admins to users.ini
   * By Jarrett Hawrylak(WrG|IceMouse)
   * iknowmypasswurd@hotmail.com
   *
   * THIS VERSION IS STRICTLY BETA
   * It isn't working as well as I wanted but I hoped
   * a few people could get some use out of it
   *
   * REQUIRES AMX 9.4.0
   *
   * COMMANDS:
   * amx_user_add <name>: Adds a WONID with full admin EXCEPT
   *          immunity to users.ini(with commented name)
   * amx_user_del <name>:Deletes a user from users.ini
   * amx_user_edit <name> <flags>: Adds <flags> to <users> access TESTING
   * amx_user_set <name> <flags>: Replaces <users> old flags with <flags>
   *             TESTING
   *
   * NOTES: This plugin hasn't been working as well as i had planned...
   * but i have made some changes that remain untested as of this release
   *  amx_user_edit/set  aren't working very well, while amx_user_add/del
   work
   * almost flawlessly... o_o almost
   *
   * EXAMPLES:
   * amx_user_add ice: places the following lines in users.ini
   * //WrG|IceMouse
   * "2932166" "*" "bcdefghijklmnopqrstuz" "ce"
   * and amx_user_del ice replaces the second line with:
   * WrG|Icemouse "2932166" DELETED BY ADMINS_NAME
   *
   * Changelog:
   * 6/11/03: v0.1, Inital release... some help can be used in
   *       testing... report all bugs/fix ideas to me please
   * 6/11/03: v0.11, Forgot to add a little thing for user_del/edit/set
   *                Fixed
   *********************************************************/
   #include <amxmod>
   #include <amxmisc>
   new usersfile[40] = "addons/amx/users.ini"
   public amx_user_add(id,level,cid) {
   if (!cmd_access(id,level,cid,2))
         return PLUGIN_HANDLED
   new arg[32]
   new WONID
   new player
   new f_admin[15]
   new f_password[15]
   new f_access[25]
   new f_flags[15]
   new line = 1
   new RF_line[100]
   new found = 0
   new user_name[32]
   read_argv(1,arg,32)
   player = cmd_target(id,arg,0)
   if(!player)
      return PLUGIN_HANDLED
   WONID = get_user_wonid(player)
   get_user_name(player,user_name,32)

   while(line != 0) {
      line = read_file(usersfile,line,RF_line,100,line)
      parse(RF_line,f_admin,15,f_password,15,f_access,25,f_flags,15)
      if (strtonum(f_admin) == WONID){
         found = 1
         break
      }
   }
   if(found) {
      console_print(id,"Player:     %s,     is     already     in     the
   users.ini!",user_name)
      return PLUGIN_HANDLED
   }
   new WF_name[32]
   new WF_line[100]
   format(WF_line,100,"^"%d^"       ^"*^"       ^"bcdefghijklmnopqrstuz^"
   ^"ce^"",WONID)
   format(WF_name,32,"^n//%s",user_name)
   write_file(usersfile,WF_name,-1)
   write_file(usersfile,WF_line,-1)
   set_user_flags(WONID,read_flags("bcdefghijklmnopqrstuz"))
   client_print(id,print_console,"%s(%d)        added        as        an
   admin!",user_name,WONID)
   return PLUGIN_HANDLED
   }
   public amx_user_edit(id,level,cid) {
   if (!cmd_access(id,level,cid,2))
         return PLUGIN_HANDLED
   new arg[32]
   new arg2[32]
   new WONID
   new player
   new f_admin[15]
   new f_password[15]
   new f_access[25]
   new f_flags[15]
   new line = 1
   new RF_line[100]
   new found = 0
   new user_name[32]
   new admin_name[32]
   read_argv(1,arg,32)
   player = cmd_target(id,arg,1)
   if(!player)
      return PLUGIN_HANDLED
   WONID = get_user_wonid(player)
   get_user_name(player,user_name,32)
   get_user_name(id,admin_name,32)

   while(line != 0) {
      line = read_file(usersfile,line,RF_line,100,line)
      parse(RF_line,f_admin,15,f_password,15,f_access,25,f_flags,15)
      if (strtonum(f_admin) == WONID){
         found = 1
         break
      }
   }
   if(!found) {
      console_print(id,"Player: %s, is not in the users.ini!",user_name)
      return PLUGIN_HANDLED
   }
   new WF_line[100]
   add(f_access,15,arg2)
   format(WF_line,100,"^"%d^" ^"*^" ^"%s^" ^"ce^"",WONID,f_access)
   write_file(usersfile,WF_line,line - 1)
   set_user_flags(WONID,read_flags(f_access))
   client_print(id,print_console,"%s(%d)            changed            to
   %s",user_name,WONID,f_access)
   return PLUGIN_HANDLED
   }
   public amx_user_set(id,level,cid) {
   if (!cmd_access(id,level,cid,2))
         return PLUGIN_HANDLED
   new arg[32]
   new arg2[32]
   new WONID
   new player
   new f_admin[15]
   new f_password[15]
   new f_access[25]
   new f_flags[15]
   new line = 1
   new RF_line[100]
   new found = 0
   new user_name[32]
   new admin_name[32]
   read_argv(1,arg,32)
   read_argv(1,arg2,32)
   player = cmd_target(id,arg,1)
   if(!player)
      return PLUGIN_HANDLED
   WONID = get_user_wonid(player)
   get_user_name(player,user_name,32)
   get_user_name(id,admin_name,32)

   while(line != 0) {
      line = read_file(usersfile,line,RF_line,100,line)
      parse(RF_line,f_admin,15,f_password,15,f_access,25,f_flags,15)
      if (strtonum(f_admin) == WONID){
         found = 1
         break
      }
   }
   if(!found) {
      console_print(id,"Player: %s, is not in the users.ini!",user_name)
      return PLUGIN_HANDLED
   }
   new WF_line[100]
   format(WF_line,100,"^"%d^" ^"*^" ^"%s^" ^"ce^"",WONID,arg2)
   write_file(usersfile,WF_line,line - 1)
   set_user_flags(WONID,read_flags(arg2))
   client_print(id,print_console,"%s(%d)      access      changed      to
   %s",user_name,WONID, arg2)
   return PLUGIN_HANDLED
   }
   public amx_user_del(id,level,cid) {
   if (!cmd_access(id,level,cid,2))
         return PLUGIN_HANDLED
   new arg[32]
   new WONID
   new player
   new f_admin[15]
   new f_password[15]
   new f_access[25]
   new f_flags[15]
   new line = 1
   new RF_line[100]
   new found = 0
   new user_name[32]
   new admin_name[32]
   read_argv(1,arg,32)
   player = cmd_target(id,arg,1)
   if(!player)
      return PLUGIN_HANDLED
   WONID = get_user_wonid(player)
   get_user_name(player,user_name,32)
   get_user_name(id,admin_name,32)

   while(line != 0) {
      line = read_file(usersfile,line,RF_line,100,line)
      parse(RF_line,f_admin,15,f_password,15,f_access,25,f_flags,15)
      if (strtonum(f_admin) == WONID){
         found = 1
         break
      }
   }
   if(!found) {
      console_print(id,"Player: %s, is not in the users.ini!",user_name)
      return PLUGIN_HANDLED
   }
   new WF_line[100]
   format(WF_line,100,"%s^"%d^"         DELETED         IN-GAME        BY
   %s",user_name,WONID,admin_name)
   write_file(usersfile,WF_line,line - 1)
   set_user_flags(WONID,-1)
   client_print(id,print_console,"%s(%d) deleted!",user_name,WONID)
   return PLUGIN_HANDLED
   }
   public plugin_init() {
   register_plugin("Add admins BETA","1","WrG|IceMouse")
   register_concmd("amx_user_add","amx_user_add",ADMIN_RCON,"<name> Add a
   user with full access without immunity")
   register_concmd("amx_user_del","amx_user_del",ADMIN_RCON,"<name>
   Delete a users admin")
   register_concmd("amx_user_set","amx_user_set",ADMIN_RCON,"<name>  <new
   flags> Set a users flags")
   register_concmd("amx_user_edit","amx_user_edit",ADMIN_RCON,"<name>
   <flags> Add flags to what the user already has")
   return PLUGIN_CONTINUE
   }
