Author Topic: How to make connect/disconnect messages in chat?  (Read 2779 times)

CANYON

  • Newbie
  • *
  • Posts: 29
  • Karma: +1/-0
    • View Profile
How to make connect/disconnect messages in chat?
« on: August 22, 2012, 10:55:48 pm »
How to make connect/disconnect messages in chat?)

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: How to make connect/disconnect messages in chat?
« Reply #1 on: August 22, 2012, 11:39:41 pm »
For connecting: there is a clientside event called onPlayerJoin(). Returning 0 in this function will disable the built in message from appearing. Returning 1 will show the message.

This same thing goes for disconnecting, but with the clientside event called onPlayerPart().

Also, these constants in the wiki may be of some use for disconnecting:
PARTREASON_DISCONNECTED
PARTREASON_TIMEOUT
PARTREASON_KICKED
PARTREASON_BANNED

CANYON

  • Newbie
  • *
  • Posts: 29
  • Karma: +1/-0
    • View Profile
Re: How to make connect/disconnect messages in chat?
« Reply #2 on: August 23, 2012, 03:02:22 am »
For connecting: there is a clientside event called onPlayerJoin(). Returning 0 in this function will disable the built in message from appearing. Returning 1 will show the message.

This same thing goes for disconnecting, but with the clientside event called onPlayerPart().

Also, these constants in the wiki may be of some use for disconnecting:
PARTREASON_DISCONNECTED
PARTREASON_TIMEOUT
PARTREASON_KICKED
PARTREASON_BANNED

Correctly?

Code: [Select]
function OnPlayerJoin( player )
{
     Message( "Blah " + player.Name + " Blah" );
}

Code: [Select]
function onPlayerPart( player, reason )
{
     if ( reason == PARTREASON_DISCONNECTED ) Message( "Blah " + player.Name + " Blah Blah" );
     if ( reason == PARTREASON_TIMEOUT ) Message( "Blah " + player.Name + " Blah Blah" );
     if ( reason == PARTREASON_KICKED ) Message( "Blah " + player.Name + " Blah Blah" );
     if ( reason == PARTREASON_BANNED ) Message( "Blah " + player.Name + " Blah Blah." );
     
     return 1;
}

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: How to make connect/disconnect messages in chat?
« Reply #3 on: August 23, 2012, 11:15:30 am »
You need to return 0 in order to stop the default messages from appearing.
Also, You may stop asking Correctly? every time you make a script. Try it out and see if it works..

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: How to make connect/disconnect messages in chat?
« Reply #4 on: August 23, 2012, 02:59:26 pm »
Also, this might be more efficient:

From this:
Code: [Select]
if ( reason == PARTREASON_DISCONNECTED ) Message( pPlayer.Name + " has left the server (Reason: Disconnected)", Colour( 255, 0, 0 ) );
else if ( reason == PARTREASON_BANNED ) Message( pPlayer.Name + " has left the server (Reason: Banned)", Colour( 255, 0, 0 ) );
else if ( reason == PARTREASON_KICKED ) Message( pPlayer.Name + " has left the server (Reason: Kicked)", Colour( 255, 0, 0 ) );
else Message( pPlayer.Name + " has left the server (Reason: Crashed)", Colour( 255, 0, 0 ) );

To this:
Code: [Select]
switch(reason)
{
      case PARTREASON_DISCONNECTED:
              Message( pPlayer.Name + " has left the server (Reason: Disconnected)", Colour( 255, 0, 0 ) );
              break;

      case PARTREASON_BANNED:
              Message( pPlayer.Name + " has left the server (Reason: Banned)", Colour( 255, 0, 0 ) );
              break;

      case PARTREASON_KICKED:
              Message( pPlayer.Name + " has left the server (Reason: Kicked)", Colour( 255, 0, 0 ) );
              break;

      default:
              Message( pPlayer.Name + " has left the server (Reason: Crashed)", Colour( 255, 0, 0 ) );
              break;
}

SugarD

  • Argonath RPG Dev/Manager
  • Tester
  • Sr. Member
  • ****
  • Posts: 820
  • Karma: +37/-75
  • STOP IN THE NAME OF THE COLESLAW!
    • View Profile
    • Clan Xperience
Re: How to make connect/disconnect messages in chat?
« Reply #5 on: September 05, 2012, 11:04:56 pm »
For connecting: there is a clientside event called onPlayerJoin(). Returning 0 in this function will disable the built in message from appearing. Returning 1 will show the message.

This same thing goes for disconnecting, but with the clientside event called onPlayerPart().

Also, these constants in the wiki may be of some use for disconnecting:
PARTREASON_DISCONNECTED
PARTREASON_TIMEOUT
PARTREASON_KICKED
PARTREASON_BANNED
Don't forget PARTREASON_CRASHED.

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: How to make connect/disconnect messages in chat?
« Reply #6 on: September 06, 2012, 02:43:13 am »
Right, thanks man. I think somebody needs to update the wiki to add that to it.

SugarD

  • Argonath RPG Dev/Manager
  • Tester
  • Sr. Member
  • ****
  • Posts: 820
  • Karma: +37/-75
  • STOP IN THE NAME OF THE COLESLAW!
    • View Profile
    • Clan Xperience
Re: How to make connect/disconnect messages in chat?
« Reply #7 on: September 06, 2012, 02:52:01 am »
Right, thanks man. I think somebody needs to update the wiki to add that to it.
I keep telling VRocker! ;D

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: How to make connect/disconnect messages in chat?
« Reply #8 on: September 06, 2012, 03:32:16 am »
I wonder though, if it were possible to let certain community members edit the wiki too, as there a quite a few functions that need documentation (mostly client side), not to mention a lot more that need examples.

SugarD

  • Argonath RPG Dev/Manager
  • Tester
  • Sr. Member
  • ****
  • Posts: 820
  • Karma: +37/-75
  • STOP IN THE NAME OF THE COLESLAW!
    • View Profile
    • Clan Xperience
Re: How to make connect/disconnect messages in chat?
« Reply #9 on: September 06, 2012, 03:38:55 am »
I wonder though, if it were possible to let certain community members edit the wiki too, as there a quite a few functions that need documentation (mostly client side), not to mention a lot more that need examples.
I believe to some degree registered users can. If not, you can always send me the code for a page and I can update it for you. :)

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: How to make connect/disconnect messages in chat?
« Reply #10 on: September 06, 2012, 03:40:26 am »
Yeah, maybe it would be good to have users allowed to submit a change, but without it being visible, and a mod approve it or something so it changes.

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: How to make connect/disconnect messages in chat?
« Reply #11 on: September 06, 2012, 09:54:34 am »
You can request edit permissions by asking any LU dev (esspecially Juppi or VRocker).
We have disabled editing of the wiki for default users for anti-spamming reasons.

 

© Liberty Unleashed Team.