additions and changes

- adds /chatban
- adds /chatbanlist
- adds migration file to support chatban
- adjusts admin level commands to reflect new commands and also old
- moves command into correct admin level file
This commit is contained in:
Damen 2019-04-08 01:13:20 -04:00
parent 9fc85cc224
commit da68b881cb
8 changed files with 174 additions and 69 deletions

View File

@ -315,6 +315,10 @@ thread OnAttemptPlayerLogin( playerid, password[ ] )
// Log in player // Log in player
SendServerMessage( playerid, "You have " COL_GREEN "successfully" COL_WHITE " logged in!" ); SendServerMessage( playerid, "You have " COL_GREEN "successfully" COL_WHITE " logged in!" );
// Chat Ban Player
format( szBigString, sizeof( szBigString ), "SELECT * FROM `CHAT_BANS` WHERE `ID` = '%d' LIMIT 0,1", p_AccountID[ playerid ] );
mysql_function_query( dbHandle, szBigString, true, "ChatBanUponLogin", "d", playerid );
} }
else else
{ {

View File

@ -72,11 +72,13 @@ static stock
{ 2, "/mute", "Muting a player" }, { 2, "/mute", "Muting a player" },
{ 2, "/unmute", "Unmuting a player" }, { 2, "/unmute", "Unmuting a player" },
{ 2, "/kick", "Kicking a player from the server" }, { 2, "/kick", "Kicking a player from the server" },
{ 2, "/smlog", "Cash transaction log from a player" },
{ 2, "/iclog", "IC transaction log from a player" },
/* ** Level 3 Commands ** */ /* ** Level 3 Commands ** */
{ 3, "/chatban", "Bans a player from using all forms of chat" },
{ 3, "/unchatban", "Unbans a player from using all forms of chat" },
{ 3, "/banlog", "Finding ban information about a player" }, { 3, "/banlog", "Finding ban information about a player" },
{ 3, "/smlog", "Cash transaction log from a player" },
{ 3, "/iclog", "IC transaction log from a player" },
{ 3, "/resetwep", "Resetting weapons from a player" }, { 3, "/resetwep", "Resetting weapons from a player" },
{ 3, "/getip", "Getting IP of a player" }, { 3, "/getip", "Getting IP of a player" },
{ 3, "/geolocate", "Geographical location of a player" }, { 3, "/geolocate", "Geographical location of a player" },
@ -105,6 +107,7 @@ static stock
{ 3, "/countdown", "Countdown" }, { 3, "/countdown", "Countdown" },
{ 3, "/pingimmune", "Making a player immune from ping kicker" }, { 3, "/pingimmune", "Making a player immune from ping kicker" },
{ 3, "/ban", "Banning a player" }, { 3, "/ban", "Banning a player" },
{ 3, "/forceac" "Force a player to use CAC while playing the server" },
{ 3, "/bring", "Bring a player to you" }, { 3, "/bring", "Bring a player to you" },
/* ** Level 4 Commands ** */ /* ** Level 4 Commands ** */
@ -260,34 +263,6 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
return 1; return 1;
} }
/*CMD:acmds( playerid, params[ ] )
{
if ( p_AdminLevel[ playerid ] < 1 ) return SendError( playerid, ADMIN_COMMAND_REJECT );
SendClientMessage( playerid, COLOR_GREY, "|______________________________________| Admin Commands |_____________________________________|" );
SendClientMessage( playerid, COLOR_WHITE, " " );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 1: /goto, /spec(off), /(un)jail, /asay, /slap, /a, /getstats, /stpfr, /setskin, /frules, /fpc, /ticketlog" );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 1: /pinfo, /warn, /aspawn, /ans, /stpfa, /alog, /(un)freeze, /aod, /respawnalluv, /reports, /questions" );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 1: /respond, /mutelist, /aka, /arepair, /viewdeathmsg" );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 2: /kick, /vdestroy, /(un)mute, /explode, /vrespawn, /arenas, /suspend, /viewnotes, /slay" );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 3: /ban, /bring, /clearchat, /(ann)ounce, /giveweapon, /vadminpark, /vcreate, /healall, /getip, /smlog, /iclog" );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 3: /vadminstats, /pingimmune, /vbring, /countdown, /forcecoptutorial, /vgoto, /copwarn, /armywarn, /resetwep" );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 3: /venter, /geolocate" );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 4: /circleall, /giveweaponall, /resetwepall, /motd, /uncopban, /unarmyban, /setworld, /destroyallav, /gotopos" );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 4: /addnote, /removenote" );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 5: /createhouse, /destroyhouse, /respawnallv, /achangename, /toggleviewpm, /unban(ip)" );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 5: /createcar, /destroycar, /stripcarmods, /createbribe, /destroybribe, /doublexp, /(h/v)adminsell" );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 5: /autovehrespawn, /megaban, /acunban, /creategate, /editgate, /connectsong, /discordurl" );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 5: /creategarage, /destroygarage, /check, /reconnectchuff" );
if ( p_AdminLevel[ playerid ] > 5 ) {
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 6: /setirc, /seteventhost, /setlevel, /setleveloffline, /svrstats, /playaction, /playanimation" );
SendClientMessage( playerid, COLOR_WHITE, " LEVEL 6: /updaterules, /truncate, /broadcast, /setgangleader, /viewgangtalk, /createentrance, /destroyentrance" );
}
SendClientMessage( playerid, COLOR_GREY, "|_____________________________________________________________________________________________|" );
return 1;
}*/
/* ** Modules ** */ /* ** Modules ** */
#include "irresistible\cnr\commands\admin\admin_one.pwn" #include "irresistible\cnr\commands\admin\admin_one.pwn"
#include "irresistible\cnr\commands\admin\admin_two.pwn" #include "irresistible\cnr\commands\admin\admin_two.pwn"

