Liberty Unleashed

Scripting => Script Help => Topic started by: CANYON on August 22, 2012, 09:55:48 pm

Title: How to make connect/disconnect messages in chat?
Post by: CANYON on August 22, 2012, 09:55:48 pm
How to make connect/disconnect messages in chat?)
Title: Re: How to make connect/disconnect messages in chat?
Post by: Vortrex on August 22, 2012, 10: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
Title: Re: How to make connect/disconnect messages in chat?
Post by: CANYON on August 23, 2012, 02: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;
}
Title: Re: How to make connect/disconnect messages in chat?
Post by: Thijn on August 23, 2012, 10: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..
Title: Re: How to make connect/disconnect messages in chat?
Post by: Vortrex on August 23, 2012, 01: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;
}
Title: Re: How to make connect/disconnect messages in chat?
Post by: SugarD on September 05, 2012, 10: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.
Title: Re: How to make connect/disconnect messages in chat?
Post by: Vortrex on September 06, 2012, 01:43:13 am
Right, thanks man. I think somebody needs to update the wiki to add that to it.
Title: Re: How to make connect/disconnect messages in chat?
Post by: SugarD on September 06, 2012, 01:52:01 am
Right, thanks man. I think somebody needs to update the wiki to add that to it.
I keep telling VRocker! ;D
Title: Re: How to make connect/disconnect messages in chat?
Post by: Vortrex on September 06, 2012, 02: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.
Title: Re: How to make connect/disconnect messages in chat?
Post by: SugarD on September 06, 2012, 02: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. :)
Title: Re: How to make connect/disconnect messages in chat?
Post by: Vortrex on September 06, 2012, 02: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.
Title: Re: How to make connect/disconnect messages in chat?
Post by: Thijn on September 06, 2012, 08: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.