Jump to content

Kick player client and server :S


Sasu

Recommended Posts

Posted

Server-side:

local name = "" 
local reason = "" 
  
function kickear(source) 
local nombre = getPlayerFromName(name) 
kickPlayer(nombre, reason) 
end 
addEvent("onPlayerKick", true) 
addEventHandler("onPlayerKick", getRootElement(), kickear) 

Client-side:

function kickearButton(button, source, name, reason) 
if (button == kickButton) then 
triggerServerEvent("onPlayerKick", source, guiGetText( guiGridListGetSelectedItems ( playerLista ) ), guiGetText ( reasonEdit ) ) 
end 
end 
addEventHandler("onClientGUIClick", root, kickearButton) 

Nothings happened. And... How can I do when kick a player appear in the chat "Player has been kicked by Admin : Reason" ? :S

  • MTA Team
Posted

Remove the client script, below the kickPlayer() function where you kick the player type this: outputChatBox(".. has been banned!", root, 255, 0, 0, 0)

remember to edit the code

Posted

Try this:

Client:

function kickearButton () 
local playerName = guiGridListGetItemText ( playerLista, guiGridListGetSelectedItem ( playerLista ), 1 ) 
local reason = guiGetText ( reasonEdit ) 
if ( playerName ) then 
triggerServerEvent ( "onPlayerKick",localPlayer,tostring(playerName), tostring(reason)) 
    end 
end 
addEventHandler ( "onClientGUIClick", kickButton, kickearButton )  

Server:

function kickear (playerName,reason) 
        kickPlayer (getPlayerFromName(playerName), source, reason ) 
end 
addEvent ( "onPlayerKick", true ) 
addEventHandler ( "onPlayerKick", root, kickear ) 

Posted

@A Concerned Citizen wtf ? ._. I use a botton to kick the player and I said that appear in chat "Player has been kicked by Admin : Reason". I know outputChatBox but I dont know how to make variables :S

Posted
Try this:

Client:

function kickearButton () 
local playerName = guiGridListGetItemText ( playerLista, guiGridListGetSelectedItem ( playerLista ), 1 ) 
local reason = guiGetText ( reasonEdit ) 
if ( playerName ) then 
triggerServerEvent ( "onPlayerKick",localPlayer,tostring(playerName), tostring(reason)) 
    end 
end 
addEventHandler ( "onClientGUIClick", kickButton, kickearButton )  

Server:

function kickear (playerName,reason) 
        kickPlayer (getPlayerFromName(playerName), source, reason ) 
end 
addEvent ( "onPlayerKick", true ) 
addEventHandler ( "onPlayerKick", root, kickear ) 

Doesnt work :S

Posted
playerLista = guiCreateGridList(10, 67, 187, 448, false, punishWindow) 
        columnPlayers = guiGridListAddColumn( playerLista, "Jugadores", 0.85 ) 
  
function update ( old, new ) 
    if ( eventName == "onClientPlayerJoin" ) then 
        guiGridListSetItemText ( playerLista, guiGridListAddRow ( playerLista), columnPlayers, getPlayerName ( source ), false, false ) 
    elseif ( eventName == "onClientPlayerQuit" ) then 
        for row = 0, guiGridListGetRowCount ( playerLista) do 
            if ( guiGridListGetItemText ( playerLista, row, columnPlayers) == getPlayerName ( source ) ) then 
                guiGridListRemoveRow ( playerLista, row ) 
                break 
            end 
        end 
    elseif ( eventName == "onClientPlayerChangeNick" ) then 
        for row = 0, guiGridListGetRowCount ( playerLista) do 
            if ( guiGridListGetItemText ( playerLista, row, columnPlayers) == old ) then 
                guiGridListSetItemText ( playerLista, row, columnPlayers, new, false, false ) 
                break 
            end 
        end 
    end 
end 
addEventHandler ( "onClientPlayerJoin", root, update ) 
addEventHandler ( "onClientPlayerQuit", root, update ) 
addEventHandler ( "onClientPlayerChangeNick", root, update ) 
  
function getAllPlayers (  ) 
    guiGridListClear( playerLista ) 
    for i,v in ipairs( getElementsByType( "player" ) ) do 
        local row = guiGridListAddRow( playerLista ) 
        guiGridListSetItemText( playerLista, row, 1, getPlayerName( v ), false, false ) 
    end 
end 

Posted

client :

function kickearButton (text, editText) 
    if (source == kickButton) then 
        local selected = guiGridListGetSelectedItem( playerLista ) 
        local text = guiGridListGetItemText( playerLista, selected, 1 ) 
        local editText = guiGetText( reasonEdit ) 
        triggerServerEvent("onPlayerKick", root, text, editText ) 
    end 
end 
addEventHandler("onClientGUIClick", root, kickearButton) 

server :

function kickear(text, editText) 
    local nombre = getPlayerFromName(text) 
    kickPlayer(nombre, editText) 
end 
addEvent("onPlayerKick", true) 
addEventHandler("onPlayerKick", getRootElement(), kickear) 

And make sure your script is added in Admin group at the ACL .
Posted

When No reasons it kick the player but if I write a reason it doesnt kick the player. Error on debug 3: Bad Argument @ 'kickPlayer'

Posted

Because when there is a reason you need to include the responsible person for the kick in the kickPlayer function.

So pass the localPlayer to the server and put it as the second argument for kickPlayer.

Actually it's optional but go ahead and do that anyways.

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