AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Rate Admin (+rep , -rep) (https://forums.alliedmods.net/showthread.php?t=292191)

youssef_randy 12-31-2016 12:13

[Help] Rate Admin (+rep , -rep)
 
Hello guys! This Plugin is awsome,& i find cool idea to make it perfect & helpfull to all cs 1.6 server players, it's +rep -rep system, it controlls the reputable of any admin in your server and by typing "say /report" you can vote for an admin, please i want to make the admin that has +12 x -rep, to lose his admin acces automaticly or relate it to a file that show me the list of reported admins :
PHP Code:

 /* Plugin generated by AMXX-Studio */

#include <amxmodx>

#define PLUGIN "Admin rate"
#define VERSION "0.1"
#define AUTHOR "¢"
#define FLAG_ADM ADMIN_IMMUNITY

new g_maxplayersg_menutarget[33], g_rate[33][33];

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("say /report""cmd_ratemenu");
    
g_maxplayers get_maxplayers();
    if( !
dir_exists("admins_y") )
    {
        
mkdir("admins_y");
    }
}

public 
client_authorized(id)
{
    if(
get_user_flags(id) & FLAG_ADM)
    {
        new 
name[32], text[64];
        
get_user_name(idnamecharsmax(name));
        
formatex(textcharsmax(text), "admins_y/%s.txt"name);
        if( !
file_exists(text) )
        {
            new 
FILE fopen(text"w");
            
fputs(FILE"0^n");
            
fclose(FILE);
        }
    }
}

public 
cmd_ratemenu(id)
{
    new 
menu menu_create("\r[AW] \wAdmin Rate menu""menu_handler");
    for( new 
1g_maxplayersi++)
    {
        new 
name[32], text[34], num[4];
        
get_user_name(inamecharsmax(name));
        
formatex(textcharsmax(text), "%s%s", (get_user_flags(i) & FLAG_ADM)?"\w":"\d"name);
        
num_to_str(inumcharsmax(num));
        
menu_additem(menutextnum);
    }
    
menu_display(idmenu);
}

public 
menu_handler(idmenukey)
{
    if( 
key == MENU_EXIT )
    {
        
menu_destroy(menu);
        return;
    }
    
key+=1;
    if( !(
get_user_flags(key) & ADMIN_IMMUNITY) )
    {
        
menu_display(idmenu);
        return;
    }
    
g_menutarget[id]=key;
    
menu_rate(id);
    
}

public 
menu_rate(id)
{
    if( 
g_menutarget[id] == id )
    {
        
client_print(idprint_chat"^4[AW]^3 You can't rate yourself!");
        return;
    }
    if( 
get_user_flags(g_menutarget[id]) & FLAG_ADM )
    {
        new 
name[32], menu;
        
get_user_name(g_menutarget[id], namecharsmax(name));
        
menu menu_create(name"rate_handler");
        
menu_additem(menu"\r+Rep \yGood Admin""0");
        
menu_additem(menu"\r-Rep \yBad Admin""1");
        
menu_display(idmenu);
    }
}

