Jump to content

quitType question :)


GanJaRuleZ

Recommended Posts

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
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 
  

  • Thanks 1
Link to comment

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

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 :mrgreen: I tested later and i've seen.

  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...