Liberty Unleashed
Scripting => Script Help => Topic started by: CANYON on August 22, 2012, 09:55:48 pm
-
How to make connect/disconnect messages in chat?)
-
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
-
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?
function OnPlayerJoin( player )
{
Message( "Blah " + player.Name + " Blah" );
}
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;
}
-
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..
-
Also, this might be more efficient:
From this:
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:
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;
}
-
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.
-
Right, thanks man. I think somebody needs to update the wiki to add that to it.
-
Right, thanks man. I think somebody needs to update the wiki to add that to it.
I keep telling VRocker! ;D
-
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 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. :)
-
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.
-
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.