Raised This Month: $ Target: $400
 0% 

[Help] Rate Admin (+rep , -rep)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
youssef_randy
Junior Member
Join Date: Dec 2016
Location: Morocco
Old 12-31-2016 , 12:13   [Help] Rate Admin (+rep , -rep)
Reply With Quote #1

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);

youssef_randy is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-31-2016 , 13:16   Re: [Help] Rate Admin (+rep , -rep)
Reply With Quote #2

Rep = reputation, not report. :s
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 12-31-2016 , 13:31   Re: [Help] Rate Admin (+rep , -rep)
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
Rep = reputation, not report. :s
Agree, "re" would look better.
__________________
edon1337 is offline
youssef_randy
Junior Member
Join Date: Dec 2016
Location: Morocco
Old 01-01-2017 , 13:37   Re: [Help] Rate Admin (+rep , -rep)
Reply With Quote #4

Quote:
Originally Posted by OciXCrom View Post
Rep = reputation, not report. :s
i'm not stupid ^.^
youssef_randy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-01-2017 , 18:50   Re: [Help] Rate Admin (+rep , -rep)
Reply With Quote #5

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.
__________________
Bugsy is offline
youssef_randy
Junior Member
Join Date: Dec 2016
Location: Morocco
Old 01-02-2017 , 06:58   Re: [Help] Rate Admin (+rep , -rep)
Reply With Quote #6

Quote:
Originally Posted by Bugsy View Post
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 ! ^^
youssef_randy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-03-2017 , 21:37   Re: [Help] Rate Admin (+rep , -rep)
Reply With Quote #7

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 ]++;
        }
    }

__________________

Last edited by Bugsy; 01-03-2017 at 22:06.
Bugsy is offline
youssef_randy
Junior Member
Join Date: Dec 2016
Location: Morocco
Old 01-04-2017 , 15:14   Re: [Help] Rate Admin (+rep , -rep)
Reply With Quote #8

Quote:
Originally Posted by Bugsy View Post
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!
youssef_randy is offline
SomewhereLost
AlliedModders Donor
Join Date: Mar 2014
Location: Tomorrowland
Old 01-05-2017 , 06:14   Re: [Help] Rate Admin (+rep , -rep)
Reply With Quote #9

Quote:
I'm thinking of bringing in nVault Utility to show a MOTD displaying each admin and their vote counts.
This would be great
__________________
SomewhereLost is offline
Send a message via Skype™ to SomewhereLost
Reply



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 18:41.


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