AlliedModders

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

1M1e 07-21-2020 11:16

help flags
 
can some one do this code just who have flag ADMIN_BAN can see who connect ?


Code:


#include <amxmodx>

#define PLUGIN "ConnectDisconnect Message"
#define VERSION "1.0"
#define AUTHOR "AlliedMods"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
}

public client_connect(id){
    new szName[32]
    new szID[32]
    get_user_authid(id, szID, 19)
    get_user_name(id, szName, charsmax(szName))
    client_print(0, print_chat, "%s is connecting SteamID(%s)", szName, szID)
}

public client_putinserver(id){
    new szName[32]
    new szID[32]
    get_user_authid(id, szID, 19)
    get_user_name(id, szName, charsmax(szName))
    client_print(0, print_chat, "%s has connected SteamID(%s)", szName, szID)


public client_disconnected(id){
    new szName[32]
    new szID[32]
    get_user_authid(id, szID, 19)
    get_user_name(id, szName, charsmax(szName))
    client_print(0, print_chat, "%s has disconnected SteamID(%s)", szName, szID)
}


OciXCrom 07-23-2020 16:46

Re: help flags
 
No because this is not the "do it for me" section. The function you need is "get_user_flags" - try to do it, otherwise post in the REQUESTS section.

Also, that's not how you upload codes in the forum. Use [code], [php] or [pawn] tags.

1M1e 07-23-2020 16:52

Re: help flags
 
Quote:

Originally Posted by OciXCrom (Post 2711335)
"get_user_flags" [code], [php] or [pawn] tags.

i trid to do

Code:


        if (!(get_user_flags(id) & ADMIN_BAN)
        {
                return PLUGIN_HANDLED
        }

in top of plugin but did not work

Shadows Adi 07-23-2020 17:43

Re: help flags
 
Quote:

Originally Posted by 1M1e (Post 2711338)
i trid to do

Code:


        if (!(get_user_flags(id) & ADMIN_BAN)
        {
                return PLUGIN_HANDLED
        }

in top of plugin but did not work

You need to use this in every function which you want. Not in the header of the plugin

1M1e 07-23-2020 17:52

Re: help flags
 
Quote:

Originally Posted by Shadows Adi (Post 2711346)
You need to use this in every function which you want. Not in the header of the plugin

Code:


#include <amxmodx>

#define PLUGIN "ConnectDisconnect Message"
#define VERSION "1.0"
#define AUTHOR "AlliedMods"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
}

public client_connect(id){

                if (!(get_user_flags(id) & ADMIN_BAN))
        {
                return PLUGIN_HANDLED
        }
    new szName[32]
    new szID[32]
    get_user_authid(id, szID, 19)
    get_user_name(id, szName, charsmax(szName))
    client_print(0, print_chat, "%s is connecting SteamID(%s)", szName, szID)
}

public client_putinserver(id){

                if (!(get_user_flags(id) & ADMIN_BAN))
        {
                return PLUGIN_HANDLED
        }
    new szName[32]
    new szID[32]
    get_user_authid(id, szID, 19)
    get_user_name(id, szName, charsmax(szName))
    client_print(0, print_chat, "%s has connected SteamID(%s)", szName, szID)


public client_disconnected(id){

                if (!(get_user_flags(id) & ADMIN_BAN))
        {
                return PLUGIN_HANDLED
        }
    new szName[32]
    new szID[32]
    get_user_authid(id, szID, 19)
    get_user_name(id, szName, charsmax(szName))
    client_print(0, print_chat, "%s has disconnected SteamID(%s)", szName, szID)
}

did not work

OciXCrom 07-23-2020 18:16

Re: help flags
 
The player doesn't have admin flags while he is connecting.

1M1e 07-23-2020 18:58

Re: help flags
 
Quote:

Originally Posted by OciXCrom (Post 2711354)
The player doesn't have admin flags while he is connecting.

i want just when player connected to server Just admin will see the print chat !

ZaX 07-23-2020 19:39

Re: help flags
 
Make a task of 2 seconds in client_putinserver with the index of the player.
In the task callback function, get the client name or whatever you want then loop through all players, check if the player has the required flags then show message.

1M1e 07-24-2020 00:37

Re: help flags
 
like this ?

Code:

#include <amxmodx>

#define PLUGIN "ConnectDisconnect Message"
#define VERSION "1.0"
#define AUTHOR "AlliedMods"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
}

public client_join(id)
{
        set_task(2.0, "client_connect" ,ADMIN_BAN)
}

public client_connect(id){
    new szName[32]
    new szID[32]
    get_user_authid(id, szID, 19)
    get_user_name(id, szName, charsmax(szName))
    client_print(0, print_chat, "%s is connecting SteamID(%s)", szName, szID)
}

public client_joined(id)
{
        set_task(2.0, "client_putinserver" ,ADMIN_BAN)
}

public client_putinserver(id){
    new szName[32]
    new szID[32]
    get_user_authid(id, szID, 19)
    get_user_name(id, szName, charsmax(szName))
    client_print(0, print_chat, "%s has connected SteamID(%s)", szName, szID)
}

public client_left(id)
{
        set_task(2.0, "client_disconnected" ,ADMIN_BAN)


public client_disconnected(id){
    new szName[32]
    new szID[32]
    get_user_authid(id, szID, 19)
    get_user_name(id, szName, charsmax(szName))
    client_print(0, print_chat, "%s has disconnected SteamID(%s)", szName, szID)
}

not work

fysiks 07-24-2020 02:09

Re: help flags
 
No, that is very wrong.

The important part is that you're wanting to print something to all admins that are already in the server. That actually means that you're needing to address the client_print() function, not when the new player joins the server.

The other major requirement for your plugin is that you do do the printing of the message after two events have occurred: the player has joined the server and the the player has been authenticated by Steam (meaning they have a SteamID).

I suggest that you start with just printing the name when the player is put into the server. Get that working first using client_putinserver(). Then, you can add to printing only to admins by replacing your client_print() with a for loop that goes through all connected players and then calling client_print() only on those that have admin access. I suggest that you look for other plugins and threads where you see get_players() being used, most of these will have an example of how to use it and its results in a for loop.

Once you have that working, you can then work on adding the SteamID. The simplest (but not the most proper) would be to do what was previously mentioned to add a delay. So, in client_putinserver() you would use set_task() to call a custom function that contains the player loop code that prints the message.

Try to do some of those steps and if you run into issues, post the code that you've tried and we can help you out. If you make a decent effort to do these steps on your own, people will generally be more willing to help.


All times are GMT -4. The time now is 13:54.

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