Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- g_Ignores <- {};
- function onPlayerJoin( player ) {
- g_Ignores.rawset( player.ID, {} );
- }
- function onPlayerPart( player, reason ) {
- if( g_Ignores.rawin( player.ID ) ) {
- g_Ignores.rawdelete( player.ID );
- }
- }
- function onPlayerCommand( player, cmd, text ) {
- if( cmd == "ignore" ) {
- if( !text ) return MessagePlayer( "/ignore [ID/Name]", player );
- local plr = ( !IsNum( text ) ? FindPlayer( text ) : FindPlayer( text.tointeger() ) );
- if( !plr ) return MessagePlayer( "Invalid player", player );
- else if( g_Ignores.rawget( player.ID ).rawin( plr.ID ) ) return MessagePlayer( format( "You are already ignoring %s", plr.Name ), player );
- g_Ignores.rawget( player.ID ).rawset( plr.ID, true );
- MessagePlayer( format( "You are not ignoring %s", plr.Name ), player );
- }
- else if( cmd == "unignore" ) {
- if( !text ) return MessagePlayer( "/unignore [ID/Name]", player );
- local plr = ( !IsNum( text ) ? FindPlayer( text ) : FindPlayer( text.tointeger() ) );
- if( !plr ) return MessagePlayer( "Invalid player", player );
- else if( !g_Ignores.rawget( player.ID ).rawin( plr.ID ) ) return MessagePlayer( format( "You are not ignoring %s", plr.Name ), player );
- g_Ignores.rawget( player.ID ).rawdelete( plr.ID );
- MessagePlayer( format( "You are no longer ignoring %s", plr.Name ), player );
- }
- }
- function onPlayerChat( player, text ) {
- local playerIgnores = g_Ignores.rawget( player.ID );
- local MaxPlayers = GetMaxPlayers();
- for( local i = 0; i <= MaxPlayers; i++ ) {
- local plr = FindPlayer( i );
- if( !plr ) continue;
- local plrIgnores = g_Ignores.rawget( plr.ID );
- if( playerIgnores.rawin( plr.ID ) ) continue;
- else if( plrIgnores.rawin( player.ID ) ) continue;
- MessagePlayer( format( "%s: %s", player.Name, text ), plr );
- }
- return 0; //You must halt the event itself to avoid double chats
- }
Add Comment
Please, Sign In to add comment