Jump to content

Kickplayer (attacker) ?


Adde

Recommended Posts

Hello

I have tried to create a function that kicks the player who kills another player (no dm) and then output a message in chatbox. I have tried to figure out how to make it work. I read on wiki, looked at other scripts and searched on forum. The thing is that I don´t really know how to do so it get the killer, or if I´m close being right

I´m stuck and I have added and removed things all the time. This is what I have atm:

Function KickDM(killer) 
if ( attacker ) then 
  if ( getElementType ( attacker ) == "player" ) then 
    kickPlayer(attacker,"You have been kicked for killing another player") 
      outputChatBox(getPlayerName(attacker).."have been kicked for DM!", getRootElement, 250, 60, 60, true) 
    end 
end 
addEventHandler("onPlayerWasted",getRootElement,kickDM) 
  

I don´t have any ideas left -.-

I would be glad for help :)

Edited by Guest
Link to comment

I dont really know what you want,but try this:

function KickDM(attacker) 
if ( attacker ) then 
  if ( getElementType ( attacker ) == "player" ) then 
    kickPlayer(attacker,"You have been kicked for killing another player") 
      outputChatBox(getPlayerName(attacker).."have been kicked for DM!", getRootElement, 250, 60, 60, true) 
    end 
end 
addEventHandler("onPlayerWasted",getRootElement,KickDM) 
  

Link to comment

Try this one

function KickDM ( _, attacker ) 
    if ( attacker ) then 
        if ( getElementType ( attacker ) == "player" ) then 
            kickPlayer ( attacker, "You have been kicked for killing another player" ) 
            outputChatBox ( getPlayerName ( attacker ) .. " have been kicked for DM!", root, 250, 60, 60, true ) 
        end 
    end 
end 
addEventHandler ( "onPlayerWasted", root, KickDM ) 

Link to comment
function KickDM ( _, attacker ) 
    if ( attacker ) then 
        if ( getElementType ( attacker ) == "player" ) then 
            outputChatBox ( getPlayerName ( attacker ) .. " have been kicked for DM!", root, 250, 60, 60, true ) 
            kickPlayer ( attacker, "You have been kicked for killing another player" ) 
        end 
    end 
end 
addEventHandler ( "onPlayerWasted", root, KickDM ) 

outputChatBox has to go first, if you do it after kickPlayer, it'll say that expected a player element, but got nil at getPlayerName.

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