AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   EntMod Manager v2.0 - 7/24/07 (https://forums.alliedmods.net/showthread.php?t=48539)

stupok 12-13-2006 22:38

EntMod Manager v2.0 - 7/24/07
 
2 Attachment(s)
EntMod Manager v2.0

by XmINiX and stupok69

I made this plugin intending to replace Seather's plugin.

The only EntMod plugin worth mentioning that I found was made by Seather almost one year ago, and it has very limited functionality. I am posting this plugin as a combination of XmINiX's two other plugins and some of my own ideas. I have permission from XmINiX to do this. I hope that will make the situation more simple.

Description:
This plugin will eliminate the need to modify the files inside "addons/EntMod/" by hand. You can add users, remove users, and delete entsaves using console commands. Also, this plugin gives you the option of logging EntMod commands.

Details:
  • If a user has EntMod access, he will be "logged in" automatically with the correct password. (ie. setinfo _entpass "pass")
  • Upon adding a user with ent_adduser the client will be automatically logged in.
  • Using ent_removeuser will remove the line from DF_admins.txt that contains the client's STEAMID.
  • The commands that will be logged are determined by reading a file called commands.cfg in addons/EntMod/log/.
  • The log will write an entry when the server starts, so that the admin can see the last command executed before a server crashes. This is helpful to determine what command and user caused the crash.
  • The plugin writes one log per day.


Commands:
  • ent_adduser <name> <password>
  • ent_removeuser <name>
  • es_delete <name> as it appears in es_list

Cvars:
  • entlog 0 or 1, log EntMod commands
  • entlog_showactivity 0 or 1, display a hudmessage when EntMod command executed

Please Note:
You need to have a list of EntMod commands defined in commands.cfg in the directory "addons/EntMod/log/commands.cfg" in order to log EntMod commands. I have included one for your convenience.

Changelog:
v1.0 - Initial release.
v2.0 - Updated code: more efficient, same functionality.

Charming 12-13-2006 23:36

Re: EntMod Manager
 
Not bad the, most usefull about this is the LOGID, so users wont ask HOW DO YOU LOGINS!?!?? all the time gj.

Da_sk8rboy 12-14-2006 01:48

Re: EntMod Manager
 
Quote:

Originally Posted by Charming (Post 415184)
Not bad the, most usefull about this is the LOGID, so users wont ask HOW DO YOU LOGINS!?!?? all the time gj.

+Karma Stupko.

EDIT: Shouldnt this be like entmanager2 since there already this plugin *Besides it does less than you plugin*

XmINiX 12-14-2006 06:43

Re: EntMod Manager
 
I saw that entmanager but it was trashed :/ i dont think it can compare to this.

GHW_Chronic 12-14-2006 18:40

Re: EntMod Manager
 
this plugin has the same functionality as:
http://forums.alliedmods.net/showthread.php?t=47193
but with more yes? I would consider this to depreceate the old one.

Tell me if I'm wrong and this plugin doesn't do what that one does.

stupok 12-14-2006 19:22

Re: EntMod Manager
 
You are correct. The plugin you posted writes only one log file. This plugin has more functionality in general, but also with logs. This plugin will write one log per day as opposed to only one log.

Besides that fact, this plugin is supposed to be a combination of the two plugins xminix posted, with an extra feature added by me (es_delete). I thought it would be simpler to have one plugin instead of two separate ones. I am open to any suggestions to make this worthy of approval.

Hviid 07-24-2007 17:27

Re: EntMod Manager
 
Really nice, ill use it at my server :) and then i don't need a forum where people can sign up for the ent rights :D

stupok 07-24-2007 22:26

Re: EntMod Manager v2.0 - 7/24/07
 
I decided to update the code. It's been a while since I wrote this plugin.

Luffy933 12-25-2007 14:28

Log
 
Is there any way that the log can be fixed to log the whole command insted of just the first 34 letters characters? Because if you spawn a monster and got an error on the model server will crash, if i could know what misspellings did that it would help me a lot.

stupok 12-31-2007 01:37

Re: EntMod Manager v2.0 - 7/24/07
 
