FuriouZ Posted May 11, 2013 Share Posted May 11, 2013 Hey, i have a question what i doesn't find from wiki. How to sctipt disconnceting from server,what functions i need ? Like i created a gui and i need that if i click to 'quit' button,then i disconnet from server. What i have to paste here ? Serverside: function quitButton ( ) [[HERE]] end addEvent( "quitButton", true ) addEventHandler( "quitButton", getRootElement(), quitButton ) Link to comment
3NAD Posted May 11, 2013 Share Posted May 11, 2013 Hmm.. i guess you need to use " disconnect " or " quit " command by this executeCommandHandler Or Use this kickPlayer Link to comment
TAPL Posted May 11, 2013 Share Posted May 11, 2013 Hmm.. i guess you need to use " disconnect " or " quit " command by this executeCommandHandler NOTE: You can only execute commands created by Lua. You cannot execute MTA harcoded commands due to security reasons. Link to comment
FuriouZ Posted May 11, 2013 Author Share Posted May 11, 2013 Doesn't work --Quit Button function quitButton ( playerSource, commandName ) if ( playerSource ) executeCommandHandler ( "quit", playerSource ) end end addEvent( "quitButton", true ) addEventHandler( "quitButton", getRootElement(), quitButton ) Link to comment
iPrestege Posted May 11, 2013 Share Posted May 11, 2013 Hmmm..You can make a function with a command handler then execute the command : addCommandHandler executeCommandHandler kickPlayer * You can use the same command handler with execute with any resource . Link to comment
Sasu Posted May 11, 2013 Share Posted May 11, 2013 You forgot 'then' --Quit Button function quitButton ( playerSource, commandName ) if ( playerSource ) then executeCommandHandler ( "quit", playerSource ) end end addEvent( "quitButton", true ) addEventHandler( "quitButton", getRootElement(), quitButton ) Link to comment
iPrestege Posted May 11, 2013 Share Posted May 11, 2013 Hmm.. i guess you need to use " disconnect " or " quit " command by this executeCommandHandler NOTE: You can only execute commands created by Lua. You cannot execute MTA harcoded commands due to security reasons. @ Sasuke ! Link to comment
FuriouZ Posted May 11, 2013 Author Share Posted May 11, 2013 Doesn't work,no errors in debug . Link to comment
iPrestege Posted May 11, 2013 Share Posted May 11, 2013 As i said above read my post #1 You have to create function to kick the player and add the command handler then execute the command that's all . Link to comment
FuriouZ Posted May 11, 2013 Author Share Posted May 11, 2013 I tryed both of them but still nothing Server: --Quit Button function quitButton ( playerSource, commandName ) if ( playerSource ) then executeCommandHandler ( "disconnect", playerSource ) end end addEvent( "quitButton", true ) addEventHandler( "quitButton", getRootElement(), quitButton ) A part from client: addEventHandler("onClientGUIClick", root, function() if source == GUIEditor.button[1] then triggerServerEvent ( "quitButton", getLocalPlayer() ) elseif source == GUIEditor.button[3] then triggerServerEvent ( "commandButton", getLocalPlayer() ) end end ) And debug (tryed restarting,pressing quit button,but no errors) Link to comment
Castillo Posted May 11, 2013 Share Posted May 11, 2013 1: Do you even read what they said? you can't execute hard coded commands. 2: 'playerSource' and 'commandName' is nil on your code, you must use 'source'. Link to comment
3NAD Posted May 11, 2013 Share Posted May 11, 2013 You triggered with ' localPlayer ' .. triggerServerEvent ( "quitButton", getLocalPlayer() ) So the ' source ' @ server side; will be the player who triggered the event, I didn't try it. function quitButton ( ) kickPlayer ( source, source, "Quit" ) -- needs resource permissions end addEvent ( "quitButton", true ) addEventHandler ( "quitButton", root, quitButton ) Link to comment
Cadu12 Posted May 11, 2013 Share Posted May 11, 2013 "NOTE: You can only execute commands created by Lua. You cannot execute MTA harcoded commands due to security reasons." Why don't you can read wiki what they are saying? It doesn't work if you are using "quit", "disconnect", "connect", etc Here is command list: https://wiki.multitheftauto.com/wiki/Client_Commands Link to comment
iPrestege Posted May 11, 2013 Share Posted May 11, 2013 addCommandHandler("QuitFromServer", function ( player ) kickPlayer ( player , "The Reason" ) end ) addEvent( "quitButton", true ) addEventHandler( "quitButton", getRootElement(), function ( ) local player = source if not ( isElement ( player ) ) then return end executeCommandHandler ( "QuitFromServer", player ) end ) Link to comment
FuriouZ Posted May 11, 2013 Author Share Posted May 11, 2013 addCommandHandler("QuitFromServer", function ( player ) kickPlayer ( player , "The Reason" ) end ) addEvent( "quitButton", true ) addEventHandler( "quitButton", getRootElement(), function ( ) local player = source if not ( isElement ( player ) ) then return end executeCommandHandler ( "QuitFromServer", player ) end ) Debug: s_settings.lua:12: Access denied @ 'executeCommandHandler' still doesn't work Link to comment
xXMADEXx Posted May 11, 2013 Share Posted May 11, 2013 In the admin ACL put: <object name="resource.YourResourceName" /> Link to comment
3NAD Posted May 12, 2013 Share Posted May 12, 2013 You triggered with ' localPlayer ' .. triggerServerEvent ( "quitButton", getLocalPlayer() ) So the ' source ' @ server side; will be the player who triggered the event, I didn't try it. function quitButton ( ) kickPlayer ( source, source, "Quit" ) -- needs resource permissions end addEvent ( "quitButton", true ) addEventHandler ( "quitButton", root, quitButton ) Talking to myself ! Link to comment
FuriouZ Posted May 12, 2013 Author Share Posted May 12, 2013 Okay,it works,thanks,but there isn't other way widhout kick'ing player ? Link to comment
iPrestege Posted May 12, 2013 Share Posted May 12, 2013 As far as i know there's no way . Link to comment
TAPL Posted May 12, 2013 Share Posted May 12, 2013 Other way? I am thinking about redirect the player to fake IP and Port. 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