AlliedModders

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

InteX01 01-22-2017 09:06

1 command
 
Code:

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

#define PLUGIN "ADMIN FUN PLUGIN"
#define VERSION "1.0"
#define AUTHOR "InteX"

public plugin_init() {
        register_clcmd("say /noclipon", "NoClipON")
        register_clcmd("say /noclipoff", "NoClipOFF")
}
public NoClipON(id)
{
        if(get_user_flags(id) & ADMIN_RCON)
        {
                set_user_noclip (id, 1)
                ColorChat(id, GREEN, "[AdminFun] ^3You turned on noclip.")
        }
        else
        {
                {
                        if(get_user_flags(id) & ADMIN_USER)
                        {
                                ColorChat(id, GREEN, "[AMXX] ^3You dont have access to this command.")
                        }
                }
        }
        return PLUGIN_HANDLED;
}
public NoClipOFF(id)
{
        if(get_user_flags(id) & ADMIN_RCON)
        {
                set_user_noclip (id, 0)
                ColorChat(id, GREEN, "[AdminFun] ^3You turned off noclip.")
        }
        else
        {
                {
                        if(get_user_flags(id) & ADMIN_USER)
                        {
                                ColorChat(id, GREEN, "[AMXX] ^3You dont have access to this command.")
                        }
                }
        }
        return PLUGIN_HANDLED;
}

This is only part of plugin.
Im begginer at scripting and my question is:
Can i somehow make both like switching ON/OFF with one command /noclip but to keep this "You dont have access...."
So i dont need to use /noclipon and /noclipoff
And yeah if u can give me some advices if i done something wrong or.....

Thanks.

Celena Luna 01-22-2017 09:21

Re: 1 command
 
PHP Code:

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

#define PLUGIN "ADMIN FUN PLUGIN"
#define VERSION "1.0"
#define AUTHOR "InteX"

//You will need this to check if that player is on/off
new is_noclip[33

public 
plugin_init() 
{
    
register_clcmd("say /noclip""NoClip")    
}
public 
NoClip(id)
{
    if(
get_user_flags(id) & ADMIN_RCON)
    {
        if(!
is_noclip[id]) //already turn on?
        
{
            
set_user_noclip (id1)
            
ColorChat(idGREEN"[AdminFun] ^3You turned on noclip.")
            
is_noclip[id] = 1
        
}
        else 
//other situation (here, definitely check if it already on)
        
{
            
set_user_noclip (id0)
            
ColorChat(idGREEN"[AdminFun] ^3You turned off noclip.")
            
is_noclip[id] = 0
        
}
        
    }
    else
    {
        
//if(get_user_flags(id) & ADMIN_USER) //You only need else, don't need to be ADMIN_USER here
        
ColorChat(idGREEN"[AMXX] ^3You dont have access to this command.")
    }
    return 
PLUGIN_HANDLED;



InteX01 01-22-2017 09:22

Re: 1 command
 
Thanks :)

new is_noclip [33]

btw what does that number mean

Celena Luna 01-22-2017 09:25

Re: 1 command
 
I update it a bit.

HamletEagle 01-22-2017 09:56

Re: 1 command
 
Quote:

Originally Posted by InteX01 (Post 2488947)
Thanks :)

new is_noclip [33]

btw what does that number mean

There is a maximum of 32 players with indexes from 1 to 32. The array has to have the last cell empty, so in order to be able to access 32rd cell the array must have a size of 33. If you would do is_noclip[32] then only indexes from 1 to 31 can be used and the 32rd player will cause an index out of bounds error, because there is no room for index 32.
The first cell(0) remains unused.

InteX01 01-22-2017 10:38

Re: 1 command
 
Code:

public prefix(id){
    if(get_user_flags(id) & ADMIN_LEVEL_H)
{
        new said[192], name[30]
        get_user_name(id,name,29)
        read_args(said,191)
        remove_quotes(said)
        ColorChat(0, GREEN,"[VIP] ^3%s^4 : %s",name,said)
 }

I dont want to open new topic so
Is this properly used ?
cuz im getting

InteX : hello
[VIP] InteX : hello

How could i make this

And on my second plugin i used this
its only
[VIP] InteX : message
but useres without T flag cant chat :/

OciXCrom 01-22-2017 10:52

Re: 1 command
 
It's because you have two plugins that modify the chat.


All times are GMT -4. The time now is 20:49.

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