Jump to content

[Ayuda] Me da booleanos y nils y no se por qué.


Platin

Recommended Posts

Es un sistema para hacer anuncios, basado en un script de la comunidad muy mal hecho, ya que cualquiera podía hacerlos:

function input_Console ( text,_, ThePlayer )  
  
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) and ( getElementType ( source ) == "player" ) then    
        local command = gettok ( text, 1, 32 ) 
        local actionText = string.sub ( text, 3 ) 
        outputChatBox ( "#FF0000*Administración* #FFFFFF" .. actionText, getRootElement(), r, g, b, true ) 
    else 
        outputChatBox("No puedes usar este comando",getRootElement(), 255, 0, 0) 
    end 
end 
  
addCommandHandler("an", input_Console) 

Antes tenía otro sistema, que era luego de detectar si era dueño, que si ponía el comando /an (if command "/an" then), pero seguía dando el mismo error.

Link to comment
  
function input_Console ( thePlayer,_, text) 
  
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) and ( getElementType ( thePlayer) == "player" ) then    
        local command = gettok ( text, 1, 32 ) 
        local actionText = string.sub ( text, 3 ) 
        outputChatBox ( "#FF0000*Administración* #FFFFFF" .. actionText, getRootElement(), r, g, b, true ) 
    else 
        outputChatBox("No puedes usar este comando",thePlayer, 255, 0, 0) 
    end 
end 
  
addCommandHandler("an", input_Console) 
  

Link to comment
  
function input_Console ( thePlayer,_, text) 
  
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) and ( getElementType ( thePlayer) == "player" ) then    
        local command = gettok ( text, 1, 32 ) 
        local actionText = string.sub ( text, 3 ) 
        outputChatBox ( "#FF0000*Administración* #FFFFFF" .. actionText, getRootElement(), r, g, b, true ) 
    else 
        outputChatBox("No puedes usar este comando",thePlayer, 255, 0, 0) 
    end 
end 
  
addCommandHandler("an", input_Console) 
  

Oh DIOS que tonto soy, gracias Tomas

EDIT:

Intente modificarlo ya que solo me dejaba mandar una palabra, nada más y me sigue dando el mismo error:

function input_Console ( thePlayer,_, text) 
  
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- Esta línea y 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) and ( getElementType ( thePlayer) == "player" ) then -- Esta linea me dan error  
        local command = gettok ( text, 1, 32 ) 
        if ( command == "an" ) then 
            local actionText = string.sub ( text, 0 ) 
            outputChatBox ( "#FF0000*Administración* #FFFFFF" .. actionText, getRootElement(), r, g, b, true ) 
        end 
    else 
        outputChatBox("No puedes usar este comando",thePlayer, 255, 0, 0) 
    end 
end 
  
addEventHandler ( "onConsole", getRootElement(), input_Console )  

Link to comment

No testeado:

  
function input_Console ( thePlayer,_, ...) 
text = table.concat({...}, " ") 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- Esta línea y 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) and ( getElementType ( thePlayer) == "player" ) then -- Esta linea me dan error 
        local command = gettok ( text, 1, 32 ) 
        if ( command == "an" ) then 
            local actionText = string.sub ( text, 0 ) 
            outputChatBox ( "#FF0000*Administración* #FFFFFF" .. actionText, getRootElement(), r, g, b, true ) 
        end 
    else 
        outputChatBox("No puedes usar este comando",thePlayer, 255, 0, 0) 
    end 
end 
  
addEventHandler ( "onConsole", getRootElement(), input_Console ) 
  

Link to comment
No testeado:
  
function input_Console ( thePlayer,_, ...) 
text = table.concat({...}, " ") 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- Esta línea y 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) and ( getElementType ( thePlayer) == "player" ) then -- Esta linea me dan error 
        local command = gettok ( text, 1, 32 ) 
        if ( command == "an" ) then 
            local actionText = string.sub ( text, 0 ) 
            outputChatBox ( "#FF0000*Administración* #FFFFFF" .. actionText, getRootElement(), r, g, b, true ) 
        end 
    else 
        outputChatBox("No puedes usar este comando",thePlayer, 255, 0, 0) 
    end 
end 
  
addEventHandler ( "onConsole", getRootElement(), input_Console ) 
  

Sigue en nada :/

Link to comment

