AlliedModders

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

Alucard^ 09-05-2009 06:18

server_cmd()
 
PHP Code:

#include <amxmodx>

#define PLUGIN    "New Plugin"
#define AUTHOR    "Alucard"
#define VERSION    "1.0"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /kickme""HookKickMe")
}

public 
HookKickMe(id)
{
    new 
Name[32]
    
get_user_name(idName31)
    
    
server_cmd("amx_kick %s"Name)
    
server_exec()


Is only an example... the problem is that i can use the command ONLY if i am ADMIN... but i want that all players can use this command...

Yeh, i know that the correct method to do this is:

PHP Code:

server_cmd("kick #%d"get_user_userid(id)) 

But like i said... is only an example.

Arkshine 09-05-2009 06:47

Re: server_cmd()
 
If you don't specify a flag, it means it would be available for all players.

Alucard^ 09-05-2009 09:15

Re: server_cmd()
 
Well.. i show you the code:

PHP Code:

#include <amxmodx>

#define ADMIN_CHECK ADMIN_KICK

new maxplayers

public plugin_init()
{
    
register_plugin("Admin Check edited""1.0""OneEyed && Alucard")
    
    
maxplayers get_maxplayers()
    
    
register_clcmd("say""handle_say")
}

public 
handle_say(id)
{
    new 
said[192]
    
read_args(said,192)
    
    if( ( 
containi(said"quien") != -&& containi(said"admin") != -) || contain(said"/admin") != -)
    {
        new 
adminnames[33][32]
        new 
Name[32]
        new 
icountx
        
        get_user_name
(idName31)
        
        for(
<= maxplayers i++)
        {
            if(
is_user_connected(i) )
            {
                if(
get_user_flags(i) & ADMIN_CHECK)
                    
get_user_name(iadminnames[count++], 31)
            }
        }
        
        if(
count 0)
        {
            for(
count x++)
            {
                
server_cmd("amx_msg %s ^"Admins Online:\n%s%s^""Nameadminnames[x], < (count-1) ? "\n":"")
                
server_exec()
            }
        }
        if(
count 0)
        {
            
server_cmd("amx_msg %s ^"No admins online^""Name)
            
server_exec()
        }
    }
    else
        return 
PLUGIN_CONTINUE
    
return PLUGIN_HANDLED


I tested in lan and in a dedicated server. When i have the name with the Admin... and i use /admins command... show me
"Admins Online:
Alucard^"

Good... but when i use a name without the admin... and /admins command... would show me "No admins online". But no... the msg doesn't appear. Is something of flags, or what?

Thx and sry for my english.

SnoW 09-05-2009 10:06

Re: server_cmd()
 
The count is 0 when there's no admins online and your check is:
PHP Code:

if(count 0


So nothing is displayed.

Alucard^ 09-05-2009 12:45

Re: server_cmd()
 
Quote:

Originally Posted by SnoW (Post 923723)
The count is 0 when there's no admins online and your check is:
PHP Code:

if(count 0


So nothing is displayed.

True, i am rly stupid... but now... have the first problem... when i am not admin and type /admins... i get "[AMXX] You have no acces to this command." or soemthing like this... o.o!

Mxnn 09-05-2009 20:10

Re: server_cmd()
 
register_concmd ("say /kickme", "HookKickMe", ADMIN_LEVEL_Z " ")

If you try that?

Alucard^ 09-05-2009 21:38

Re: server_cmd()
 
I don't think that...

As far as i know... concmd is useless for command like "say /command"... And, like Arskhine said... if you dont specify a flag... it means it would be available for all players.

Also, the /kickme command is only an example... i showed in the last post, the real code.


All times are GMT -4. The time now is 15:09.

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