iPanda Posted February 24, 2014 Share Posted February 24, 2014 (edited) How can i use function kickPlayer in client side for my GUI? I have code, but it don`t work! Help. server side: addEvent("kikcPlayer", true) addEventHandler("kikcPlayer", getRootElement(), function(kicked) if (type(kicked) == "player") then kickPlayer(client, kicked) end end) Then in client side i use client side: triggerServerEvent("kickPlayer", getLocalPlayer(), getLocalPlayer()) Edited February 24, 2014 by Guest Link to comment
Karuzo Posted February 24, 2014 Share Posted February 24, 2014 You made a typo in the serverside. 'kikcplayer' Link to comment
WASSIm. Posted February 24, 2014 Share Posted February 24, 2014 --change this giveWeapon(client, kicked) --to this giveWeapon(kicked, 38, 5000) -- 38 is ID M4 weapon and 5000 is amount ammo Link to comment
iPanda Posted February 24, 2014 Author Share Posted February 24, 2014 You made a typo in the serverside.'kikcplayer' Thanks, did not notice. Just tested, it is still not working. Link to comment
Anubhav Posted February 24, 2014 Share Posted February 24, 2014 WASSIm he is talking about kickPlayer not giveWeapon. IPanda try using sourcePlayer Link to comment
myonlake Posted February 24, 2014 Share Posted February 24, 2014 Client-side triggerServerEvent( "kickPlayer", localPlayer ) Server-side addEvent( "kickPlayer", true ) addEventHandler( "kickPlayer", root, function( kicker ) if ( source ~= client ) then return end kickPlayer( client, ( ( isElement( kicker ) and getElementType( kicker ) == "player" ) and kicker or client ) ) end ) Link to comment
iPanda Posted February 24, 2014 Author Share Posted February 24, 2014 Thank you very much) Link to comment
iPanda Posted February 24, 2014 Author Share Posted February 24, 2014 I've got one more question. How can I cancel a kick-timer, pressing the button? kickme = guiCreateButton(0.2, 0.52, 0.15, 0.05, "kick me", true) cancel = guiCreateButton(0.2, 0.60, 0.15, 0.05, "cancel", true) kickTimer = setTimer(function() triggerServerEvent("kickPlayer", getLocalPlayer()) end, 5000, 1) addEventHandler("onClientGUIClick", getRootElement(), function() if (source == kickme) then if isTimer(kickTimer) then resetTimer(kickTimer) end elseif (source == cancel) then if isTimer(kickTimer) then killTimer(kickTimer) end end end) The problem is that I was kicked from server without pressing any buttons. Also, the cancel button kick-timer is not running. Help. Link to comment
myonlake Posted February 24, 2014 Share Posted February 24, 2014 You reset the timer when pressing the kickme button. You have to execute the event manually by doing the following. kickme = guiCreateButton( 0.2, 0.52, 0.15, 0.05, "kick me", true ) cancel = guiCreateButton( 0.2, 0.60, 0.15, 0.05, "cancel", true ) kickTimer = setTimer( triggerServerEvent, 5000, 1, "kickPlayer", localPlayer ) addEventHandler( "onClientGUIClick", root, function( ) if ( source == kickme ) then triggerServerEvent( "kickPlayer", localPlayer ) elseif ( source == cancel ) then if ( isTimer( kickTimer ) then killTimer( kickTimer ) end end end, false ) Link to comment
WASSIm. Posted February 24, 2014 Share Posted February 24, 2014 kickme = guiCreateButton( 0.2, 0.52, 0.15, 0.05, "kick me", true ) cancel = guiCreateButton( 0.2, 0.60, 0.15, 0.05, "cancel", true ) addEventHandler( "onClientGUIClick", root, function( ) if ( source == kickme ) then kickTimer = setTimer( triggerServerEvent, 5000, 1, "kickPlayer", localPlayer ) elseif ( source == cancel ) then if (kickTimer) and ( isTimer( kickTimer ) then killTimer( kickTimer ) end end end, false ) Link to comment
iPanda Posted February 24, 2014 Author Share Posted February 24, 2014 Did not help. Now even the kick does not work Link to comment
Castillo Posted February 24, 2014 Share Posted February 24, 2014 kickme = guiCreateButton( 0.2, 0.52, 0.15, 0.05, "kick me", true ) cancel = guiCreateButton( 0.2, 0.60, 0.15, 0.05, "cancel", true ) addEventHandler( "onClientGUIClick", root, function( ) if ( source == kickme ) then kickTimer = setTimer ( triggerServerEvent, 5000, 1, "kickPlayer", localPlayer ) elseif ( source == cancel ) then if isTimer( kickTimer ) then killTimer( kickTimer ) end end end ) Link to comment
iPanda Posted February 26, 2014 Author Share Posted February 26, 2014 There was an unknown error to me. I have no idea what's going on ... Client.lua: Server.lua: At the command prompt on my server says: Acces denied @ "kickPlayer" ps. Do not pay attention to the incomplete code on the picture, I took the new variables and syntax observed. Link to comment
WASSIm. Posted February 26, 2014 Share Posted February 26, 2014 make your resource on ACL Link to comment
Moderators Citizen Posted February 27, 2014 Moderators Share Posted February 27, 2014 make your resource on ACL By that, he means that you have to add your resource to the Admin group in acl.xml (located at the same place as mtaserver.conf) <acl> ... <group name="Admin"> ... <object name="resource.yourResourceName" /> ... </group> ... </acl> More information about acl here: https://wiki.multitheftauto.com/wiki/Access_Control_List 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