Sasu Posted March 12, 2013 Posted March 12, 2013 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" ?
MTA Team qaisjp Posted March 12, 2013 MTA Team Posted March 12, 2013 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
TheIceman1 Posted March 12, 2013 Posted March 12, 2013 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 )
Sasu Posted March 12, 2013 Author Posted March 12, 2013 @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
Sasu Posted March 12, 2013 Author Posted March 12, 2013 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
OGF Posted March 12, 2013 Posted March 12, 2013 Iceman you don't have to do tostring, because they are already strings.
PaiN^ Posted March 12, 2013 Posted March 12, 2013 Show the gridlist and how you add players in it, And make sure your script is added in Admin group at the ACL .
Sasu Posted March 12, 2013 Author Posted March 12, 2013 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
PaiN^ Posted March 12, 2013 Posted March 12, 2013 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 .
Sasu Posted March 12, 2013 Author Posted March 12, 2013 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'
OGF Posted March 12, 2013 Posted March 12, 2013 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.
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