Jump to content

Reiniciar resource con un button de la GUI


Tomas

Recommended Posts

Posted

Holis, otra vez yo molestando e,e

Estaba creando un panel que hace que al presionar un botón segun cual presiones se crea una Puerta o Gate del Map.

Quiero agregar un botón que haga que se eliminen todas, pues podría hacerlo con una tabla, pero me da paja meter todo dentro .-.

Así que es mejor que al presionar "Eliminar todos los objetos" se reinicie el resource del panel.

Y nose que poner en la function de ese botón :v

Si quieren me explican lo de las tablas o me dan el código directo 8)

Posted (edited)

client

  
  
GUIEditor = { 
    button = {}, 
    window = {}, 
    memo = {}, 
} 
  
        PanelObjetosMapa = guiCreateWindow(124, 50, 579, 354, "Panel de objetos de mapeo ~ By: Tomasito", false) 
        guiWindowSetSizable(PanelObjetosMapa, false) 
        guiSetVisible(PanelObjetosMapa,false) 
  
        Close = guiCreateButton(470, 309, 99, 35, "Cerrar", false, PanelObjetosMapa) 
        guiSetFont(Close, "sa-header") 
        guiSetProperty(Close, "NormalTextColour", "C8E70000") 
  
        BORRAR = guiCreateButton(352, 309, 99, 35, "borrar", false, PanelObjetosMapa) 
        guiSetFont(BORRAR, "sa-header") 
        guiSetProperty(BORRAR, "NormalTextColour", "C8E70000")     
        --GUIEditor.button[1] = guiCreateButton(-451, -44, 51, 15, "", false, Close) 
  
        Gate1V = guiCreateButton(10, 50, 70, 27, "Gate1", false, PanelObjetosMapa) 
        Gate8V = guiCreateButton(10, 271, 70, 27, "Gate7", false, PanelObjetosMapa) 
        Gate2V = guiCreateButton(10, 98, 70, 27, "Gate2", false, PanelObjetosMapa) 
        Gate9V = guiCreateButton(10, 317, 70, 27, "Gate8", false, PanelObjetosMapa) 
        Gate3V = guiCreateButton(10, 141, 70, 27, "Gate4", false, PanelObjetosMapa) 
        Gate6V = guiCreateButton(10, 225, 70, 27, "Gate6", false, PanelObjetosMapa) 
        Gate4V = guiCreateButton(10, 184, 70, 27, "Gate5", false, PanelObjetosMapa) 
        Memo = guiCreateMemo(9, 23, 560, 27, "Al hacer click en cada boton aparecera un objeto diferente. ", false, PanelObjetosMapa) 
        guiMemoSetReadOnly(Memo, true)     
  
addCommandHandler ( "panel", function () 
    local value = guiGetVisible(PanelObjetosMapa) 
    guiSetVisible(PanelObjetosMapa,not value) 
    showCursor (not value) 
end) 
  
addEventHandler("onClientGUIClick", Gate1V , function () 
    triggerServerEvent ( "crearGate1V", getLocalPlayer()  ) 
end) 
  
addEventHandler("onClientGUIClick", Close , function () 
    guiSetVisible (PanelObjetosMapa,false) 
    showCursor(false) 
end) 
  
addEventHandler("onClientGUIClick", BORRAR , function() 
    triggerServerEvent ( "borrarTodo", getLocalPlayer()  ) 
    guiSetVisible (PanelObjetosMapa,false) 
    showCursor(false) 
end) 

 

server

  
todoslosobjetos = {} 
  
addEvent( "crearGate1V", true ) 
addEventHandler( "crearGate1V", getRootElement(), function () 
  local x, y, z = getElementPosition (source) 
  objeto = createObject (976, x + 0.1, y + 0.1, z, 0, 0, 0) 
    if (objeto) then 
        outputChatBox ( "Objeto creado", source, 0, 255, 0) 
        table.insert(todoslosobjetos, objeto) 
    end  
end) 
  
addEvent( "borrarTodo", true ) 
addEventHandler( "borrarTodo", getRootElement(), function() 
  for i, v in ipairs ( todoslosobjetos ) do  
    if ( isElement(v) ) then 
      destroyElement(v) 
      outputChatBox ( "Todos los objetos han sido borrados", source, 0, 255, 0) 
    end 
  end 
end) 
  

Edited by Guest
Posted
client
  
