Sergioks Posted January 10, 2014 Posted January 10, 2014 Hola!. Quisiera Saber Como Hacer que Un Usuario Pueda Abrir Un Panel Con Un Bind, pero solo para un grupo de ACL En Especifico. Yo Lo Hice Asi, Pero No Funciona. Client-Side: function gui () --- Bind De Abierto/Cerrado ( GUI ) local state = ( not guiGetVisible ( StaffPanel ) ) guiSetVisible ( StaffPanel, state ) showCursor ( state ) triggerServerEvent("OpenPanel", localPlayer) end bindKey ( "f5", "down", gui ) Server-Side: addEvent("OpenPanel", true) addEventHandler("OpenPanel", root, function() local accName = getAccountName ( getPlayerAccount ( source ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then end end ) Ayuda *Edit: Para Ser Honesto Solo Improvise Con Eso del isObjectInACLGroup , Asi que Si Pudieran Explicarme Que Hacer, Les Agradeceria Mucho
Sergioks Posted January 10, 2014 Author Posted January 10, 2014 Crea el bind server-side. Me Dice: Bad Argument's @ 'BindKey' ¿ahora que paso? Server-Side: function GUI() local accName = getAccountName ( getPlayerAccount ( source ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then triggerClientEvent ("OpenPanel", getRootElement()) end end bindKey ( "f5", "down", GUI )
Castillo Posted January 10, 2014 Posted January 10, 2014 Eso es porque bindKey server-side tiene un argumento de jugador antes de la tecla ( el primer argumento es el jugador al que se le asignara el bind ).
MTA Team 0xCiBeR Posted January 10, 2014 MTA Team Posted January 10, 2014 function GUI() local accName = getAccountName ( getPlayerAccount ( source ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then triggerClientEvent ("OpenPanel", getRootElement()) end end function bind() for i,v in ipairs(getElementsByType ( "player" )) do bindKey ( v,"f5", "down", GUI ) end end addEventHandler("onResourceStart",root,bind)
Alexs Posted January 11, 2014 Posted January 11, 2014 function GUI( thePlayer ) if isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "Admin" ) ) then triggerClientEvent (thePlayer, "OpenPanel", thePlayer) end end addEventHandler( 'onPlayerJoin', root, --Se les asigna el bind al conectarse function() bindKey ( source, "F5", "down", GUI ) end ) for k, i in ipairs( getElementsByType( 'player' ) do --y a los que ya están conectados. bindKey ( i, "F5", "down", GUI ) end Cualquier problema me avisas, no estoy muy seguro respecto a los parámetros en una función manejada por un bind.
Sergioks Posted January 12, 2014 Author Posted January 12, 2014 function GUI() local accName = getAccountName ( getPlayerAccount ( source ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then triggerClientEvent ("OpenPanel", getRootElement()) end end function bind() for i,v in ipairs(getElementsByType ( "player" )) do bindKey ( v,"f5", "down", GUI ) end end addEventHandler("onResourceStart",root,bind) Me Dice: WARNING: StaffSystem/Server.lua:11: Bad Argument @ 'getPlayerAccount' [ Expected account at argument 1, got boolean ] WARNING: StaffSystem/Server.lua:11: Bad Argument @ 'getAccountName' [Expected account at argument 1, got boolean] ERROR: StaffSystem\Server.lua:12: arrempt to concatenate local 'accName' ( a Boolean Value ) function GUI( thePlayer ) if isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "Admin" ) ) then triggerClientEvent (thePlayer, "OpenPanel", thePlayer) end end addEventHandler( 'onPlayerJoin', root, --Se les asigna el bind al conectarse function() bindKey ( source, "F5", "down", GUI ) end ) for k, i in ipairs( getElementsByType( 'player' ) do --y a los que ya están conectados. bindKey ( i, "F5", "down", GUI ) end Cualquier problema me avisas, no estoy muy seguro respecto a los parámetros en una función manejada por un bind. Me Dice: StaffSystem/Server.lua:22: ')' expected near 'do' ayuda
MTA Team 0xCiBeR Posted January 12, 2014 MTA Team Posted January 12, 2014 Le falto cerrar un ) a @Alexs function GUI( thePlayer ) local cuenta = getAccountName ( getPlayerAccount ( thePlayer ) ) if not cuenta or isGuestAccount(acc) then outputChatBox("ERROR!:",thePlayer,255,0,0,true) break end if isObjectInACLGroup ("user."..cuenta, aclGetGroup ( "Admin" ) ) then triggerClientEvent (thePlayer, "OpenPanel", thePlayer) end end addEventHandler( 'onPlayerJoin', root, --Se les asigna el bind al conectarse function() bindKey ( source, "F5", "down", GUI ) end ) for k, i in ipairs( getElementsByType( 'player' )) do --y a los que ya están conectados. bindKey ( i, "F5", "down", GUI ) end
Sergioks Posted January 12, 2014 Author Posted January 12, 2014 Le falto cerrar un ) a @Alexs function GUI( thePlayer ) local cuenta = getAccountName ( getPlayerAccount ( thePlayer ) ) if not cuenta or isGuestAccount(acc) then outputChatBox("ERROR!:",thePlayer,255,0,0,true) break end if isObjectInACLGroup ("user."..cuenta, aclGetGroup ( "Admin" ) ) then triggerClientEvent (thePlayer, "OpenPanel", thePlayer) end end addEventHandler( 'onPlayerJoin', root, --Se les asigna el bind al conectarse function() bindKey ( source, "F5", "down", GUI ) end ) for k, i in ipairs( getElementsByType( 'player' )) do --y a los que ya están conectados. bindKey ( i, "F5", "down", GUI ) end Muchas Gracias .:CiBeR:.!
Alexs Posted January 13, 2014 Posted January 13, 2014 Me Dice: StaffSystem/Server.lua:22: ')' expected near 'do' ayuda Me falto cerrar un paréntesis en la linea 13, de todas formas me preocupa mas otro tema del que no estoy seguro. Por favor, asegúrate de que el panel se muestre solo para quien utiliza el comando, insisto en que estoy dudoso respecto a los parámetros de la función.
MTA Team 0xCiBeR Posted January 13, 2014 MTA Team Posted January 13, 2014 Por favor, asegúrate de que el panel se muestre solo para quien utiliza el comando, insisto en que estoy dudoso respecto a los parámetros de la función. Handler Function Server-Side: function functionName ( player keyPresser, string key, string keyState, [ var arguments, ... ] ) The values passed to this function are:keyPresser: The player who pressed the key key: The key that was pressed keyState: The state of the key that was pressed, down if it was pressed, up if it was released. arguments The optional arguments you specified when calling bindKey (see below).
Alexs Posted January 13, 2014 Posted January 13, 2014 Siempre pueden existir problemas aparte, sin importar lo que la wiki diga.
Sergioks Posted January 14, 2014 Author Posted January 14, 2014 Si alexs, me funciono. Gracias. Solo tuve el problema del ")" q ciber ayudo a cerrar.
MTA Team 0xCiBeR Posted January 14, 2014 MTA Team Posted January 14, 2014 Si alexs, me funciono. Gracias. Solo tuve el problema del ")" q ciber ayudo a cerrar. También agregue: isGuestAccount Ya que siempre es mejor comprobar si no esta logueado para evitar errores y además ahorrar recursos. PD:Siempre recuerda Optimizar Tus scripts. Saludos.
Alexs Posted January 14, 2014 Posted January 14, 2014 Si alexs, me funciono. Gracias. Solo tuve el problema del ")" q ciber ayudo a cerrar. No hay problema, aunque déjalo así: function GUI( thePlayer ) local acc = getPlayerAccount ( thePlayer ) if not isGuestAccount( acc ) then if isObjectInACLGroup ("user."..getAccountName ( acc ), aclGetGroup ( "Admin" ) ) then triggerClientEvent (thePlayer, "OpenPanel", thePlayer) end end end addEventHandler( 'onPlayerJoin', root, --Se les asigna el bind al conectarse function() bindKey ( source, "F5", "down", GUI ) end ) for k, i in ipairs( getElementsByType( 'player' )) do --y a los que ya están conectados. bindKey ( i, "F5", "down", GUI ) end La "corrección" que te dieron tenia algunas partes inútiles.
Recommended Posts