Raised This Month: $12 Target: $400
 3% 

help flags


Post New Thread Reply   
 
Thread Tools Display Modes
1M1e
Member
Join Date: Mar 2020
Old 07-24-2020 , 03:57   Re: help flags
Reply With Quote #11

Quote:
Originally Posted by fysiks View Post
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.
i don't know how to do it can some one do it ?

Last edited by 1M1e; 07-24-2020 at 03:57.
1M1e is offline
Foxa
Member
Join Date: Nov 2018
Location: Croatia
Old 07-25-2020 , 05:03   Re: help flags
Reply With Quote #12

If you don't know anything and you're not willing to learn, don't post here, go to the requests subforum and post there

PHP Code:
#include <amxmodx>

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

new const Flag[]="d";  //Change the flag to whatever you want

public plugin_init(){
    
register_plugin(PLUGINVERSIONAUTHOR)
}

public 
client_connect(id){
    new 
szName[32]
    new 
szID[32]
    new 
players[32], num;
    
get_user_authid(idszIDcharsmax(szID))
    
get_user_name(idszNamecharsmax(szName))
    
get_players(playersnum)
    for(new 
i=0i<numi++){
        if(
is_admin(players[i]))
            
client_print(players[i], print_chat"%s is connecting SteamID(%s)"szNameszID)
    }
}

public 
client_putinserver(id){
    new 
szName[32]
    new 
szID[32]
    new 
players[32], num
    get_user_authid
(idszIDcharsmax(szID))
    
get_user_name(idszNamecharsmax(szName))
    
get_players(playersnum)
    for(new 
i=0i<numi++){
        if(
is_admin(players[i]))
            
client_print(0print_chat"%s has connected SteamID(%s)"szNameszID)
    }
}  

public 
client_disconnected(id){
    new 
szName[32]
    new 
szID[32]
    new 
players[32], num
    get_user_authid
(idszIDcharsmax(szID))
    
get_user_name(idszNamecharsmax(szName))
    
get_players(playersnum)
    for(new 
i=0i<numi++){
        if(
is_admin(players[i]))
            
client_print(0print_chat"%s has disconnected SteamID(%s)"szNameszID)
    }
}

stock bool:is_admin(id){
    if((
get_user_flags(id) & read_flags(Flag)))
        return 
true
    
    
return false

Not tested but should work.

Last edited by Foxa; 07-25-2020 at 05:04.
Foxa is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-25-2020 , 11:25   Re: help flags
Reply With Quote #13

@Foxa

1. The steam ID will not always be available at client_connect(). I recommend using client_authorized() if you require the steam ID.
2. Your code is written to print to only those who have the specified admin status/flags but then you use 0 in client_print, which prints to everyone. So everyone would see the same print <number of players> number of times. Change this to the player id.
3. Capture the steam id in a global variable so it can be re-used when the player disconnects. No sense in calling a native that returns the same value twice.
4. Your code would not work if the Flag variable held more than 1 flags.
5. I would add "ch" flags to get_players() to exclude bots/HLTV.
6. 'stock' should not be used within a plugin, only include files.

@1M1e - I would avoid printing the 'connecting' and 'connected' messages, use connected only since you are guaranteed to have steam ID at authorized(). It would be annoying to see the same message back to back for each player.

Spoiler
__________________

Last edited by Bugsy; 07-25-2020 at 11:59.
Bugsy is offline
1M1e
Member
Join Date: Mar 2020
Old 07-25-2020 , 15:22   Re: help flags
Reply With Quote #14

Quote:
Originally Posted by Foxa View Post
If you don't know anything and you're not willing to learn, don't post here, go to the requests subforum and post there
i am new on amxmodx i want to learn but this is hard for me

and thx its work
1M1e is offline
1M1e
Member
Join Date: Mar 2020
Old 07-25-2020 , 15:24   Re: help flags
Reply With Quote #15

Quote:
Originally Posted by Bugsy View Post

@1M1e - I would avoid printing the 'connecting' and 'connected' messages, use connected only since you are guaranteed to have steam ID at authorized(). It would be annoying to see the same message back to back for each player.
ty for update

Last edited by 1M1e; 07-25-2020 at 15:29.
1M1e is offline
Foxa
Member
Join Date: Nov 2018
Location: Croatia
Old 07-26-2020 , 05:38   Re: help flags
Reply With Quote #16

Quote:
Originally Posted by Bugsy View Post
@Foxa

1. The steam ID will not always be available at client_connect(). I recommend using client_authorized() if you require the steam ID.
2. Your code is written to print to only those who have the specified admin status/flags but then you use 0 in client_print, which prints to everyone. So everyone would see the same print <number of players> number of times. Change this to the player id.
3. Capture the steam id in a global variable so it can be re-used when the player disconnects. No sense in calling a native that returns the same value twice.
4. Your code would not work if the Flag variable held more than 1 flags.
5. I would add "ch" flags to get_players() to exclude bots/HLTV.
6. 'stock' should not be used within a plugin, only include files.

@1M1e - I would avoid printing the 'connecting' and 'connected' messages, use connected only since you are guaranteed to have steam ID at authorized(). It would be annoying to see the same message back to back for each player.

Spoiler
Yeah I know about all those issues, I literally just copied his code and added the flag thing, figured hey if it worked so far why would it not work anymore.
Anyways, thanks for pointing those things out.

Last edited by Foxa; 07-26-2020 at 05:42.
Foxa is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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