Here ya go:

Code:

#include <amxmodx>
#include <amxmisc>

new const gc_admin_file[]                =        "addons/EntMod/DF_admins.txt"
new const gc_entlog_dir[]                =        "addons/EntMod/log/"
new const gc_entlog_fileformat[]        =        "addons/EntMod/log/%s.txt"
new const gc_entlog_cmds_file[]                =        "addons/EntMod/log/commands.cfg"

new g_entlog_file[64]

new bool:gb_client_has_ent[33]

new cvar_entlog
new cvar_showactivity

public plugin_init()
{
        register_plugin("EntMod Manager", "2.0", "Mini_soldier/stupok69")
       
        register_concmd("ent_adduser",                "giveent",        ADMIN_RCON, "<name> <pass>")
        register_concmd("ent_removeuser",        "removeent",        ADMIN_RCON, "<name>")
        register_concmd("es_delete",                "delete_save",        ADMIN_RCON, "<filename> as shown in es_list")
       
        cvar_showactivity        =        register_cvar("entlog_showactivity", "1")
        cvar_entlog                =        register_cvar("entlog", "1")
       
        initiate_log()
}

public initiate_log()
{
        if(!dir_exists(gc_entlog_dir)) mkdir(gc_entlog_dir)

        if(!file_exists(gc_entlog_cmds_file)) write_file(gc_entlog_cmds_file, ";Add EntMod commands you want to log here")
       
        new fh = fopen(gc_entlog_cmds_file, "rt")
       
        if(fh)
        {
                new buffer[32]
               
                while(!feof(fh))
                {
                        fgets(fh, buffer, 31)
                       
                        if(buffer[0] != ';' && buffer[0])
                        {
                                register_clcmd(buffer, "log_ent_command")
                        }
                }
        }
       
        fclose(fh)
       
        new CurrentDate[16]
       
        get_time("%m%d%y", CurrentDate, 15)
        format(g_entlog_file, 63, gc_entlog_fileformat, CurrentDate)
       
        new CurrentTime[64]
       
        get_time("%m/%d/%Y - %H:%M:%S * * *  Server Started  * * *", CurrentTime, 63)
        write_file(g_entlog_file, CurrentTime, -1)
}

public delete_save(id, level, cid)
{
        if (!cmd_access(id, level, cid, 2))
                return PLUGIN_HANDLED
       
        new entsavename[32], currentmap[32], entsavefile[96]
       
        read_argv(1, entsavename, 31)
       
        get_mapname(currentmap, 31)
       
        format(entsavefile, 95, "addons/EntMod/entsave/%s_%s.txt", currentmap, entsavename)
       
        if(!file_exists(entsavefile))
        {
                console_print(id, "%s does not exist!", entsavename)
        }
        else
        {
                delete_file(entsavefile)
                console_print(id, "%s successfully deleted.", entsavename)
        }
       
        return PLUGIN_HANDLED
}

public client_putinserver(id)
{
        gb_client_has_ent[id] = false
       
        set_task(10.0, "login_entmod", id)
}

public login_entmod(id)
{
        new fh = fopen(gc_admin_file, "rt")
       
        if(fh)
        {
                new authid[32], buffer[64], buffer2[64]
               
                get_user_authid(id, authid, 31)
               
                while(!feof(fh))
                {
                        fgets(fh, buffer, 63)
                       
                        strtok(buffer, buffer, 63, buffer2, 63, ';')
                       
                        if(equal(buffer, authid))
                        {
                                strtok(buffer2, buffer, 63, buffer2, 63, ';')
                               
                                client_cmd(id, "setinfo _entpass %s", buffer)
                               
                                gb_client_has_ent[id] = true
                               
                                new hostname[64]
                               
                                get_user_name(0, hostname, 63)
                                client_print(id, print_chat, "[Ent Give] Welcome to %s, you have been logged in to EntMod with pass (%s).", hostname, buffer)
                        }
                }
        }
       
        fclose(fh)
}

