Jump to content

onPlayerQuit


'LinKin

Recommended Posts

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

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

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

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

F4MZM4.gif

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

Posted

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.

F4MZM4.gif

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

Doesn't work like this either

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

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

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

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

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

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

Posted
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()

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

  • Moderators
Posted

It can only show that error at moments his team >element< got deleted at the exact same time.

I have that problem with my custom killmessages.

Conclusion: If that isn't the case, then his code isn't the same as this one.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

It works perfectly! Use server-side:

addEventHandler ( "onPlayerQuit", getRootElement(), function ( ) 
  local tm = getPlayerTeam ( source ) 
  if tm then 
    outputChatBox ( getTeamName(tm) .." quits" ) 
    outputDebugString ( getTeamName(tm) .." quits") 
  end 
end) 

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