Vice City: Multiplayer

Server Development => Scripting and Server Management => Script and Content Requests => Topic started by: D4rkR420R on Aug 18, 2017, 01:42 AM

Title: Custom Tags in OnPlayerChat
Post by: D4rkR420R on Aug 18, 2017, 01:42 AM
Dear fellows, I would like to find a method into adding a tag next to the player's name and it's text (onPlayerChat( player, text )). However, I'm unable to add it next to the player.Name with either Message or ClientMessageToAll. How would I be able to add a tag like for ex. [Math Lover] player.Name?
Title: Re: Custom Tags in OnPlayerChat
Post by: Xmair on Aug 18, 2017, 04:21 AM
I believe this is what you're looking for:
function onPlayerChat( player, text )
{

Message( "[#CC0000][TAG] [$FF]" + player.Name + ": " + text );
return 0; // You must return 0 for the server to not use the regular text

}
Title: Re: Custom Tags in OnPlayerChat
Post by: W3aPoN^ on Aug 18, 2017, 05:53 AM
Yeah Use Xmairs Code or Get an Idea From DNUS Script
Title: Re: Custom Tags in OnPlayerChat
Post by: D4rkR420R on Aug 18, 2017, 02:41 PM
Quote from: Xmair on Aug 18, 2017, 04:21 AMI believe this is what you're looking for:
function onPlayerChat( player, text )
{

Message( "[#CC0000][TAG] [$FF]" + player.Name + ": " + text );
return 0; // You must return 0 for the server to not use the regular text

}
Question: Is this another method of color coding?
[$FF]
Title: Re: Custom Tags in OnPlayerChat
Post by: Xmair on Aug 18, 2017, 02:45 PM
Quote from: DarkRaZoR^ on Aug 18, 2017, 02:41 PM
Quote from: Xmair on Aug 18, 2017, 04:21 AMI believe this is what you're looking for:
function onPlayerChat( player, text )
{

Message( "[#CC0000][TAG] [$FF]" + player.Name + ": " + text );
return 0; // You must return 0 for the server to not use the regular text

}
Question: Is this another method of color coding?
[$FF]
[$FF] = original colour
For example:
ClientMessageToAll( "[#FF0000]Test [$FF]Test", 255, 255, 0 );You'll notice the yellow colour is applied when I used [$FF]
Title: Re: Custom Tags in OnPlayerChat
Post by: D4rkR420R on Aug 18, 2017, 02:49 PM
Quote from: Xmair on Aug 18, 2017, 02:45 PM
Quote from: DarkRaZoR^ on Aug 18, 2017, 02:41 PM
Quote from: Xmair on Aug 18, 2017, 04:21 AMI believe this is what you're looking for:
function onPlayerChat( player, text )
{

Message( "[#CC0000][TAG] [$FF]" + player.Name + ": " + text );
return 0; // You must return 0 for the server to not use the regular text

}
Question: Is this another method of color coding?
[$FF]
[$FF] = original colour
For example:
ClientMessageToAll( "[#FF0000]Test [$FF]Test", 255, 255, 0 );You'll notice the yellow colour is applied when I used [$FF]
Thank you for answering my question. I'll make an EDIT on this reply if your code worked.
Title: Re: Custom Tags in OnPlayerChat
Post by: D4rkR420R on Aug 18, 2017, 07:02 PM
Edit: This code isn't working for the reason maybe due to the mute system functionality.
Title: Re: Custom Tags in OnPlayerChat
Post by: Xmair on Aug 19, 2017, 04:32 AM
Quote from: DarkRaZoR^ on Aug 18, 2017, 07:02 PMEdit: This code isn't working for the reason maybe due to the mute system functionality.
Post your onPlayerChat
Title: Re: Custom Tags in OnPlayerChat
Post by: D4rkR420R on Aug 19, 2017, 01:58 PM
Quote from: Xmair on Aug 19, 2017, 04:32 AM
Quote from: DarkRaZoR^ on Aug 18, 2017, 07:02 PMEdit: This code isn't working for the reason maybe due to the mute system functionality.
Post your onPlayerChat

function onPlayerChat( player, text )
{
    if ( IsMuted[ player.ID ] == true )
          {
           MessagePlayer("[#FF0000]Error: You had been muted.", player );
           return 0;
          }
local MUTE_DIVIDE = 1000;
       if ( ( time() - antiSpamTime[ player.ID ] ) <= LIMIT_REP_TIME )
   {
        antiSpamWarnings[ player.ID ]++;
       if ( antiSpamWarnings[ player.ID ] >= LIMIT_REP_SPAM )
   {
        if( !IsMuted[ player.ID ] )
{
         IsMuted[ player.ID ] = true;
  Message(format( "[#2aff00][Info][#FF0000] Auto-Muted: %s | Reason: spamming the chat. Duration: %d seconds ", player.Name,MUTE_TIME/MUTE_DIVIDE) );
  NewTimer( "autounmute", MUTE_TIME.tointeger(),1, player.ID );
    }
  }

    else
    {
   antiSpamWarnings[ player.ID ] = 0;
}
    antiSpamTime[ player.ID ] = time();
    if( IsMuted[ player.ID ] )
    {
   return 0;
   MessagePlayer( "[#FF0000]Error: You have been muted.", player );
}
    else return 1;
Message( "[#CC0000][User] [$FF]" + player.Name + ": " + text );
 return 0; // You must return 0 for the server to not use the regular text
}
Title: Re: Custom Tags in OnPlayerChat
Post by: KAKAN on Aug 19, 2017, 02:36 PM
dafuq did I just see?
function onPlayerChat( player, text )
{
    if ( IsMuted[ player.ID ] == true )
          {
           MessagePlayer("[#FF0000]Error: You have been muted.", player );
           return 0;
          }
 local MUTE_DIVIDE = 1000;
       if ( ( time() - antiSpamTime[ player.ID ] ) <= LIMIT_REP_TIME )
    {
        antiSpamWarnings[ player.ID ]++;
       if ( antiSpamWarnings[ player.ID ] >= LIMIT_REP_SPAM )
    {
        if( !IsMuted[ player.ID ] )
 {
         IsMuted[ player.ID ] = true;
   Message(format( "[#2aff00][Info][#FF0000] Auto-Muted: %s | Reason: spamming the chat. Duration: %d seconds ", player.Name,MUTE_TIME/MUTE_DIVIDE) );
   NewTimer( "autounmute", MUTE_TIME.tointeger(),1, player.ID );
     }
   }
 } 
    else
    {
    antiSpamWarnings[ player.ID ] = 0;
 }
    antiSpamTime[ player.ID ] = time();

 Message( "[#CC0000][User] [$FF]" + player.Name + ": " + text );
 return 0; // You must return 0 for the server to not use the regular text
}
Title: Re: Custom Tags in OnPlayerChat
Post by: D4rkR420R on Aug 19, 2017, 04:24 PM
Solved. @KAKAN