Recién vi el evento, lol.

  
function input_Console (...) 
text = table.concat({...}, " ") 
    local accName = getAccountName ( getPlayerAccount ( source) ) -- Esta línea y 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) and ( getElementType  source) == "player" ) then -- Esta linea me dan error 
        local command = gettok ( text, 1, 32 ) 
        if ( command == "an" ) then 
            local actionText = string.sub ( text, 0 ) 
            outputChatBox ( "#FF0000*Administración* #FFFFFF" .. actionText, getRootElement(), r, g, b, true ) 
        end 
    else 
        outputChatBox("No puedes usar este comando",source, 255, 0, 0) 
    end 
end 
  
addEventHandler ( "onConsole", getRootElement(), input_Console ) 
  

Link to comment
Recién vi el evento, lol.
  
function input_Console (...) 
text = table.concat({...}, " ") 
    local accName = getAccountName ( getPlayerAccount ( source) ) -- Esta línea y 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) and ( getElementType  source) == "player" ) then -- Esta linea me dan error 
        local command = gettok ( text, 1, 32 ) 
        if ( command == "an" ) then 
            local actionText = string.sub ( text, 0 ) 
            outputChatBox ( "#FF0000*Administración* #FFFFFF" .. actionText, getRootElement(), r, g, b, true ) 
        end 
    else 
        outputChatBox("No puedes usar este comando",source, 255, 0, 0) 
    end 
end 
  
addEventHandler ( "onConsole", getRootElement(), input_Console ) 
  

¡Muchas gracias, le quite lo de verificar si era un jugador y me sirvio!

Tengo otra pequeña duda y ya no quiero crear más posts :P

¿Estás dos lineas estan bien si las coloco en el clientside?

Siempre me dan errores porque las quiero llamar globales siendo nada.