public 
rate_handler(idmenukey)
{
    if( 
key == MENU_EXIT )
    {
        
menu_destroy(menu);
        return;
    }
    new 
i;
    for( 
0g_maxplayersi++ )
    {
        if(
g_rate[id][i] == g_menutarget[id])
        {
            
client_print(idprint_chat"^4[AW]^3 You have already rated this Player");
            return;
        }
    }
    for( 
0g_maxplayersi++ )
    {
        if( !
g_rate[id][i] )
        {
            
g_rate[id][i]=g_menutarget[id];
            break;
        }
    }
    new 
name[32], text[64], a[4],b;
    
get_user_name(g_menutarget[id], namecharsmax(name));
    
formatex(textcharsmax(text), "admins_y/%s.txt"name);
    new 
FILE fopen(text"r");
    
fgets(FILEacharsmax(a));
    
fclose(FILE);
    
b=str_to_num(a);
    if( 
key == )
    {
        
b++;
        
client_print(idprint_chat"%s's rate plus"name);
    }
    if( 
key == )
    {
        
b--;
        
client_print(idprint_chat"%s's rate minus"name);
    }
    
FILE fopen(text"w");
    
num_to_str(bacharsmax(a));
    
fputs(FILEa);
    
fputs(FILE"^n");
    
fclose(FILE);



OciXCrom 12-31-2016 13:16

Re: [Help] Rate Admin (+rep , -rep)
 
Rep = reputation, not report. :s

edon1337 12-31-2016 13:31

Re: [Help] Rate Admin (+rep , -rep)
 
Quote:

Originally Posted by OciXCrom (Post 2482292)
Rep = reputation, not report. :s

Agree, "re" would look better.

youssef_randy 01-01-2017 13:37

Re: [Help] Rate Admin (+rep , -rep)
 
Quote:

Originally Posted by OciXCrom (Post 2482292)
Rep = reputation, not report. :s

i'm not stupid ^.^

Bugsy 01-01-2017 18:50

Re: [Help] Rate Admin (+rep , -rep)
 
A clean way to do this would be to not have the plugin modify users.ini automatically, while it will still remove the users admin flags each time he connects. This removal will be in a log file and you can check this (in a MOTD if you want) periodically and if you decide you then want to remove him from users.ini, you can.

youssef_randy 01-02-2017 06:58

Re: [Help] Rate Admin (+rep , -rep)
 
Quote:

Originally Posted by Bugsy (Post 2482543)
A clean way to do this would be to not have the plugin modify users.ini automatically, while it will still remove the users admin flags each time he connects. This removal will be in a log file and you can check this (in a MOTD if you want) periodically and if you decide you then want to remove him from users.ini, you can.

Thanks i'll try it ! ^^

Bugsy 01-03-2017 21:37

Re: [Help] Rate Admin (+rep , -rep)
 
Here's the first draft. Once an admin accumulates 12 minus votes, his admin power will be removed the next time he connects. The calculation is done using [minus votes] - [plus votes]; so if he has 15 minus votes and 5 plus votes (10 total minus), he is ok and keeps admin, but if has 15 minus and 2 plus (13 minus), he loses admin. Each vote on the admin is remembered between admin connections so you can keep track of votes over time. Each vote is stored in a log file so you can see if the same player re-votes for a specific admin. I'm thinking of bringing in nVault Utility to show a MOTD displaying each admin and their vote counts.

What I think would be better is to only allow each player to vote a specific admin 1 time. It does do this per-connection, but if the player disconnects/re-connects, he can again vote the same admin.

You will need nVault Array
PHP Code:


#include <amxmodx>
#include <nvault_array>

new const Version[] = "0.1";

#define MAX_PLAYERS 32

const AdminFlag ADMIN_IMMUNITY;

enum PlayerData
{
    
szName32 ],
    
szAuthID32 ],
    
bool:bIsAdmin,
    
iNumGood,
    
iNumBad,
    
bool:bVotedMAX_PLAYERS ]
}
new 
g_pdDataMAX_PLAYERS ][ PlayerData ];

new 
g_Vault g_pMinusVotes;

public 
plugin_init() 
{
    
register_plugin"Rate Admins" Version "bugsy" );
    
    
register_clcmd"say /eport" "ShowRateMenu" );
    
    
g_pMinusVotes register_cvar"ra_minusvotes" "12" );
    
    if ( ( 
g_Vault nvault_open"RateAdmins" ) ) == INVALID_HANDLE )
        
set_fail_state"Error opening vault" );
}

public 
plugin_end() 
{
    
nvault_closeg_Vault );
}

public 
client_authorizedid )
{
    
get_user_authidid g_pdDataid ][ szAuthID ] , charsmaxg_pdData[][ szAuthID ] ) );
    
    if ( ( 
g_pdDataid ][ bIsAdmin ] = bool:( get_user_flagsid ) & AdminFlag ) ) )
    {
        
nvault_get_arrayg_Vault g_pdDataid ][ szAuthID ] , g_pdDataid ][ szName ][ ] , sizeofg_pdData[] ) );
        
        if ( ( 
g_pdDataid ][ iNumBad ] - g_pdDataid ][ iNumGood ] ) >= get_pcvar_numg_pMinusVotes ) )
        {
            
set_user_flagsid ADMIN_USER );
        }
    }
    
    
get_user_nameid g_pdDataid ][ szName ] , charsmaxg_pdData[][ szName ] ) );
    
    
arraysetg_pdDataid ][ bVoted ] , false sizeofg_pdData[][ bVoted ] ) ); 
}

public 
client_disconnectid )
{
    if ( 
g_pdDataid ][ bIsAdmin ] )
    {
        
nvault_set_arrayg_Vault g_pdDataid ][ szAuthID ] , g_pdDataid ][ szName ][ ] , sizeofg_pdData[] ) );
    }
}

