AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   AMX AddAdmin (https://forums.alliedmods.net/showthread.php?t=295252)

DarthMan 03-20-2017 09:46

AMX AddAdmin
 
Hello. I started working on a brand new admin plugin for my HL1 server.

Code:

public cmdAddAdmin(id){   
        new arg[32]
        new arg2[64]
        new szName[32]
        new linetoadd=-1
        new Player = find_player("bl", arg);
        read_argv(1, arg, 63)
        new arglen=read_argv(2, arg2, 63)
        new flags = get_user_flags(id);
        get_user_name(id,szName,charsmax(szName))
        if (((is_user_connected(id)) && (flags & ADMIN_LEVEL_H)) && (read_argc() > 2)){
                        format(file_admins, 511, "^"%s^" ^"%s^" *Admin set by %s*", arg, arg2, szName)
                        get_user_authid(Player , arg , charsmax(arg) )
                        set_user_flags(Player,arglen)
                        client_print(0,print_console,"* The user became an admin with level %s.", arg2)
                        write_file(conffile_admins,file_admins,linetoadd)
                        if (read_argc() < 3)
                        {
                                client_print(id,print_console,"Usage: <steamid> <level>")
                                return PLUGIN_HANDLED
                        }
                }               
        else if ((is_user_connected(id)) && (!(flags & ADMIN_LEVEL_H)))
                {
                        client_print(id,print_console,"You do not have access to use this command.")
                        return PLUGIN_HANDLED
                }
        return PLUGIN_HANDLED               
}

Can someone fix the code for me? I want to check if there is a player with the steamid wrote in console, get it's name, and if there is no player with the steamid that I wrote, it should say No user with that name was found on the server. If it was found, it should set it's flags from arg2. Thanks!

klippy 03-20-2017 10:08

Re: AMX AddAdmin
 
The proper solution would be to use cmd_target().

DarthMan 03-20-2017 10:12

Re: AMX AddAdmin
 
Quote:

Originally Posted by KliPPy (Post 2505112)
The proper solution would be to use cmd_target().

And how can I use it on Player? IK, I can't use id in this case on the 1st parameter.

DarthMan 03-20-2017 11:55

Re: AMX AddAdmin
 
I fixed the plugin, problem solved :)

DarthMan 03-20-2017 16:30

Re: AMX AddAdmin
 
Fixed, problem solved :)


All times are GMT -4. The time now is 17:54.

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