public giveent(id, level, cid)
{
        if(!cmd_access(id, level, cid, 3))
                return PLUGIN_HANDLED
       
        new arg1[32]
        new arg2[32]
       
        read_argv(1, arg1, 31)
        read_argv(2, arg2, 31)
       
        new player = cmd_target(id, arg1, 10)
       
        if(player)
        {
                if(!gb_client_has_ent[player])
                {
                        new name[32], authid[32]
                       
                        get_user_name(player, name, 31)
                        get_user_authid(player, authid, 31)
                       
                        if(!arg2[0])
                        {
                                console_print(id, "[Ent Give] You must enter a password!")
                                return PLUGIN_HANDLED
                        }
                       
                        new buffer[128]
                       
                        format(buffer, 127, "%s;%s;1        ; %s", authid, arg2, name)
                        write_file(gc_admin_file, buffer, -1)
                       
                        client_cmd(player, "setinfo _entpass %s", arg2)
                       
                        gb_client_has_ent[player] = true
                       
                        set_hudmessage(0, 0, 255, -1.0, -1.0, 0, 6.0, 12.0)
                        show_hudmessage(0, "[Ent Give] Player: %s now has EntMod access", name)
               
                        client_print(player, print_chat, "[Ent Give] Your password: %s", arg2)
                        client_print(player, print_chat, "[Ent Give] You have been logged in to EntMod, so there is no need to type setinfo _entpass ^"%s^".", arg2)
                }
                else
                {
                        client_print(id, print_console, "This client already has EntMod access.")
                }
        }
        else
        {
                client_print(id, print_console, "Client not found.")
                return PLUGIN_HANDLED
        }
       
        return PLUGIN_HANDLED
}

public removeent(id, level, cid)
{
        if (!cmd_access(id, level, cid, 2))
                return PLUGIN_HANDLED
       
        new arg1[32]
        read_argv(1, arg1, 31)
       
        new player = cmd_target(id, arg1, 10)
       
        if(player)
        {
                if(gb_client_has_ent[player])
                {
                        new name[32], authid[32]
                       
                        get_user_name(player, name, 31)
                        get_user_authid(player, authid, 31)
                       
                        new fh = fopen(gc_admin_file, "rt")
                       
                        if(fh)
                        {
                                new buffer[32]
                                new counter
                               
                                while(!feof(fh))
                                {
                                        fgets(fh, buffer, 31)
                                       
                                        if(contain(buffer, authid) != -1)
                                        {
                                                gb_client_has_ent[player] = false
                                               
                                                write_file(gc_admin_file, "", counter)
                                               
                                                client_print(0, print_chat, "[Ent Remover] Removed EntMod access from %s (%s).", name, authid)
                                                client_print(id, print_console, "[Ent Remover] Removed EntMod access from %s (%s).", name, authid)
                                        }
                                        counter++
                                }
                        }
                       
                        fclose(fh)
                }
                else
                {
                        client_print(id, print_console, "This client does not have EntMod access.")
                        return PLUGIN_HANDLED
                }
        }
        else
        {
                client_print(id, print_console, "Client not found.")
                return PLUGIN_HANDLED
        }
       
        return PLUGIN_HANDLED
}

public log_ent_command(id)
{
        if(get_pcvar_num(cvar_entlog) && gb_client_has_ent[id])
        {
                new args[96]
                new cmd[32]
                new text[256]
                new name[32]
                new authid[32]
               
                read_args(args, 63) 
                read_argv(0, cmd, 31)
                get_user_name(id, name, 31)
                get_user_authid(id, authid, 31)
               
                format(text, 127, "%32s        %32s        %32s        %s", authid, name, cmd, args)
                write_file(g_entlog_file, text)
               
                if(get_pcvar_num(cvar_showactivity))
                {
                        set_hudmessage(100, 100, 100, 0.0, 0.7, 0, 0.1, 3.0, 0.1, 0.1, -1)
                        show_hudmessage(0, "[Ent Log] %s: %s %s", name, cmd, args)
                        client_print(0, print_console, "[Ent Log] %s did cmd: %s",name, cmd, args)               
                }
        }
}



All times are GMT -4. The time now is 16:05.

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