GanJaRuleZ Posted March 31, 2012 Share Posted March 31, 2012 Hai there , i just wanna ask you if it can be done , to add/remove/modify any "quitType" from onPlayerQuit Link to comment
drk Posted March 31, 2012 Share Posted March 31, 2012 You wanna change quit reason text? Then: addEventHandler ( 'onPlayerQuit', root, function ( reason ) if ( reason == 'Quit' ) then reason = 'Left'; elseif ( reason == 'Timed out' ) then reason = 'Lost connection'; -- more and more end end ) I think this work too: local reasons = { [ 'Quit' ] = 'Left'; [ 'Timed out' ] = 'Lost Connection'; } addEventHandler ( 'onPlayerQuit', root, function ( reason ) if ( reasons [ tostring ( reason ) ] ) then reason = reasons [ tostring ( reason ) ] [ 1 ] outputChatBox ( getPlayerName ( source ) .. 'left the game. Reason: ' .. reason, root, 255, 255, 255, false ); end end ) Link to comment
Kenix Posted March 31, 2012 Share Posted March 31, 2012 local tReasons = { [ 'Unknown' ] = 'Unknown'; [ 'Banned' ] = 'Banned'; [ 'Bad Connection' ] = 'Bad Connection'; [ 'Kicked' ] = 'Kicked'; [ 'Quit' ] = 'Left'; [ 'Timed out' ] = 'Lost Connection'; } addEventHandler ( 'onPlayerQuit', root, function ( sReason ) if tReasons [ sReason ] then outputChatBox ( getPlayerName ( source ) .. 'left the game. Reason: ' .. tReasons [ sReason ], root, 255, 255, 255, false ) end end ) Draken reason = reasons [ tostring ( reason ) ] [ 1 ] It's wrong. Because in your table not have this index. You have string only. If you not understand. t = { [1] = '...' } print( t[1] ) -- ... t = { ['my index'] = 'my value' } print( t['my index'] ) -- my value 1 Link to comment
GanJaRuleZ Posted March 31, 2012 Author Share Posted March 31, 2012 But , how to make like these : I do command /switch ( switches the server ) ( Actually made it ) I want to output like this : ..Player.. went to the another server , do /switch to follow him. Now it outputs like this : ..Player.. left from server [ Quit ] So , i need to output a new message for each reason , i think i forgot to say it Link to comment
drk Posted March 31, 2012 Share Posted March 31, 2012 Add the message to the table and output it. local tReasons = { [ 'Unknown' ] = 'Unknown'; [ 'Banned' ] = 'Banned'; [ 'Bad Connection' ] = 'Bad Connection'; [ 'Kicked' ] = 'Kicked'; [ 'Quit' ] = 'Left'; [ 'Timed out' ] = 'Lost Connection'; } addEventHandler ( 'onPlayerQuit', root, function ( sReason ) if tReasons [ sReason ] then outputChatBox ( getPlayerName ( source ) .. 'left the game. Reason: ' .. tReasons [ sReason ], root, 255, 255, 255, false ) end end ) Draken reason = reasons [ tostring ( reason ) ] [ 1 ] It's wrong. Because in your table not have this index. You have string only. If you not understand. t = { [1] = '...' } print( t[1] ) -- ... t = { ['my index'] = 'my value' } print( t['my index'] ) -- my value I understand, I forgot these things I tested later and i've seen. 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now