iPanda Posted February 24, 2014 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
Karuzo Posted February 24, 2014 Posted February 24, 2014 You made a typo in the serverside. 'kikcplayer'
WASSIm. Posted February 24, 2014 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
iPanda Posted February 24, 2014 Author Posted February 24, 2014 You made a typo in the serverside.'kikcplayer' Thanks, did not notice. Just tested, it is still not working.
Anubhav Posted February 24, 2014 Posted February 24, 2014 WASSIm he is talking about kickPlayer not giveWeapon. IPanda try using sourcePlayer
myonlake Posted February 24, 2014 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 )
iPanda Posted February 24, 2014 Author 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.
myonlake Posted February 24, 2014 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 )
WASSIm. Posted February 24, 2014 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 )
iPanda Posted February 24, 2014 Author Posted February 24, 2014 Did not help. Now even the kick does not work
Castillo Posted February 24, 2014 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 )
iPanda Posted February 26, 2014 Author 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.
Moderators Citizen Posted February 27, 2014 Moderators 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
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