View File

@ -714,3 +714,31 @@ CMD:mutelist( playerid, params[ ] )
else else
return ShowPlayerDialog( playerid, DIALOG_NULL, DIALOG_STYLE_TABLIST, ""COL_WHITE"Muted List", szNormalString, "Close", "" ), 1; return ShowPlayerDialog( playerid, DIALOG_NULL, DIALOG_STYLE_TABLIST, ""COL_WHITE"Muted List", szNormalString, "Close", "" ), 1;
} }
CMD:chatbanlist( playerid, params[ ] )
{
new
count = 0;
if ( p_AdminLevel[ playerid ] < 1 ) return SendError( playerid, ADMIN_COMMAND_REJECT );
szNormalString[ 0 ] = '\0';
foreach( new i : Player )
{
if ( p_ChatBanned{ i } )
{
format( szNormalString, sizeof( szNormalString ), "%s"COL_WHITE"%s(%d)\t"COL_GREY"By %s for '%s'\n",
szNormalString,
ReturnPlayerName( i ), i,
p_ChatBannedBy[ playerid ],
p_ChatBanReason[ playerid ]
);
count ++;
}
}
if ( count == 0 )
return SendError( playerid, "There are no chat banned players online." );
else
return ShowPlayerDialog( playerid, DIALOG_NULL, DIALOG_STYLE_TABLIST, ""COL_WHITE"Chat Ban List", szNormalString, "Close", "" ), 1;
}

View File

