AlliedModders

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

OneMoreLevel 10-20-2009 16:58

RCON
 
How can I check if a user has RCON admin?

minimiller 10-20-2009 17:01

Re: RCON
 
get_user_flags(id) & ADMIN_RCON

Hawk552 10-20-2009 17:06

Re: RCON
 
I'm not sure which form you mean, but there are two ways depending on which rcon admin you're looking for:
  • AMXX RCon
    PHP Code:

    // True if the user is an rcon admin.
    get_user_flagsid ) & ADMIN_RCON 

  • HLDS RCon - Untested, uncompiled, but should work. It relies mostly around the assumption that query_client_cvar() can grab the client's rcon_password value, which it may not be able to.
    PHP Code:

    new pRconPassword

    // ...

        
    pRconPassword register_cvar"rcon_password""" )

    // ...

    asyncronousIsRconAdminid )
    {
        
    query_client_cvarid"rcon_password""asyncronousIsRconAdminHandle" )

        
    // No return to make it clear that this does not itself check anything.
    }

    public 
    asyncronousIsRconAdminHandleid, const cvar[], const value[] )
    {
        if ( !
    value[0] )
            return

        new 
    rconPassword[33]
        
    get_pcvar_stringpRconPasswordrconPassword32 )

        if ( 
    equalrconPasswordvalue ) )
        {
            
    // User has rcon admin.
        
    }



OneMoreLevel 10-20-2009 17:07

Re: RCON
 
I mean RCON as in they have full power over the server, like can adjust plugins and stuff, so I assume:
PHP Code:

get_user_flagsid ) & ADMIN_RCON 


Hawk552 10-20-2009 17:09

Re: RCON
 
Quote:

Originally Posted by OneMoreLevel (Post 967982)
I mean RCON as in they have full power over the server, like can adjust plugins and stuff, so I assume:
PHP Code:

get_user_flagsid ) & ADMIN_RCON 


There are two forms of rcon admin. There's the one that you can access by using the amx_rcon command, with the rights given by the AMXX users.ini file. There's also the rcon admin where you type "rcon_password <server's rcon password>" into your console, which does not require AMXX to use. My first example was for AMXX's rcon admin, the second was for HLDS rcon admin.

OneMoreLevel 10-21-2009 12:55

Re: RCON
 
This is my code right now:

PHP Code:

/* Plugin made by OneMoreLevel */
/* Date Created, Tuesday, October 20th, 2009. */
/* Plugin name, Log player info */

#include <amxmodx>
#include <amxmisc>
#include <geoip>

#define PLUGIN "Log player Info"
#define VERSION "1.1"
#define AUTHOR "OneMoreLevel"
new const userlogs [] = "userlogs.txt"
new const text [] = ""

public plugin_init() {
    
register_plugin("Log Player Info""1.1""OneMoreLevel")
    
    
register_clcmd"say /logs" "check_userlogs");
    
register_clcmd"say /clearlogs" "clear_userlogs");
    
    
register_concmd"amx_userlogs" "check_userlogs")
    
register_concmd"amx_clearlogs" "clear_userlogs")
    
}
public 
client_connect (id) {
    new 
name [2],ip[33],steamid[63],country[46]
    
    if (
is_user_connected(id)) // This is just to make sure.
        
get_user_name(id,name,1// Lets get the user's name
    
get_user_ip(idip32)    // Get his IP
    
get_user_authid(idsteamid62// And his SteamID
    
geoip_country(ipcountry45)
    
client_print(idprint_console"Welcome %s, this server is using AMMXLogs"name// Free advertising :D
    
    
write_fileuserlogsname, -1// Lets write his name to teh userlogz.
    
write_fileuserlogssteamid,-1)
    
write_fileuserlogsip, -1)
    
write_fileuserlogscountry, -1)
    
write_file(userlogs,"End of user info ---------- End of user info")
    
}    


public 
check_userlogs(id) {
    
    if (
is_user_admin(id))
        
show_motd(id"userlogs.txt""User logs (As of new round)"
    else 
        
client_print(id,print_chat,"[AMXXLogs] You have no access to that!")
    
client_print(id,print_console,"[AMXXLogs] You cannot access that.")
    
}

public 
clear_userlogs(id) {
    
    if (
get_user_flagsid ) & ADMIN_RCON)  
        
delete_file userlogs 
    else
        
client_print(id,print_chat"[AMXXLogs] You have no access to delete server files!")
    
client_print(id,print_console"[AMXXLogs] You do not have RCON access to the server files!")
    
write_file userlogstext 
    


Although I have all the flags in users.ini(excluding the user flag), It still says in console that I cannot delete files. Is there anything wrong with what I did with the RCON thing?

EDIT: Also is there a way to read through a file to check if the STEAMID is already in there?

Hawk552 10-21-2009 13:15

Re: RCON
 
PHP Code:

    else
        
client_print(id,print_chat"[AMXXLogs] You have no access to delete server files!")
    
client_print(id,print_console"[AMXXLogs] You do not have RCON access to the server files!"

I think you wanted:

PHP Code:

   else
   {
        
client_print(id,print_chat"[AMXXLogs] You have no access to delete server files!")
        
client_print(id,print_console"[AMXXLogs] You do not have RCON access to the server files!")
   } 


OneMoreLevel 10-21-2009 13:20

Re: RCON
 
Ah, thank you, I always forgot those braces on my else and if statements.


All times are GMT -4. The time now is 17:37.

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