local accName = getAccountName ( getPlayerAccount ( source ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 

Link to comment
Las funciones getAccountName, getPlayerAccount, isObjectInACLGroup y aclGetGroup son todas funciones del lado del servidor. Para chequear en que 'side' la puedes usar puedes visitar su página en la wiki en la parte superior derecha verás Client side function / Server side function / Client event / Server event / Client and Server Function / Client and Server Event.

Vale, entonces tengo que hacer un triggerserver, no?

Link to comment
Las funciones getAccountName, getPlayerAccount, isObjectInACLGroup y aclGetGroup son todas funciones del lado del servidor. Para chequear en que 'side' la puedes usar puedes visitar su página en la wiki en la parte superior derecha verás Client side function / Server side function / Client event / Server event / Client and Server Function / Client and Server Event.

Vale, entonces tengo que hacer un triggerserver, no?

Hay otras alternativas.. pero sí.

Link to comment
Las funciones getAccountName, getPlayerAccount, isObjectInACLGroup y aclGetGroup son todas funciones del lado del servidor. Para chequear en que 'side' la puedes usar puedes visitar su página en la wiki en la parte superior derecha verás Client side function / Server side function / Client event / Server event / Client and Server Function / Client and Server Event.

Vale, entonces tengo que hacer un triggerserver, no?

Hay otras alternativas.. pero sí.

¿Algunas más fáciles? ¿Cuáles?

EDIT:

Intente hacer un trigger Event, el tema es que siempre me dice que es falso:

serverside

function permisos() 
    local accName = getAccountName ( getPlayerAccount ( source ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) and ( getElementType ( source ) == "player" ) then 
        permisosvip = true -- Si es VIP, entonces, permisosvip true, y si permisosvip true, en el clientside se debería de abrir el panel. 
    end 
end 
addEvent( "onPermisos", true ) 
addEventHandler( "onPermisos", getRootElement(), permisos ) 

clientside

triggerServerEvent ( "onPermisos", getLocalPlayer() ) 
    if permisosvip  then 
-- Si permisosvip es true entonces abrir el panel, eso debería de decir,pero no quiero pegar todo el codigo. 

¿Alguna idea el por qué?

PD: ¿Si permisosvip es true, eso solo para el cliente o para todo el mundo?

Link to comment
No puedes pasar variables entre dos sides. Crea un trigger el cuál detecte desde el server-side si el jugador está en el ACL VIP, en caso de que si esté triggea al client para abrir la gui.

Comprendí que tengo que hacer, pero no podría hacerlo. Ejecuto un comando "/vip" para que se inicie la gui, ¿cómo debería de hacer? Ya que el único trigger que conozco es con el addEvent

Link to comment

Intenta así, acomodalo a lo que quieres.

SERVER:

  
function VIPPermiso (thePlayer) 
  local accName = getAccountName ( getPlayerAccount ( thePlayer ) )  
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then  
triggerClientEvent(thePlayer, "ElEvento", thePlayer) 
else 
outputChatBox("No eres VIP para ejercer este comando...", thePlayer, 255, 0, 0) 
end 
end 
addCommandHandler("panelvip", VIPPermiso) -- Comando que quieras 
  

CLIENT:

  
function PermisoVIP () 
if not ( guiGetVisible(LaGui)) then 
guiSetVisible(LaGui, true) 
showCursor(true) 
end 
end 
addEvent("ElEvento", true) 
addEventHandler("ElEvento", root, PermisoVIP) -- El evento que quieras 
  

Link to comment
Intenta así, acomodalo a lo que quieres.

SERVER:

  
function VIPPermiso (thePlayer) 
  local accName = getAccountName ( getPlayerAccount ( thePlayer ) )  
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then  
triggerClientEvent(thePlayer, "ElEvento", thePlayer) 
else 
outputChatBox("No eres VIP para ejercer este comando...", thePlayer, 255, 0, 0) 
end 
end 
addCommandHandler("panelvip", VIPPermiso) -- Comando que quieras 
  

CLIENT:

  
function PermisoVIP () 
if not ( guiGetVisible(LaGui)) then 
guiSetVisible(LaGui, true) 
showCursor(true) 
end 
end 
addEvent("ElEvento", true) 
addEventHandler("ElEvento", root, PermisoVIP) -- El evento que quieras 
  

Muchas gracias, me sirvió. Sobre

La idea era que lo hiciera él...

Tomas, no pasa nada. Ahora tengo un ejemplo y esto me podría ayudar a que en el futuro pueda escribir el code y diga, joder, si me ayudaron en el foro, ahora me acuerdo como era.

Por cierto, lo de mi panel de armas, todavía no puedo cambiar de pestañas.

  
addEventHandler ( "onClientGUIClick", armas, armasvips, false) 
  
-- Arriba, estan todos los botones y la gui del menu, en la cual tengo el armasvip justo debajo del menu 
  
function panelArma() 
  
    panelarmas = guiCreateWindow(505, 204, 329, 375, "Panel VIP - Banana Gamers", false) -- Panel armas 
    guiWindowSetSizable(panelarmas, false) 
  
    molotov = guiCreateButton(10, 152, 151, 25, "Molotovs - 200", false, panelarmas) 
    humo = guiCreateButton(10, 206, 151, 25, "Granadas de Humo - 200", false, panelarmas) 
    detonador = guiCreateButton(176, 206, 143, 25, "Detonador - 1", false, panelarmas) 
    satchel = guiCreateButton(176, 152, 143, 25, "Paquetes Bomba - 200", false, panelarmas) 
    cuchillo = guiCreateButton(10, 274, 151, 25, "Cuchillo - 1", false, panelarmas) 
    lanzallamas = guiCreateButton(175, 274, 144, 25, "Lanzallamas - 8000", false, panelarmas) 
    cerrarpanelarma = guiCreateButton(175, 340, 143, 25, "Cerrar", false,panelarmas) 
    dirigido = guiCreateButton(10, 86, 151, 25, "Lanzamisiles Dirigido - 200", false, panelarmas) 
    minigun = guiCreateButton(10, 37, 151, 25, "Minigun - 8000 balas", false, panelarmas) 
    granadas = guiCreateButton(176, 86, 143, 25, "Granadas - 200", false, panelarmas) 
    lanzamisiles = guiCreateButton(176, 37, 143, 25, "Lanzamisiles - 200", false, panelarmas) 
    volver = guiCreateButton(9, 340, 152, 25, "Volver", false, panelarmas)  
     
end 
  
function armasvips() 
    showCursor (true) 
    guiSetVisible (menu, not guiGetVisible (menu))   
    if not ( guiGetVisible(panelarmas)) then -- Le puse esta linea por si alguien toca dos veces el boton y anda algo lag, así no se le bugea el panel 
        guiSetVisible(panelarmas, true) -- Esta, junto a la linea anterior, me dice que panelarmas no existe, ¡no tiene sentido! 
    end 
end 

Sigo con el mismo error incial!

EDIT:

Y si, he tratado de poner el addEvent de armas debajo del panel, me salto error.

Link to comment
  
    panelarmas = guiCreateWindow(505, 204, 329, 375, "Panel VIP - Banana Gamers", false) -- Panel armas 
    guiWindowSetSizable(panelarmas, false) 
    guiSetVisible(panelarmas,false) 
    molotov = guiCreateButton(10, 152, 151, 25, "Molotovs - 200", false, panelarmas) 
    humo = guiCreateButton(10, 206, 151, 25, "Granadas de Humo - 200", false, panelarmas) 
    detonador = guiCreateButton(176, 206, 143, 25, "Detonador - 1", false, panelarmas) 
    satchel = guiCreateButton(176, 152, 143, 25, "Paquetes Bomba - 200", false, panelarmas) 
    cuchillo = guiCreateButton(10, 274, 151, 25, "Cuchillo - 1", false, panelarmas) 
    lanzallamas = guiCreateButton(175, 274, 144, 25, "Lanzallamas - 8000", false, panelarmas) 
    cerrarpanelarma = guiCreateButton(175, 340, 143, 25, "Cerrar", false,panelarmas) 
    dirigido = guiCreateButton(10, 86, 151, 25, "Lanzamisiles Dirigido - 200", false, panelarmas) 
    minigun = guiCreateButton(10, 37, 151, 25, "Minigun - 8000 balas", false, panelarmas) 
    granadas = guiCreateButton(176, 86, 143, 25, "Granadas - 200", false, panelarmas) 
    lanzamisiles = guiCreateButton(176, 37, 143, 25, "Lanzamisiles - 200", false, panelarmas) 
    volver = guiCreateButton(9, 340, 152, 25, "Volver", false, panelarmas) 
  
function armasvips() 
    showCursor (true) 
    guiSetVisible (menu, not guiGetVisible (menu))  
    if not ( guiGetVisible(panelarmas)) then -- Le puse esta linea por si alguien toca dos veces el boton y anda algo lag, así no se le bugea el panel 
        guiSetVisible(panelarmas, true) -- Esta, junto a la linea anterior, me dice que panelarmas no existe, ¡no tiene sentido! 
    end 
end 
addEventHandler ( "onClientGUIClick", armas, armasvips, false) 
  

Link to comment
  
    panelarmas = guiCreateWindow(505, 204, 329, 375, "Panel VIP - Banana Gamers", false) -- Panel armas 
    guiWindowSetSizable(panelarmas, false) 
    guiSetVisible(panelarmas,false) 
    molotov = guiCreateButton(10, 152, 151, 25, "Molotovs - 200", false, panelarmas) 
    humo = guiCreateButton(10, 206, 151, 25, "Granadas de Humo - 200", false, panelarmas) 
    detonador = guiCreateButton(176, 206, 143, 25, "Detonador - 1", false, panelarmas) 
    satchel = guiCreateButton(176, 152, 143, 25, "Paquetes Bomba - 200", false, panelarmas) 
    cuchillo = guiCreateButton(10, 274, 151, 25, "Cuchillo - 1", false, panelarmas) 
    lanzallamas = guiCreateButton(175, 274, 144, 25, "Lanzallamas - 8000", false, panelarmas) 
    cerrarpanelarma = guiCreateButton(175, 340, 143, 25, "Cerrar", false,panelarmas) 
    dirigido = guiCreateButton(10, 86, 151, 25, "Lanzamisiles Dirigido - 200", false, panelarmas) 
    minigun = guiCreateButton(10, 37, 151, 25, "Minigun - 8000 balas", false, panelarmas) 
    granadas = guiCreateButton(176, 86, 143, 25, "Granadas - 200", false, panelarmas) 
    lanzamisiles = guiCreateButton(176, 37, 143, 25, "Lanzamisiles - 200", false, panelarmas) 
    volver = guiCreateButton(9, 340, 152, 25, "Volver", false, panelarmas) 
  
function armasvips() 
    showCursor (true) 
    guiSetVisible (menu, not guiGetVisible (menu))  
    if not ( guiGetVisible(panelarmas)) then -- Le puse esta linea por si alguien toca dos veces el boton y anda algo lag, así no se le bugea el panel 
        guiSetVisible(panelarmas, true) -- Esta, junto a la linea anterior, me dice que panelarmas no existe, ¡no tiene sentido! 
    end 
end 
addEventHandler ( "onClientGUIClick", armas, armasvips, false) 
  

Me dice que armas no existe, pero esta existe, wtf

EDIT:

Solucionado, gracias a todos.

Link to comment
  • Recently Browsing   0 members

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