@ -6,40 +6,6 @@
*/ */
/* ** Commands ** */ /* ** Commands ** */
CMD:smlog( playerid, params[ ] )
{
new
pID
;
if ( p_AdminLevel[ playerid ] < 2 ) return SendError( playerid, ADMIN_COMMAND_REJECT );
else if ( sscanf( params, "u", pID ) ) return SendUsage( playerid, "/smlog [PLAYER_ID]" );
else if ( !IsPlayerConnected( pID ) || IsPlayerNPC( pID ) ) return SendError( playerid, "Invalid Player ID." );
else
{
format( szBigString, 160, "SELECT u.`NAME`,t.`CASH`,t.`DATE` FROM `TRANSACTIONS` t INNER JOIN `USERS` u ON t.`TO_ID`=u.`ID` WHERE FROM_ID=%d ORDER BY DATE DESC LIMIT 10", p_AccountID[ pID ] );
mysql_function_query( dbHandle, szBigString, true, "readmoneylog", "dd", playerid, pID );
}
return 1;
}
CMD:iclog( playerid, params[ ] )
{
new
pID
;
if ( p_AdminLevel[ playerid ] < 2 ) return SendError( playerid, ADMIN_COMMAND_REJECT );
else if ( sscanf( params, "u", pID ) ) return SendUsage( playerid, "/iclog [PLAYER_ID]" );
else if ( !IsPlayerConnected( pID ) || IsPlayerNPC( pID ) ) return SendError( playerid, "Invalid Player ID." );
else
{
format( szBigString, 160, "SELECT u.`NAME`,t.`IC`,t.`DATE` FROM `TRANSACTIONS_IC` t INNER JOIN `USERS` u ON t.`TO_ID`=u.`ID` WHERE FROM_ID=%d ORDER BY DATE DESC LIMIT 10", p_AccountID[ pID ] );
mysql_function_query( dbHandle, szBigString, true, "readiclog", "dd", playerid, pID );
}
return 1;
}
CMD:resetwep( playerid, params[ ] ) CMD:resetwep( playerid, params[ ] )
{ {
new new
@ -622,9 +588,9 @@ CMD:forceac( playerid, params[ ] )
pID; pID;
if ( p_AdminLevel[ playerid ] < 3 ) return SendError( playerid, ADMIN_COMMAND_REJECT ); if ( p_AdminLevel[ playerid ] < 3 ) return SendError( playerid, ADMIN_COMMAND_REJECT );
else if ( sscanf( params, "u", pID ) ) SendUsage( playerid, "/forceac [PLAYER_ID]" ); else if ( sscanf( params, "u", pID ) ) return SendUsage( playerid, "/forceac [PLAYER_ID]" );
else if ( !IsPlayerConnected( pID ) || IsPlayerNPC( pID ) ) return SendError( playerid, "Invalid Player ID." ); else if ( !IsPlayerConnected( pID ) || IsPlayerNPC( pID ) ) return SendError( playerid, "Invalid Player ID." );
else if ( pID == playerid ) return SendError( playerid, "You cant use this command on yourself." ); else if ( pID == playerid ) return SendError( playerid, "You can't use this command on yourself." );
else if ( p_AdminLevel[ pID ] > p_AdminLevel[ playerid ] ) return SendError( playerid, "You cannot use this command on admins higher than your level." ); else if ( p_AdminLevel[ pID ] > p_AdminLevel[ playerid ] ) return SendError( playerid, "You cannot use this command on admins higher than your level." );
//else if ( GetPlayerScore( pID ) < 100 ) return SendError( playerid, "This player's score is under 100, please spectate instead." ); //else if ( GetPlayerScore( pID ) < 100 ) return SendError( playerid, "This player's score is under 100, please spectate instead." );
else else
@ -644,3 +610,74 @@ CMD:forceac( playerid, params[ ] )
} }
return 1; return 1;
} }
CMD:chatban( playerid, params[ ] )
{
new pID, reason[ 25 ];
if ( p_AdminLevel[ playerid ] < 3 ) return SendError( playerid, ADMIN_COMMAND_REJECT );
else if ( sscanf( params, "us[50]", pID, reason ) ) return SendUsage( playerid, "/chatban [PLAYER_ID] [REASON]" );
else if ( strlen( reason ) < 3 || strlen( reason ) > 25 ) return SendError( playerid, "Please keep your chat ban reason between 3 - 25 characters." );
else if ( !IsPlayerConnected( pID ) || IsPlayerNPC( pID ) ) return SendError( playerid, "Invalid Player ID." );
else if ( pID == playerid ) return SendError( playerid, "You can't use this command on yourself." );
else if ( p_AdminLevel[ pID ] > p_AdminLevel[ playerid ] ) return SendError( playerid, "You cannot use this command on admins higher than your level." );
else if ( IsPlayerChatBanned( pID ) ) return SendError( playerid, "This player is already chat banned." );
else
{
p_ChatBanned{ pID } = true;
p_ChatBannedBy[ pID ] = ReturnPlayerName( playerid );
p_ChatBanReason[ pID ] = reason;
mysql_single_query( sprintf( "INSERT INTO `CHAT_BANS` (`ID`, `NAME`, `BANNED_BY_ID`, `BANNED_BY`, `REASON`) VALUES (%d, '%s', %d, '%s', '%s')", p_AccountID[ pID ], mysql_escape( ReturnPlayerName( pID ) ), p_AccountID[ playerid ], mysql_escape( ReturnPlayerName( playerid ) ), mysql_escape( reason ) ) );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[ADMIN]"COL_WHITE" You have been chat banned by %s for '%s'.", ReturnPlayerName( pID ), reason );
AddAdminLogLineFormatted( "%s(%d) has chat banned %s(%d)", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( pID ), pID );
SaveToAdminLog( playerid, p_AccountID[ pID ], "chat ban" );
}
return 1;
}
CMD:unchatban( playerid, params[ ] )
{
new pID;
if ( p_AdminLevel[ playerid ] < 3 ) return SendError( playerid, ADMIN_COMMAND_REJECT );
else if ( sscanf( params, "u", pID ) ) return SendUsage( playerid, "/chatban [PLAYER_ID]" );
else if ( !IsPlayerConnected( pID ) || IsPlayerNPC( pID ) ) return SendError( playerid, "Invalid Player ID." );
else if ( pID == playerid ) return SendError( playerid, "You can't use this command on yourself." );
else if ( !IsPlayerChatBanned( pID ) ) return SendError( playerid, "This player is not chat banned." );
else
{
p_ChatBanned{ pID } = false;
mysql_single_query( sprintf( "DELETE FROM `CHAT_BANS` WHERE `ID`=%d", p_AccountID[ pID ] ) );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[ADMIN]"COL_WHITE" You have been chat unbanned by %s.", ReturnPlayerName( pID ) );
AddAdminLogLineFormatted( "%s(%d) has chat unbanned %s(%d)", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( pID ), pID );
SaveToAdminLog( playerid, p_AccountID[ pID ], "chat unban" );
}
return 1;
}
thread ChatBanUponLogin( playerid )
{
new
rows, fields
;
cache_get_data( rows, fields );
if ( rows )
{
new banned_by[ MAX_PLAYER_NAME ], reason[ 25 ];
cache_get_field_content( 0, "BANNED_BY", banned_by );
cache_get_field_content( 0, "REASON", reason );
p_ChatBanned{ playerid } = true;
p_ChatBannedBy[ playerid ] = banned_by;
p_ChatBanReason[ playerid ] = reason;
print("done with chatbanuponlogin");
}
return 1;
}

