Jump to content

[ Help ] kickPlayer "onPlayerWasted"


Recommended Posts

What is wrong? :(

function kickPlayerHandler ( killer, kickedname, reason ) 
    -- Get player element from the name 
    local kicked = getPlayerFromName ( killer ) 
  
        if ( killer ) and ( killer ~= source ) then 
        kickPlayer ( kicked, killer, reason ) 
         outputChatBox("No kill people!", 0,0,255) 
    end 
end 
  
addEventHandler ( "onPlayerWasted", getRootElement(), kickPlayerHandler ) 

Link to comment
function kickPlayerHandler(totalAmmo, killer) 
    if ( killer ) and ( killer ~= source ) then 
        kickPlayer(killer, "No kill people!") 
    end 
end 
addEventHandler("onPlayerWasted", root, kickPlayerHandler) 

The wrong is:

  • 1- You forgot totalAmmo parameter in onPlayerWasted event and you expect that this is the killer
  • 2- There is no need to getPlayerFromName function
  • 3- There is no reason parameter in onPlayerWasted event
  • 4- The killer gets kicked before the chat message appears
  • 5- You're defining killerWeapon as kickedname, this should be int though

I'm not sure about the chat message, but i think you want to output this chat message to the killer not to all players.

P.S. I recommend you to reread onPlayerWasted parameters

int totalAmmo, element killer, int killerWeapon, int bodypart [, bool stealth ] 

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