'LinKin Posted November 16, 2013 Posted November 16, 2013 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?
Chronic Posted November 16, 2013 Posted November 16, 2013 addEventHandler("onPlayerQuit", root, function () local selectedTeam = getTeamName(getPlayerTeam(source)) if selectedTeam then outputChatBox(selectedTeam.." quits") end end )
Tete omar Posted November 16, 2013 Posted November 16, 2013 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.
Chronic Posted November 16, 2013 Posted November 16, 2013 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..
Tete omar Posted November 16, 2013 Posted November 16, 2013 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.
Chronic Posted November 16, 2013 Posted November 16, 2013 Oh nevermind I thought you were trying to say something else
'LinKin Posted November 17, 2013 Author Posted November 17, 2013 addEventHandler("onPlayerQuit", root, function () local selectedTeam = getTeamName(getPlayerTeam(source)) if selectedTeam then outputChatBox(selectedTeam.." quits") end end ) Doesn't work like this either
'LinKin Posted November 17, 2013 Author Posted November 17, 2013 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...
xXMADEXx Posted November 17, 2013 Posted November 17, 2013 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.
'LinKin Posted November 17, 2013 Author Posted November 17, 2013 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?
Chronic Posted November 18, 2013 Posted November 18, 2013 It should work, be sure to have a second person with you on the server to test it out
'LinKin Posted November 18, 2013 Author Posted November 18, 2013 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()
Moderators IIYAMA Posted November 18, 2013 Moderators Posted November 18, 2013 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.
TRANE152 Posted November 19, 2013 Posted November 19, 2013 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)
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