AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Adding only admins function (https://forums.alliedmods.net/showthread.php?t=157066)

fLaXXiE 05-15-2011 15:33

Adding only admins function
 
I need to add only admins function. i tried but was not correct.

PHP Code:

#include < amxmodx >
#include < amxmisc >
#include < colorchat >
#include < engine >
#include < fun >

#define prefix "^4[FB] Manager:^3"

public plugin_init ( )
{
    
register_plugin "JBManager""1.0""Capell" )
    
    
register_clcmd "say""SayCmds" )
}

public 
SayCmds iPlayerid )
{
    static 
arg 36 ]
    new 
iPlayerName 32 ]
    
read_argv 1argsizeof arg ) - )
    
parse (argarg35iPlayerNamesizeof iPlayerName ) - )

    if (!(
get_user_flags(id0)&ADMIN_VOTE))
        return
    {    
        if ( 
equali arg"!kick" ) )
        {
            if ( !
iPlayerName ] )
                
ColorChat iPlayerGREY"%s You need to type a nick"prefix )
            else
            {
                new 
iPlayerNameID cmd_target iPlayeriPlayerName)
                if ( 
iPlayerNameID )
                {
                    new 
iName 32 ], iTargetName 32 ]
                    
get_user_name iPlayeriNamesizeof iName ) - )
                    
get_user_name iPlayerNameIDiTargetNamesizeof iTargetName ) - )
                    
server_cmd "kick ^"%s^""iTargetName )
                    
ColorChat 0GREY"%s %s kicked^4 %s"prefixiNameiTargetName)
                }
                else
                    
ColorChat iPlayerGREY"%s There are no players with that name"prefix )
            }
            return 
PLUGIN_HANDLED
        
}
    
        if ( 
equali arg"!slay" ) )
        {
            if ( !
iPlayerName ] )
                
ColorChat iPlayerGREY"%s You need to type a nick"prefix )
            else
            {
                new 
iPlayerNameID cmd_target iPlayeriPlayerName)
                if ( 
iPlayerNameID )
                {
                    new 
iName 32 ], iTargetName 32 ]
                    
get_user_name iPlayeriNamesizeof iName ) - )
                    
get_user_name iPlayerNameIDiTargetNamesizeof iTargetName ) - )
                    
user_silentkill iPlayerNameID )
                    
ColorChat 0GREY"%s %s slayed^4 %s"prefixiNameiTargetName)
                }
                else
                    
ColorChat iPlayerGREY"%s There are no players with that name"prefix )
            }
            return 
PLUGIN_HANDLED
        
}
    
    }
        return 
PLUGIN_CONTINUE



fysiks 05-15-2011 17:24

Re: Adding only admins function
 
You didn't read the thread that I linked you to.

I'll give you a whole sample so it's not so hard to piece together:


PHP Code:

public plugin_init()
{
    
register_clcmd("say""cmdSay")
}

public 
cmdSay(id)
{
    new 
szString[45], szFirstArgument[12], szSecondArgument[12], szThirdArgument[4], szEverythingElse[20]
    
    
read_args(szStringcharsmax(szString))
    
remove_quotes(szString)
    
    
strbreak(szStringszFirstArgumentcharsmax(szFirstArgument), szStringcharsmax(szString))
    
strbreak(szStringszSecondArgumentcharsmax(szSecondArgument), szStringcharsmax(szString))
    
strbreak(szStringszThirdArgumentcharsmax(szThirdArgument), szEverythingElsecharsmax(szEverythingElse))
    
    
client_print(idprint_console"First Argument: %s"szFirstArgument)
    
client_print(idprint_console"Second Argument: %s"szSecondArgument)
    
client_print(idprint_console"Third Argument: %s"szThirdArgument)
    
client_print(idprint_console"Everything else: %s"szEverythingElse)


Try this and see what prints in your console.

It can be modified to use fewer or more argument easily if needed.


All times are GMT -4. The time now is 04:31.

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