public 
ShowRateMenuid )
{
    new 
iMenu menu_create"\r[AW] \wAdmin Rate menu" "AdminHandler" );
    new 
szID] , iAdminsLoaded;
    
    for( new 
<= MAX_PLAYERS i++ )
    {
        if ( ( 
!= id ) && ( g_pdData][ bIsAdmin ] == true ) )
        {
            
num_to_strszID charsmaxszID ) );
            
menu_additemiMenu g_pdData][ szName ] , szID );
            
iAdminsLoaded++;
        }
    }
    
    if ( 
iAdminsLoaded )
    {
        
menu_displayid iMenu );
    }
    else
    {
        
client_printid print_chat "^4[AW]^3 There are no admins to vote." );
    }
    
    return 
PLUGIN_HANDLED;
}

public 
AdminHandlerid iMenu iKey )
{
    new 
iNewMenu szID] , iDummy;
    
    
menu_item_getinfoiMenu iKey iDummy szID charsmaxszID ) , "" iDummy );  
    
    
iNewMenu menu_createg_pdDatastr_to_numszID ) ][ szName ] , "RateHandler");
    
    
menu_additemiNewMenu "\r+Rep \yGood Admin" szID );
    
menu_additemiNewMenu "\r-Rep \yBad Admin" szID );
    
    
menu_displayid iNewMenu );
}

public 
RateHandlerid iMenu iKey )
{
    new 
szID] , iDummy iAdminID;
    
    if( 
iKey == MENU_EXIT )
    {
        
menu_destroyiMenu );
        return;
    }
    
    
menu_item_getinfoiMenu iKey iDummy szID charsmaxszID ) , "" iDummy );  
    
    
iAdminID str_to_numszID );
    
    if ( 
g_pdDataid ][ bVoted ][ iAdminID ] == true 
    {
        
client_print(idprint_chat"^4[AW]^3 You have already rated this Player");
    }
    else
    {
        
g_pdDataid ][ bVoted ][ iAdminID ] = true;
        
        
client_printid print_chat "%s's rate %s" g_pdDataiAdminID ][ szName ] , iKey == "plus" "minus" );
        
        
log_to_file"AdminRate.log" "%s (%s) voted %s for %s (%s)" g_pdDataid ][ szName ] , g_pdDataid ][ szAuthID ] , iKey == "PLUS" "MINUS" g_pdDataiAdminID ][ szName ] , g_pdDataiAdminID ][ szAuthID ] );
        
        if ( 
iKey == )
        {
            
g_pdDataiAdminID ][ iNumGood ]++;
        }
        else
        {
            
g_pdDataiAdminID ][ iNumBad ]++;
        }
    }



youssef_randy 01-04-2017 15:14

Re: [Help] Rate Admin (+rep , -rep)
 
Quote:

Originally Posted by Bugsy (Post 2483260)
Here's the first draft. Once an admin accumulates 12 minus votes, his admin power will be removed the next time he connects. The calculation is done using [minus votes] - [plus votes]; so if he has 15 minus votes and 5 plus votes (10 total minus), he is ok and keeps admin, but if has 15 minus and 2 plus (13 minus), he loses admin. Each vote on the admin is remembered between admin connections so you can keep track of votes over time. Each vote is stored in a log file so you can see if the same player re-votes for a specific admin. I'm thinking of bringing in nVault Utility to show a MOTD displaying each admin and their vote counts.

What I think would be better is to only allow each player to vote a specific admin 1 time. It does do this per-connection, but if the player disconnects/re-connects, he can again vote the same admin.

You will need nVault Array
PHP Code:


#include <amxmodx>
#include <nvault_array>

new const Version[] = "0.1";

#define MAX_PLAYERS 32

const AdminFlag ADMIN_IMMUNITY;

enum PlayerData
{
    
szName32 ],
    
szAuthID32 ],
    
bool:bIsAdmin,
    
iNumGood,
    
iNumBad,
    
bool:bVotedMAX_PLAYERS ]
}
new 
g_pdDataMAX_PLAYERS ][ PlayerData ];

new 
g_Vault g_pMinusVotes;

public 
plugin_init() 
{
    
register_plugin"Rate Admins" Version "bugsy" );
    
    
register_clcmd"say /eport" "ShowRateMenu" );
    
    
g_pMinusVotes register_cvar"ra_minusvotes" "12" );
    
    if ( ( 
g_Vault nvault_open"RateAdmins" ) ) == INVALID_HANDLE )
        