GUIEditor = { 
    button = {}, 
    window = {}, 
    memo = {}, 
} 
  
        PanelObjetosMapa = guiCreateWindow(124, 50, 579, 354, "Panel de objetos de mapeo ~ By: Tomasito", false) 
        guiWindowSetSizable(PanelObjetosMapa, false) 
        guiSetVisible(PanelObjetosMapa,false) 
  
        Close = guiCreateButton(470, 309, 99, 35, "Cerrar", false, PanelObjetosMapa) 
        guiSetFont(Close, "sa-header") 
        guiSetProperty(Close, "NormalTextColour", "C8E70000") 
  
        BORRAR = guiCreateButton(352, 309, 99, 35, "borrar", false, PanelObjetosMapa) 
        guiSetFont(BORRAR, "sa-header") 
        guiSetProperty(BORRAR, "NormalTextColour", "C8E70000")     
        --GUIEditor.button[1] = guiCreateButton(-451, -44, 51, 15, "", false, Close) 
  
        Gate1V = guiCreateButton(10, 50, 70, 27, "Gate1", false, PanelObjetosMapa) 
        Gate8V = guiCreateButton(10, 271, 70, 27, "Gate7", false, PanelObjetosMapa) 
        Gate2V = guiCreateButton(10, 98, 70, 27, "Gate2", false, PanelObjetosMapa) 
        Gate9V = guiCreateButton(10, 317, 70, 27, "Gate8", false, PanelObjetosMapa) 
        Gate3V = guiCreateButton(10, 141, 70, 27, "Gate4", false, PanelObjetosMapa) 
        Gate6V = guiCreateButton(10, 225, 70, 27, "Gate6", false, PanelObjetosMapa) 
        Gate4V = guiCreateButton(10, 184, 70, 27, "Gate5", false, PanelObjetosMapa) 
        Memo = guiCreateMemo(9, 23, 560, 27, "Al hacer click en cada boton aparecera un objeto diferente. ", false, PanelObjetosMapa) 
        guiMemoSetReadOnly(Memo, true)     
    
function abrir () 
    if not guiGetVisible( PanelObjetosMapa ) then 
        showCursor ( true ) 
        guiSetVisible( PanelObjetosMapa, true ) 
         else 
        showCursor ( false ) 
        guiSetVisible( PanelObjetosMapa, false ) 
    end 
end 
 addEvent("showPanel", true) 
addEventHandler("showPanel", getRootElement(),abrir) 
  
function funGate1V(  ) 
    triggerServerEvent ( "crearGate1V", getLocalPlayer()  ) 
end  
addEventHandler("onClientGUIClick", Gate1V , funGate1V, false) 
  
function closee(  ) 
    guiSetVisible (PanelObjetosMapa,false) 
    showCursor(false) 
end 
addEventHandler("onClientGUIClick", Close , closee, false) 
  
function delall(  ) 
    triggerServerEvent ( "borrarTodo", getLocalPlayer()  ) 
    guiSetVisible (PanelObjetosMapa,false) 
    showCursor(false) 
end 
addEventHandler("onClientGUIClick", BORRAR , delall, false) 

 

server

  
objetos = {} 
  
 function showGUI ( playerSource) 
    triggerClientEvent ( playerSource, "showPanel", playerSource )   
end 
addCommandHandler ( "panel", showGUI ) 
  
function crearG1 () 
local x, y, z = getElementPosition ( source ) 
theObject = createObject ( 976, x + 0.1, y + 0.1, z, 0, 0, 0 ) 
    if ( theObject ) then 
        outputChatBox ( "Object created successfully", source, 0, 255, 0 ) 
        table.insert( objetos, theObject  ) 
         else 
        outputChatBox ( "Failed to create Object", source, 255, 0, 0) 
    end  
end 
addEvent( "crearGate1V", true ) 
addEventHandler( "crearGate1V", getRootElement(), crearG1 ) 
  
  
function borrarT () 
    for i, v in ipairs ( objetos ) do  
        if ( isElement(v) ) then 
            destroyElement(v) 
        end 
    end 
end 
addEvent( "borrarTodo", true ) 
addEventHandler( "borrarTodo", getRootElement(), borrarT ) 
  

Que capo :)

Gracias genio

Posted (edited)
client
  