View File

@ -6,6 +6,40 @@
*/ */
/* ** Commands ** */ /* ** Commands ** */
CMD:smlog( playerid, params[ ] )
{
new
pID
;
if ( p_AdminLevel[ playerid ] < 2 ) return SendError( playerid, ADMIN_COMMAND_REJECT );
else if ( sscanf( params, "u", pID ) ) return SendUsage( playerid, "/smlog [PLAYER_ID]" );
else if ( !IsPlayerConnected( pID ) || IsPlayerNPC( pID ) ) return SendError( playerid, "Invalid Player ID." );
else
{
format( szBigString, 160, "SELECT u.`NAME`,t.`CASH`,t.`DATE` FROM `TRANSACTIONS` t INNER JOIN `USERS` u ON t.`TO_ID`=u.`ID` WHERE FROM_ID=%d ORDER BY DATE DESC LIMIT 10", p_AccountID[ pID ] );
mysql_function_query( dbHandle, szBigString, true, "readmoneylog", "dd", playerid, pID );
}
return 1;
}
CMD:iclog( playerid, params[ ] )
{
new
pID
;
if ( p_AdminLevel[ playerid ] < 2 ) return SendError( playerid, ADMIN_COMMAND_REJECT );
else if ( sscanf( params, "u", pID ) ) return SendUsage( playerid, "/iclog [PLAYER_ID]" );
else if ( !IsPlayerConnected( pID ) || IsPlayerNPC( pID ) ) return SendError( playerid, "Invalid Player ID." );
else
{
format( szBigString, 160, "SELECT u.`NAME`,t.`IC`,t.`DATE` FROM `TRANSACTIONS_IC` t INNER JOIN `USERS` u ON t.`TO_ID`=u.`ID` WHERE FROM_ID=%d ORDER BY DATE DESC LIMIT 10", p_AccountID[ pID ] );
mysql_function_query( dbHandle, szBigString, true, "readiclog", "dd", playerid, pID );
}
return 1;
}
CMD:slay( playerid, params[ ] ) CMD:slay( playerid, params[ ] )
{ {
new new

View File

@ -52,6 +52,9 @@ new
// p_XP [ MAX_PLAYERS ], // p_XP [ MAX_PLAYERS ],
bool: p_Spectating [ MAX_PLAYERS char ], bool: p_Spectating [ MAX_PLAYERS char ],
bool: p_Muted [ MAX_PLAYERS char ], bool: p_Muted [ MAX_PLAYERS char ],
bool: p_ChatBanned [ MAX_PLAYERS char ],
p_ChatBannedBy [ MAX_PLAYERS ] [ MAX_PLAYER_NAME ],
p_ChatBanReason [ MAX_PLAYERS ] [ 25 ],
bool: p_InfectedHIV [ MAX_PLAYERS char ], bool: p_InfectedHIV [ MAX_PLAYERS char ],
p_AntiTextSpam [ MAX_PLAYERS ], p_AntiTextSpam [ MAX_PLAYERS ],
bool: p_BlockedPM [ MAX_PLAYERS ] [ MAX_PLAYERS ], bool: p_BlockedPM [ MAX_PLAYERS ] [ MAX_PLAYERS ],
@ -218,3 +221,5 @@ stock IsPlayerSpawned( playerid ) return p_Spawned{ playerid };
stock IsPlayerJailed( playerid ) return p_Jailed{ playerid }; stock IsPlayerJailed( playerid ) return p_Jailed{ playerid };
stock IsPlayerAdminOnDuty( playerid ) return p_AdminOnDuty{ playerid }; stock IsPlayerAdminOnDuty( playerid ) return p_AdminOnDuty{ playerid };
stock IsPlayerChatBanned( playerid ) return p_ChatBanned{ playerid };

View File

@ -0,0 +1,14 @@
-- CREATE A MIGRATION ENTRY
INSERT INTO `DB_MIGRATIONS` (`MIGRATION`) VALUES ('20190405_cnr_chat_ban_creation');
--BEGIN
-- CREATE TABLE
CREATE TABLE IF NOT EXISTS `CHAT_BANS` (
`ID` int(11) NOT NULL,
`NAME` varchar(25) DEFAULT NULL,
`BANNED_BY_ID` int(11) NOT NULL,
`BANNED_BY` varchar(25) DEFAULT NULL,
`REASON` varchar(25) DEFAULT NULL,
UNIQUE KEY `ID` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

View File

@ -521,6 +521,9 @@ public OnPlayerDisconnect( playerid, reason )
p_Cuffed { playerid } = false; p_Cuffed { playerid } = false;
justConnected { playerid } = true; justConnected { playerid } = true;
p_Muted { playerid } = false; p_Muted { playerid } = false;
p_ChatBanned { playerid } = false;
p_ChatBannedBy [ playerid ] [ 0 ] = '\0';
p_ChatBanReason [ playerid ] [ 0 ] = '\0';
p_MetalMelter [ playerid ] = 0; p_MetalMelter [ playerid ] = 0;
p_LeftCuffed { playerid } = false; p_LeftCuffed { playerid } = false;
p_PmResponder [ playerid ] = INVALID_PLAYER_ID; p_PmResponder [ playerid ] = INVALID_PLAYER_ID;
@ -1508,12 +1511,15 @@ public OnPlayerText( playerid, text[ ] )
return SendError( playerid, "An error occured, please try again." ), 0; return SendError( playerid, "An error occured, please try again." ), 0;
#endif #endif
if ( IsPlayerChatBanned( playerid ) )
return SendError( playerid, "You have been chat banned and are not allowed to chat."), 0;
if ( textContainsIP( text ) ) if ( textContainsIP( text ) )
return SendServerMessage( playerid, "Please do not advertise." ), 0; return SendServerMessage( playerid, "Please do not advertise." ), 0;
new tick_count = GetTickCount( ); new tick_count = GetTickCount( );
if ( p_AntiTextSpam[ playerid ] > tick_count ) if ( p_AntiTextSpam[ playerid ] > tick_count && p_AdminLevel[ playerid ] != 6 )
{ {
p_AntiTextSpam[ playerid ] = tick_count + 750; p_AntiTextSpam[ playerid ] = tick_count + 750;
p_AntiTextSpamCount{ playerid } ++; p_AntiTextSpamCount{ playerid } ++;
@ -2105,7 +2111,8 @@ CMD:cw( playerid, params[ ] ) return cmd_carwhisper( playerid, params );
CMD:carwhisper( playerid, params[ ] ) CMD:carwhisper( playerid, params[ ] )
{ {
new msg[ 100 ]; new msg[ 100 ];
if ( !IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You must be inside a vehicle to use this command." ); if ( p_ChatBanned{ playerid } ) return SendError( playerid, "You have been chat banned and are not allowed to chat." );
else if ( !IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You must be inside a vehicle to use this command." );
else if ( sscanf( params, "s[100]", msg ) ) return SendUsage( playerid, "/carwhisper [MESSAGE]" ); else if ( sscanf( params, "s[100]", msg ) ) return SendUsage( playerid, "/carwhisper [MESSAGE]" );
else if ( textContainsIP( msg ) ) return SendError( playerid, "Advertising is forbidden." ); else if ( textContainsIP( msg ) ) return SendError( playerid, "Advertising is forbidden." );
else else
@ -2124,7 +2131,8 @@ CMD:w( playerid, params[ ] ) return cmd_whisper( playerid, params );
CMD:whisper( playerid, params[ ] ) CMD:whisper( playerid, params[ ] )
{ {
new msg[ 100 ]; new msg[ 100 ];
if ( sscanf( params, "s[100]", msg ) ) return SendUsage( playerid, "/whisper [MESSAGE]" ); if ( p_ChatBanned{ playerid } ) return SendError( playerid, "You have been chat banned and are not allowed to chat." );
else if ( sscanf( params, "s[100]", msg ) ) return SendUsage( playerid, "/whisper [MESSAGE]" );
else if ( textContainsIP( msg ) ) return SendError( playerid, "Advertising is forbidden." ); else if ( textContainsIP( msg ) ) return SendError( playerid, "Advertising is forbidden." );
else else
{ {