set_fail_state"Error opening vault" );
}

public 
plugin_end() 
{
    
nvault_closeg_Vault );
}

public 
client_authorizedid )
{
    
get_user_authidid g_pdDataid ][ szAuthID ] , charsmaxg_pdData[][ szAuthID ] ) );
    
    if ( ( 
g_pdDataid ][ bIsAdmin ] = bool:( get_user_flagsid ) & AdminFlag ) ) )
    {
        
nvault_get_arrayg_Vault g_pdDataid ][ szAuthID ] , g_pdDataid ][ szName ][ ] , sizeofg_pdData[] ) );
        
        if ( ( 
g_pdDataid ][ iNumBad ] - g_pdDataid ][ iNumGood ] ) >= get_pcvar_numg_pMinusVotes ) )
        {
            
set_user_flagsid ADMIN_USER );
        }
    }
    
    
get_user_nameid g_pdDataid ][ szName ] , charsmaxg_pdData[][ szName ] ) );
    
    
arraysetg_pdDataid ][ bVoted ] , false sizeofg_pdData[][ bVoted ] ) ); 
}

public 
client_disconnectid )
{
    if ( 
g_pdDataid ][ bIsAdmin ] )
    {
        
nvault_set_arrayg_Vault g_pdDataid ][ szAuthID ] , g_pdDataid ][ szName ][ ] , sizeofg_pdData[] ) );
    }
}

public 
ShowRateMenuid )
{
    new 
iMenu menu_create"\r[AW] \wAdmin Rate menu" "AdminHandler" );
    new 
szID] , iAdminsLoaded;
    
    for( new 
<= MAX_PLAYERS i++ )
    {
        if ( ( 
!= id ) && ( g_pdData][ bIsAdmin ] == true ) )
        {
            
num_to_strszID charsmaxszID ) );
            
menu_additemiMenu g_pdData][ szName ] , szID );
            
iAdminsLoaded++;
        }
    }
    
    if ( 
iAdminsLoaded )
    {
        
menu_displayid iMenu );
    }
    else
    {
        
client_printid print_chat "^4[AW]^3 There are no admins to vote." );
    }
    
    return 
PLUGIN_HANDLED;
}

public 
AdminHandlerid iMenu iKey )
{
    new 
iNewMenu szID] , iDummy;
    
    
menu_item_getinfoiMenu iKey iDummy szID charsmaxszID ) , "" iDummy );  
    
    
iNewMenu menu_createg_pdDatastr_to_numszID ) ][ szName ] , "RateHandler");
    
    
menu_additemiNewMenu "\r+Rep \yGood Admin" szID );
    
menu_additemiNewMenu "\r-Rep \yBad Admin" szID );
    
    
menu_displayid iNewMenu );
}

public 
RateHandlerid iMenu iKey )
{
    new 
szID] , iDummy iAdminID;
    
    if( 
iKey == MENU_EXIT )
    {
        
menu_destroyiMenu );
        return;
    }
    
    
menu_item_getinfoiMenu iKey iDummy szID charsmaxszID ) , "" iDummy );  
    
    
iAdminID str_to_numszID );
    
    if ( 
g_pdDataid ][ bVoted ][ iAdminID ] == true 
    {
        
client_print(idprint_chat"^4[AW]^3 You have already rated this Player");
    }
    else
    {
        
g_pdDataid ][ bVoted ][ iAdminID ] = true;
        
        
client_printid print_chat "%s's rate %s" g_pdDataiAdminID ][ szName ] , iKey == "plus" "minus" );
        
        
log_to_file"AdminRate.log" "%s (%s) voted %s for %s (%s)" g_pdDataid ][ szName ] , g_pdDataid ][ szAuthID ] , iKey == "PLUS" "MINUS" g_pdDataiAdminID ][ szName ] , g_pdDataiAdminID ][ szAuthID ] );
        
        if ( 
iKey == )
        {
            
g_pdDataiAdminID ][ iNumGood ]++;
        }
        else
        {
            
g_pdDataiAdminID ][ iNumBad ]++;
        }
    }



Wow man thank you so mush!

SomewhereLost 01-05-2017 06:14

Re: [Help] Rate Admin (+rep , -rep)
 
Quote:

I'm thinking of bringing in nVault Utility to show a MOTD displaying each admin and their vote counts.
This would be great


All times are GMT -4. The time now is 10:07.

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