GUIEditor = { 
    button = {}, 
    window = {}, 
    memo = {}, 
} 
  
        PanelObjetosMapa = guiCreateWindow(124, 50, 579, 354, "Panel de objetos de mapeo ~ By: Tomasito", false) 
        guiWindowSetSizable(PanelObjetosMapa, false) 
        guiSetVisible(PanelObjetosMapa,false) 
  
        Close = guiCreateButton(470, 309, 99, 35, "Cerrar", false, PanelObjetosMapa) 
        guiSetFont(Close, "sa-header") 
        guiSetProperty(Close, "NormalTextColour", "C8E70000") 
  
        BORRAR = guiCreateButton(352, 309, 99, 35, "borrar", false, PanelObjetosMapa) 
        guiSetFont(BORRAR, "sa-header") 
        guiSetProperty(BORRAR, "NormalTextColour", "C8E70000")     
        --GUIEditor.button[1] = guiCreateButton(-451, -44, 51, 15, "", false, Close) 
  
        Gate1V = guiCreateButton(10, 50, 70, 27, "Gate1", false, PanelObjetosMapa) 
        Gate8V = guiCreateButton(10, 271, 70, 27, "Gate7", false, PanelObjetosMapa) 
        Gate2V = guiCreateButton(10, 98, 70, 27, "Gate2", false, PanelObjetosMapa) 
        Gate9V = guiCreateButton(10, 317, 70, 27, "Gate8", false, PanelObjetosMapa) 
        Gate3V = guiCreateButton(10, 141, 70, 27, "Gate4", false, PanelObjetosMapa) 
        Gate6V = guiCreateButton(10, 225, 70, 27, "Gate6", false, PanelObjetosMapa) 
        Gate4V = guiCreateButton(10, 184, 70, 27, "Gate5", false, PanelObjetosMapa) 
        Memo = guiCreateMemo(9, 23, 560, 27, "Al hacer click en cada boton aparecera un objeto diferente. ", false, PanelObjetosMapa) 
        guiMemoSetReadOnly(Memo, true)     
    
function abrir () 
    if not guiGetVisible( PanelObjetosMapa ) then 
        showCursor ( true ) 
        guiSetVisible( PanelObjetosMapa, true ) 
         else 
        showCursor ( false ) 
        guiSetVisible( PanelObjetosMapa, false ) 
    end 
end 
 addEvent("showPanel", true) 
addEventHandler("showPanel", getRootElement(),abrir) 
  
function funGate1V(  ) 
    triggerServerEvent ( "crearGate1V", getLocalPlayer()  ) 
end  
addEventHandler("onClientGUIClick", Gate1V , funGate1V, false) 
  
function closee(  ) 
    guiSetVisible (PanelObjetosMapa,false) 
    showCursor(false) 
end 
addEventHandler("onClientGUIClick", Close , closee, false) 
  
function delall(  ) 
    triggerServerEvent ( "borrarTodo", getLocalPlayer()  ) 
    guiSetVisible (PanelObjetosMapa,false) 
    showCursor(false) 
end 
addEventHandler("onClientGUIClick", BORRAR , delall, false) 

 

server

  
objetos = {} 
  
 function showGUI ( playerSource) 
    triggerClientEvent ( playerSource, "showPanel", playerSource )   
end 
addCommandHandler ( "panel", showGUI ) 
  
function crearG1 () 
local x, y, z = getElementPosition ( source ) 
theObject = createObject ( 976, x + 0.1, y + 0.1, z, 0, 0, 0 ) 
    if ( theObject ) then 
        outputChatBox ( "Object created successfully", source, 0, 255, 0 ) 
        table.insert( objetos, theObject  ) 
         else 
        outputChatBox ( "Failed to create Object", source, 255, 0, 0) 
    end  
end 
addEvent( "crearGate1V", true ) 
addEventHandler( "crearGate1V", getRootElement(), crearG1 ) 
  
  
function borrarT () 
    for i, v in ipairs ( objetos ) do  
        if ( isElement(v) ) then 
            destroyElement(v) 
        end 
    end 
end 
addEvent( "borrarTodo", true ) 
addEventHandler( "borrarTodo", getRootElement(), borrarT ) 
  

Que capo :)

Gracias genio

Vi que estaba el boton y olvide testearlo...

Al apretar Borrar el panel se cierra pero no desaparece el ítem :(

EDIT: Tu script si funciona ._.

Yo copié las partes que agregaste y lo adherí al mio, porque ya había editado varias cosas xD

Pero ahora copiaré mis cosas al tuyo e,e

Gracias :*

Edited by Guest
Posted

Joder ._.

Puedes decirme osea pasarme los script pero aparte, sin el codigo entero, sino te paso mi codigo y tu los agregas, porque si pongo tus codes en mi script no funciona el boton, solo cierra el panel :(

Posted
Joder ._.

Puedes decirme osea pasarme los script pero aparte, sin el codigo entero, sino te paso mi codigo y tu los agregas, porque si pongo tus codes en mi script no funciona el boton, solo cierra el panel :(

Revisa pm.

Posted

Post:

Revisa pm.

PM:

Checa el post :)

wat ._.

EDIT: Ya encontre el mensaje que decía que te agregue a Facebook :P

Tema solucionado, cuando lo termine los posteo :P

Gracias a todos C:

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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