AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Command only for admin & dead users while alive (https://forums.alliedmods.net/showthread.php?t=162827)

DeLiriuM 07-23-2011 11:07

Command only for admin & dead users while alive
 
Hey,

I'm trying to make a command available only for admins with flag A and regular users when they're dead, but the best i could to is, to restrict the command for alive users and make it unavailable for users with ADMIN_USER (aka default).

Code:

  if (is_user_alive(id) && (get_user_flags(id) & ADMIN_USER))
  {
    client_print(id, print_chat, "Only admins or dead users could use this command")
    return PLUGIN_HANDLED
  }


drekes 07-23-2011 11:47

Re: Command only for admin & dead users while alive
 
PHP Code:

if (is_user_alive(id) || !(get_user_flags(id) & ADMIN_USER)) 


DeLiriuM 07-23-2011 12:00

Re: Command only for admin & dead users while alive
 
Nope... no matter what flags I add or if I'm dead or alive, I get "Only admins blablabla...".

fireattack 07-23-2011 12:54

Re: Command only for admin & dead users while alive
 
PHP Code:


if( !is_user_aliveid )|| get_user_flagsid ) & ADMIN_IMMUNITY ) ) 


drekes 07-23-2011 13:06

Re: Command only for admin & dead users while alive
 
I was wrong the first time.

tested and working:
PHP Code:

#include <amxmodx>

public plugin_init()
{
    
register_clcmd("say !test""CmdTest");
}


public 
CmdTest(id)
{
    if(
is_user_alive(id) && !(get_user_flags(id) & ADMIN_BAN))
        
client_print(idprint_chat"You cannot access this");
        
    else
        
client_print(idprint_chat"You can access this");
    
    return 
PLUGIN_HANDLED;



DeLiriuM 07-23-2011 15:02

Re: Command only for admin & dead users while alive
 
Thanks. New problem now.

PHP Code:

public cmdMe(id)
{
  
    if (!
SayMe)
    {

        
colorChat(idCHATCOLOR_RED"%L"id"DISABLED_MSG")
        return 
PLUGIN_HANDLED
    
}
    
    
format_kill_vinfo(id0g_sBuffer)
    
colorChat(idCHATCOLOR_GREEN,"* %s"g_sBuffer)
    
    return 
PLUGIN_CONTINUE


@drekes - can't use you're version, since if... else... if... won't work (tested it).

nikhilgupta345 07-23-2011 15:23

Re: Command only for admin & dead users while alive
 
PHP Code:

public cmdMe(id)
{
    if (!
SayMe)
    {
        
colorChat(idCHATCOLOR_RED"%L"id"DISABLED_MSG")
    }
    
    else
    {
        
format_kill_vinfo(id0g_sBuffer)
        
colorChat(idCHATCOLOR_GREEN,"* %s"g_sBuffer)
    }
    
    return 
PLUGIN_CONTINUE


You have to use braces if you have more than 1 statement in an if/else if/else

DeLiriuM 07-23-2011 15:28

Re: Command only for admin & dead users while alive
 
Removed

PHP Code:

    if (!SayMe)
    {

        
colorChat(idCHATCOLOR_RED"%L"id"DISABLED_MSG")
        return 
PLUGIN_HANDLED
    


Added the }{ and that did the trick. Thanks ;)


All times are GMT -4. The time now is 00:59.

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