Jump to content

How I can destroy Element and again create a new


iFoReX

Recommended Posts

#tittle I want Destroy element and again create but I dont know how here my code

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(0,0.6583,0.2212,0.35,"GUI Garage",true) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_Button[1] = guiCreateButton(10,57,157,43,"Sacar Vehiculo",false,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(10,108,157,43,"Cambiar de color el Vehiculo",false,GUIEditor_Window[1]) 
GUIEditor_Button[3] = guiCreateButton(10,159,157,42,"Cambiar/poner Paintjob",false,GUIEditor_Window[1]) 
GUIEditor_Label[1] = guiCreateLabel(53,29,56,16,"By ElMota",false,GUIEditor_Window[1]) 
guiSetFont(GUIEditor_Label[1],"default-bold-small") 
GUIEditor_Button[4] = guiCreateButton(141,22,25,29,"X",false,GUIEditor_Window[1]) 
GUIEditor_Window[2] = guiCreateWindow(-0.005,0.0917,0.2275,0.5667,"GUI Autos",true) 
GUIEditor_Grid[1] = guiCreateGridList(9,28,164,303,false,GUIEditor_Window[2]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
  
column = guiGridListAddColumn(GUIEditor_Grid[1],"Autos",0.-- s8) -->
  
column2 = guiGridListAddColumn(GUIEditor_Grid[1],"ID",0.2) 
  
GUIEditor_Window[3] = guiCreateWindow(0.2212,0.6583,0.2675,0.3483,"GUI Agregar Auto",true) 
GUIEditor_Button[5] = guiCreateButton(13,164,187,33,"Agregar",false,GUIEditor_Window[3]) 
GUIEditor_Label[2] = guiCreateLabel(17,31,125,17,"Nombre de la Variable",false,GUIEditor_Window[3]) 
guiSetFont(GUIEditor_Label[2],"default-bold-small") 
GUIEditor_Edit[1] = guiCreateEdit(17,49,187,29,"",false,GUIEditor_Window[3]) 
GUIEditor_Label[3] = guiCreateLabel(19,90,123,22,"Numero de ID",false,GUIEditor_Window[3]) 
guiSetFont(GUIEditor_Label[3],"default-bold-small") 
GUIEditor_Edit[2] = guiCreateEdit(17,107,187,29,"",false,GUIEditor_Window[3]) 
  
guiSetVisible(GUIEditor_Window[1],false) 
guiSetVisible(GUIEditor_Window[2],false) 
guiSetVisible(GUIEditor_Window[3],false) 
showCursor(false) 
  
marker = createMarker( 250.27734375, -1765.474609375, 3.7, "cylinder", 1.5, 255, 255, 255, 90 ) 
  
function markerHit(hitPlayer) 
name = getPlayerName( localPlayer ) 
    if name == "ElMota(BienNice)" then 
        if ( hitPlayer == localPlayer ) then 
        guiSetVisible (GUIEditor_Window[1], true) 
        guiSetVisible (GUIEditor_Window[2], true) 
        guiSetVisible (GUIEditor_Window[3], true) 
        showCursor (true) 
        triggerServerEvent("onCameraView", getLocalPlayer()) 
        guiSetInputMode ( "no_binds_when_editing" ) 
        end 
    end 
end 
  
addEventHandler("onClientMarkerHit", marker, markerHit) 
  
addEventHandler("onClientGUIClick", root,  
function() 
if source == GUIEditor_Button[4] then 
guiSetVisible(GUIEditor_Window[1],false) 
guiSetVisible(GUIEditor_Window[2],false) 
guiSetVisible(GUIEditor_Window[3],false) 
showCursor(false) 
setCameraTarget( localPlayer ) 
end 
end 
) 
  
addEventHandler("onClientGUIClick", root, 
    function() 
        if source == GUIEditor_Button[5] then 
            local row = guiGridListAddRow(GUIEditor_Grid[1]) 
            guiGridListSetItemText ( GUIEditor_Grid[1], row, column, (guiGetText(GUIEditor_Edit[1])), false, false ) 
            guiGridListSetItemText ( GUIEditor_Grid[1], row, column2, (guiGetText(GUIEditor_Edit[2])), false, false ) 
        end 
    end 
) 
  
  
addEventHandler("onClientGUIChanged", GUIEditor_Edit[2],  
function() 
if isElement(auto) then 
destroyElement(auto) 
    if destroyElement(auto) then 
    local skins = guiGetText( source ) 
    auto = createVehicle( tonumber ( skins ), -1951.6552734375, 263.078125, 35.46875 ) 
        end 
    end 
end 
) 

Link to comment
  
if isElement( pVehicle ) then 
    destroyElement( pVehicle ) 
end 
pVehicle = createVehicle( tonumber ( guiGetText( source ) ), -1951.6552734375, 263.078125, 35.46875 ) 
  

?

P.S I say more time .. Can you tabulate code? -_-

Link to comment

Why you should destroy it? you can change the model of the vehicle instead of re-creating it.

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(0,0.6583,0.2212,0.35,"GUI Garage",true) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_Button[1] = guiCreateButton(10,57,157,43,"Sacar Vehiculo",false,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(10,108,157,43,"Cambiar de color el Vehiculo",false,GUIEditor_Window[1]) 
GUIEditor_Button[3] = guiCreateButton(10,159,157,42,"Cambiar/poner Paintjob",false,GUIEditor_Window[1]) 
GUIEditor_Label[1] = guiCreateLabel(53,29,56,16,"By ElMota",false,GUIEditor_Window[1]) 
guiSetFont(GUIEditor_Label[1],"default-bold-small") 
GUIEditor_Button[4] = guiCreateButton(141,22,25,29,"X",false,GUIEditor_Window[1]) 
GUIEditor_Window[2] = guiCreateWindow(-0.005,0.0917,0.2275,0.5667,"GUI Autos",true) 
GUIEditor_Grid[1] = guiCreateGridList(9,28,164,303,false,GUIEditor_Window[2]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
  
column = guiGridListAddColumn(GUIEditor_Grid[1],"Autos",0.-- s8) -->
  
column2 = guiGridListAddColumn(GUIEditor_Grid[1],"ID",0.2) 
  
GUIEditor_Window[3] = guiCreateWindow(0.2212,0.6583,0.2675,0.3483,"GUI Agregar Auto",true) 
GUIEditor_Button[5] = guiCreateButton(13,164,187,33,"Agregar",false,GUIEditor_Window[3]) 
GUIEditor_Label[2] = guiCreateLabel(17,31,125,17,"Nombre de la Variable",false,GUIEditor_Window[3]) 
guiSetFont(GUIEditor_Label[2],"default-bold-small") 
GUIEditor_Edit[1] = guiCreateEdit(17,49,187,29,"",false,GUIEditor_Window[3]) 
GUIEditor_Label[3] = guiCreateLabel(19,90,123,22,"Numero de ID",false,GUIEditor_Window[3]) 
guiSetFont(GUIEditor_Label[3],"default-bold-small") 
GUIEditor_Edit[2] = guiCreateEdit(17,107,187,29,"",false,GUIEditor_Window[3]) 
  
guiSetVisible(GUIEditor_Window[1],false) 
guiSetVisible(GUIEditor_Window[2],false) 
guiSetVisible(GUIEditor_Window[3],false) 
showCursor(false) 
  
marker = createMarker( 250.27734375, -1765.474609375, 3.7, "cylinder", 1.5, 255, 255, 255, 90 ) 
  
function markerHit(hitPlayer) 
name = getPlayerName( localPlayer ) 
    if name == "ElMota(BienNice)" then 
        if ( hitPlayer == localPlayer ) then 
        guiSetVisible (GUIEditor_Window[1], true) 
        guiSetVisible (GUIEditor_Window[2], true) 
        guiSetVisible (GUIEditor_Window[3], true) 
        showCursor (true) 
        triggerServerEvent("onCameraView", getLocalPlayer()) 
        guiSetInputMode ( "no_binds_when_editing" ) 
        end 
    end 
end 
  
addEventHandler("onClientMarkerHit", marker, markerHit) 
  
addEventHandler("onClientGUIClick", root, 
function() 
if source == GUIEditor_Button[4] then 
guiSetVisible(GUIEditor_Window[1],false) 
guiSetVisible(GUIEditor_Window[2],false) 
guiSetVisible(GUIEditor_Window[3],false) 
showCursor(false) 
setCameraTarget( localPlayer ) 
end 
end 
) 
  
addEventHandler("onClientGUIClick", root, 
    function() 
        if source == GUIEditor_Button[5] then 
            local row = guiGridListAddRow(GUIEditor_Grid[1]) 
            guiGridListSetItemText ( GUIEditor_Grid[1], row, column, (guiGetText(GUIEditor_Edit[1])), false, false ) 
            guiGridListSetItemText ( GUIEditor_Grid[1], row, column2, (guiGetText(GUIEditor_Edit[2])), false, false ) 
        end 
    end 
) 
  
addEventHandler ( "onClientGUIChanged", GUIEditor_Edit[2], 
    function ( ) 
        local skins = guiGetText ( source ) 
        if ( not isElement ( auto ) ) then 
            auto = createVehicle ( tonumber ( skins ), -1951.6552734375, 263.078125, 35.46875 ) 
        else 
            setElementModel ( auto, tonumber ( skins ) ) 
        end 
    end 
) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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