Jump to content

onPlayerQuit


'LinKin

Recommended Posts

  
function playerRaged() 
    local selectedTeam = getTeamName(getPlayerTeam(source)) 
    if selectedTeam then 
        outputChatBox(selectedTeam.." quits") 
    end 
end 
addEventHandler("onPlayerQuit", root, playerRaged) 
  

WARNING: @Bad Argument for getTeamName()

It is because the player leaves before the script can take the Team where he was in.

How can I achieve what I want?

Link to comment
function playerRaged ( ) 
    local team = getPlayerTeam ( source ) 
    if ( team ) then -- team will be false if the quitting player is not in a team, so we check if team is not false 
        local selectedTeam = getTeamName ( team ) 
        if ( selectedTeam ) then 
           outputChatBox ( selectedTeam .." quits" ) 
        end 
    end 
end 
addEventHandler ( "onPlayerQuit", root, playerRaged ) 

Your problem was probably because the quitting player is not in a team already.

Link to comment
function playerRaged ( ) 
    local team = getPlayerTeam ( source ) 
    if ( team ) then -- team will be false if the quitting player is not in a team, so we check if team is not false 
        local selectedTeam = getTeamName ( team ) 
        if ( selectedTeam ) then 
           outputChatBox ( selectedTeam .." quits" ) 
        end 
    end 
end 
addEventHandler ( "onPlayerQuit", root, playerRaged ) 

Your problem was probably because the quitting player is not in a team already.

That wouldn't be a reason for a bad argument..

Link to comment
addEventHandler("onPlayerQuit", root,  
    function () 
    local selectedTeam = getTeamName(getPlayerTeam(source)) 
        if selectedTeam then 
            outputChatBox(selectedTeam.." quits") 
        end 
    end 
) 

Doesn't work like this either

Link to comment
I'm sure this is the reason, |GMC|LinKin receives a warning of a bad argument in getTeamName which is simply because of getPlayerTeam does not return the team.

It's something like this.

As I said, It's like the function couldn't save the player's team who quits. I don't know...

Link to comment
function playerRaged ( ) 
    local team = getPlayerTeam ( source ) 
    if ( team ) then -- team will be false if the quitting player is not in a team, so we check if team is not false 
        local selectedTeam = getTeamName ( team ) 
        if ( selectedTeam ) then 
           outputChatBox ( selectedTeam .." quits" ) 
        end 
    end 
end 
addEventHandler ( "onPlayerQuit", root, playerRaged ) 

Your problem was probably because the quitting player is not in a team already.

Link to comment
function playerRaged ( ) 
    local team = getPlayerTeam ( source ) 
    if ( team ) then -- team will be false if the quitting player is not in a team, so we check if team is not false 
        local selectedTeam = getTeamName ( team ) 
        if ( selectedTeam ) then 
           outputChatBox ( selectedTeam .." quits" ) 
        end 
    end 
end 
addEventHandler ( "onPlayerQuit", root, playerRaged ) 

Your problem was probably because the quitting player is not in a team already.

The player who quits is in a team, but, since it quits, his team is 'gone' so this is why I cannot get the team where he was.

But I really need to do this, can anyone help on solving it?

Link to comment
It should work, be sure to have a second person with you on the server to test it out :)

I've tested it with more than 2 persons in the server..

And still: WARNING: @Bad Argument for getTeamName()

If I try to get the Players name and print it on ChatBox, it works. But it just doesn't work with the getTeamName()

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