TheIceman1 Posted February 21, 2013 Share Posted February 21, 2013 Why this kick me and not the player that I choose in gridlist? Server side: function kickplay (text) if ( hasObjectPermissionTo ( source, "function.kickPlayer" ) ) then kickPlayer ( source, source, text ) end end addEvent ( "kickplayer", true ) addEventHandler ( "kickplayer", root, kickplay ) Client side(players on gridlist): for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, col, getPlayerName( playeritem ), false, false ) local name = getPlayerName ( playeritem ) local wl = getPlayerWantedLevel ( playeritem ) guiSetText ( GUIEditor_Label[1], "Name:"..name ) guiSetText ( GUIEditor_Label[5], "WantedLevel:"..wl ) end addEventHandler( "onClientGUIClick", GUIEditor_Grid[1], getplayer, false ) Client side: function kickplayer () local text = guiGetText ( GUIEditor_Edit[1] ) triggerServerEvent ( "kickplayer", getLocalPlayer(), text ) end addEventHandler ( "onClientGUIClick", GUIEditor_Button[5], kickplayer ) Link to comment
Castillo Posted February 21, 2013 Share Posted February 21, 2013 triggerServerEvent ( "kickplayer", getLocalPlayer(), text ) Is because you are triggering the local player as source. Link to comment
DNL291 Posted February 21, 2013 Share Posted February 21, 2013 You are kicking the sourcePlayer in kickplay function. Link to comment
TheIceman1 Posted February 21, 2013 Author Share Posted February 21, 2013 But this code dont kick player. triggerServerEvent ( "kickplayer", playeritem, text ) Link to comment
Castillo Posted February 21, 2013 Share Posted February 21, 2013 What is "playeritem"? Link to comment
iPrestege Posted February 21, 2013 Share Posted February 21, 2013 You Have To Get The Player Use : guiGridListGetItemText and guiGridListGetSelectedItem . Link to comment
TheIceman1 Posted February 22, 2013 Author Share Posted February 22, 2013 for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, col, getPlayerName( playeritem ), false, false ) local name = getPlayerName ( playeritem ) local wl = getPlayerWantedLevel ( playeritem ) guiSetText ( GUIEditor_Label[1], "Name:"..name ) guiSetText ( GUIEditor_Label[5], "WantedLevel:"..wl ) end addEventHandler( "onClientGUIClick", GUIEditor_Grid[1], getplayer, false ) @ Solidsnake14: From here? @Mr.Prestege: Why this dont kick me? function kickplayer () local playerNameK = guiGridListGetItemText ( GUIEditor_Grid[1], guiGridListGetSelectedItem ( GUIEditor_Grid[1] ), 1 ) local text = guiGetText ( GUIEditor_Edit[1] ) triggerServerEvent ( "kickplayer", playerNameK, text ) end addEventHandler ( "onClientGUIClick", GUIEditor_Button[5], kickplayer ) Link to comment
iPrestege Posted February 22, 2013 Share Posted February 22, 2013 function kickplayer () local playerNameK = guiGridListGetItemText ( GUIEditor_Grid[1], guiGridListGetSelectedItem ( GUIEditor_Grid[1] ), 1 ) local text = guiGetText ( GUIEditor_Edit[1] ) if ( playerNameK ) then triggerServerEvent ( "kickplayer", tostring(playerNameK), tostring(text)) end end addEventHandler ( "onClientGUIClick", GUIEditor_Button[5], kickplayer ) Link to comment
TheIceman1 Posted February 22, 2013 Author Share Posted February 22, 2013 Mr.Pres[T]ege said: function kickplayer () local playerNameK = guiGridListGetItemText ( GUIEditor_Grid[1], guiGridListGetSelectedItem ( GUIEditor_Grid[1] ), 1 ) local text = guiGetText ( GUIEditor_Edit[1] ) if ( playerNameK ) then triggerServerEvent ( "kickplayer", tostring(playerNameK), tostring(text)) end end addEventHandler ( "onClientGUIClick", GUIEditor_Button[5], kickplayer ) Dont work. Bad argument @ triggerServerEvent[ Expected element at argument 2, got string "TheIceman" Link to comment
Sora Posted February 22, 2013 Share Posted February 22, 2013 TheIceman1 said: Mr.Pres[T]ege said: function kickplayer () local playerNameK = guiGridListGetItemText ( GUIEditor_Grid[1], guiGridListGetSelectedItem ( GUIEditor_Grid[1] ), 1 ) local text = guiGetText ( GUIEditor_Edit[1] ) if ( playerNameK ) then triggerServerEvent ( "kickplayer", tostring(playerNameK), tostring(text)) end end addEventHandler ( "onClientGUIClick", GUIEditor_Button[5], kickplayer ) Dont work. Bad argument @ triggerServerEvent[ Expected element at argument 2, got string "TheIceman" cause you didn't type any element , element is required triggerServerEvent ( "kickplayer",localPlayer,tostring(playerNameK), tostring(text)) localPlayer is predefined variable. also you need to use getPlayerFromName in the serverside function kickplay (playerNameK,text) if ( hasObjectPermissionTo ( source, "function.kickPlayer" ) ) then kickPlayer (getPlayerFromName(playerNameK), source, text ) end end addEvent ( "kickplayer", true ) addEventHandler ( "kickplayer", root, kickplay ) Link to comment
TheIceman1 Posted February 22, 2013 Author Share Posted February 22, 2013 Sora said: TheIceman1 said: Mr.Pres[T]ege said: function kickplayer () local playerNameK = guiGridListGetItemText ( GUIEditor_Grid[1], guiGridListGetSelectedItem ( GUIEditor_Grid[1] ), 1 ) local text = guiGetText ( GUIEditor_Edit[1] ) if ( playerNameK ) then triggerServerEvent ( "kickplayer", tostring(playerNameK), tostring(text)) end end addEventHandler ( "onClientGUIClick", GUIEditor_Button[5], kickplayer ) Dont work. Bad argument @ triggerServerEvent[ Expected element at argument 2, got string "TheIceman" cause you didn't type any element , element is required triggerServerEvent ( "kickplayer",localPlayer,tostring(playerNameK), tostring(text)) localPlayer is predefined variable. also you need to use getPlayerFromName in the serverside function kickplay (playerNameK,text) if ( hasObjectPermissionTo ( source, "function.kickPlayer" ) ) then kickPlayer (getPlayerFromName(playerNameK), source, text ) end end addEvent ( "kickplayer", true ) addEventHandler ( "kickplayer", root, kickplay ) Working,thanks! Link to comment
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