Jump to content

[AYUDA] - Restriccion de Usuarios Para GUI


Sergioks

Recommended Posts

Posted

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 xD

Posted
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 ) 

Posted

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
Posted
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) 

Posted
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.

Posted
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
Posted

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 
  

Posted
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:.! :D

Posted

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
Posted

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).

  • MTA Team
Posted
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.

Posted
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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...