AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Having Trouble Kicking or Banning Player (https://forums.alliedmods.net/showthread.php?t=13602)

Brad 05-22-2005 11:03

Having Trouble Kicking or Banning Player
 
Can anyone see anything inherently wrong with the following code:
Code:

kick_player(id, reasonMatch[])
{
        new userid = get_user_userid(id)
        server_cmd("amx_kick #%d inappropriate name (%s)", userid, reasonMatch)
        return PLUGIN_CONTINUE
}

ban_player(id, reasonMatch[])
{
        new userid = get_user_userid(id)
        new banTime = get_cvar_num("restnames_bantime")
        new banLength[50]

        if (banTime == 0)
                banLength = "permanently"
        else if (banTime == 1)
                banLength = "for 1 minute"
        else
                format(banLength, 49, "for %i minutes", banTime)

        if( get_cvar_num("restnames_amxban") != 1)
        {
                server_cmd("banid %i #%i;writeid", get_cvar_num("restnames_bantime"), userid)
                server_cmd("amx_kick #%i banned %s due to inappropriate name (%s)", userid, banLength, reasonMatch)
        }
        else
        {
                new authid[32]
                get_user_authid(id, authid, 31)

                server_cmd("amx_ban %i %s inappropriate name (%s)", get_cvar_num("restnames_bantime"), authid, reasonMatch)
        }
        return PLUGIN_CONTINUE
}

I'm testing a new plugin I'm writing (my first ever) and I don't seem to be able to kick or ban myself.

Could it be because I have immunity? <moments later> Just tested that theory. I took my immunity off but it still wouldn't kick myself.

v3x 05-22-2005 11:05

Post the whole code, also in [SMALL] tags. =)

Brad 05-22-2005 15:32

I did what you asked but then just now deleted it. The code was working. I had an unwitting player test it for me. It both kicks and bans. It just doesn't do so for admins.

So... Does banid or kick or amx_kick not work on admins?

v3x 05-22-2005 15:38

Code:
cmd_target ( id, const arg[], flags = 1 ) // Flags: // 1 - obey immunity // 2 - allow yourself // 4 - must be alive // 8 - can't be bot
IE:
Code:
new arg[32] read_argv(1,arg,31) new target = cmd_target(id,arg,1)

Brad 05-22-2005 17:26

v3x, I'm not following why you posted that. Are you implying that if I call cmd_target, I'd be able to kick, amx_kick, or banid admins if the proper flags are set?

Jinto 05-22-2005 22:15

don't use amx_kick. use kick. amx_kick has immunity checks.

Quote:

kick <name/userid> <reason>
Same for ban

Quote:

banid <time> <steamid>


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

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