Jump to content

[HELP] After marker hit crafting panel open


Recommended Posts

Hi! I have problem because I cant made my addon for dayz crafting to do it like this: make somewhere marker if player hit it crafting panel will open. Now its binded on key (F4) when i want to edit it all get buged so if you can help me. under my addon

sry for eng

  
GUIEditor = {
    tab = {},
    tabpanel = {},
    window = {},
    combobox = {},
    memo = {}
}
 
local items =
{
    ["Bronie"] = {
        "Lekka siekiera",
},
["Others"] = {
        "tent",
 
    }
}
 
 
 
 
forwardscarfting = {
    {"Lekka siekiera",1,"Metal",1,"Drut",1,"---",0,"---",0},
{"tent",1,"Metal",2,"Drut",1,"---",0,"---",0},
 
}
 
function getcraftingforwardsitems (text)
    for i,item in ipairs(forwardscarfting) do
        if item[1] == text then
            return item[2],item[3], item[4], item[5], item[6], item[7], item[8], item[9], item[10]
        end
    end
end
 
local backitems =
{
    ["Broń"] = {
        "test",
}
}
 
 
backwardscarfting = {
        {"test",1,"Aluminium",1,"---",0,"---",0,"---",0},
}
 
function getcraftingbackwardsitems (text)
    for i,item in ipairs(backwardscarfting) do
        if item[1] == text then
            return item[2],item[3], item[4], item[5], item[6], item[7], item[8], item[9], item[10]
        end
    end
end
 
 
function opencrafting (key)
 
setElementData(getLocalPlayer(),"---",100000)
if getElementData(getLocalPlayer(),"craftingpannelstate") == 1 then
        setElementData(getLocalPlayer(),"craftingpannelstate",0)
        setElementData(getLocalPlayer(),"craftingpannelstate",0)
        guiSetVisible( plate,false)  
        guiSetVisible( GUIEditor.window[1],false)
       
        showCursor(false)
       
else
 
        setElementData(getLocalPlayer(),"craftingpannelstate",1)
        showCursor(true)
 
       
        GUIEditor.window[1] = guiCreateWindow(747, 381, 500, 299, "", false)
    --  GUIEditor.window[1] = guiCreateWindow(0.15, 0.28, 500, 299, "", true)
     
        guiWindowSetSizable(GUIEditor.window[1], false)
 
        GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 19, 617, 270, false, GUIEditor.window[1])
           
        GUIEditor.tab[1] = guiCreateTab("Instructions", GUIEditor.tabpanel[1])
        GUIEditor.memo[1] = guiCreateMemo(15, 16, 445, 211, "Panel craftingu. W tym panelu możesz wytwarzać nowe przedmioty. \n1: nacisnij \"Wytwarzanie\" lub \"Pozyskiwanie\" by wytworzyć nowy przedmiot lub go rozebrać\n2: Wybierz kategorie ()\n3: Wybierz item który chcesz wytworzyć i sprawdź czy masz odpowiednie przedmioty do tego\n4: Jeżeli wszystko jest na zielono klikcnij wytwórz\n5: Kdy pasek sie załaduje będziesz mógł zobaczyć nowy przedmiot w ekwipunku. ", false, GUIEditor.tab[1])
        guiMemoSetReadOnly(GUIEditor.memo[1], true)
 
        GUIEditor.tab[2] = guiCreateTab("Wytwarzanie", GUIEditor.tabpanel[1])
        GUIEditor.combobox[1] = guiCreateComboBox(25, 44, 170, 120, "Kategoria", false, GUIEditor.tab[2])
        GUIEditor.combobox[2] = guiCreateComboBox(225, 44, 170, 120, "Przedmiot", false, GUIEditor.tab[2])
        local progressBar = guiCreateProgressBar( 25, 200, 430, 20, false, GUIEditor.tab[2] )
        guiProgressBarSetProgress(progressBar,0 )
        craftbutton = guiCreateButton(25, 160, 430, 30, "Wytwórz", false,GUIEditor.tab[2])
        close = guiCreateButton(420, 19, 58, 20, "Zamknij", false, GUIEditor.tab[2])
        local itemname = guiCreateLabel( 25, 80, 800,15, "Nazwa:", false,GUIEditor.tab[2] )
        local Need1 = guiCreateLabel(25, 95, 800, 15,"Potrzeba:", false,GUIEditor.tab[2] )
        local Need2 = guiCreateLabel(25, 110, 800, 15,"Potrzeba:", false,GUIEditor.tab[2] )
        local Need3 = guiCreateLabel(25, 125, 800, 15,"Potrzeba:", false,GUIEditor.tab[2] )
        local Need4 = guiCreateLabel(25, 140, 800, 15,"Potrzeba:", false,GUIEditor.tab[2] )
        local infotext = guiCreateLabel (225, 95, 800, 15,"Postępuj z instrukcją", false,GUIEditor.tab[2] )
       
       
 
    for key, value in pairs (items) do
        if type(value) == "table" then
            guiComboBoxAddItem(GUIEditor.combobox[1], key)
        end
    end
   
    addEventHandler("onClientGUIComboBoxAccepted", GUIEditor.combobox[1],
    function()
    local text = guiComboBoxGetItemText(GUIEditor.combobox[1], guiComboBoxGetSelected(GUIEditor.combobox[1]))
        guiComboBoxClear(GUIEditor.combobox[2])
        for i, st in ipairs(items[text]) do
            guiComboBoxAddItem(GUIEditor.combobox[2], st)
        end
   end )
   
    addEventHandler("onClientGUIComboBoxAccepted", GUIEditor.combobox[2],
    function()
      local num = guiComboBoxGetSelected ( GUIEditor.combobox[2] )
      local item = tostring ( guiComboBoxGetItemText ( GUIEditor.combobox[2] , num ) )
      local win,need1,need1quat,need2,need2quat,need3,need3quat,need4,need4quat = getcraftingforwardsitems(item)
     
        guiSetText ( itemname, "Nazwa: "..item.." wytworzysz: "..win  )
        guiSetText ( Need1,"Potrzeba: "..need1.."~>"..need1quat)
        if getElementData(getLocalPlayer(),need1) > need1quat-1 then
        guiLabelSetColor ( Need1,0,255,0 )
        else
        guiLabelSetColor ( Need1,255,0,0 )
        end
        guiSetText ( Need2,"Potrzeba: "..need2.."~>"..need2quat )
        if getElementData(getLocalPlayer(),need2) > need2quat-1 then
        guiLabelSetColor ( Need2,0,255,0 )
        else
        guiLabelSetColor ( Need2,255,0,0 )
        end
        guiSetText ( Need3,"Potrzeba: "..need3.."~>"..need3quat )
        if getElementData(getLocalPlayer(),need3) > need3quat-1 then
        guiLabelSetColor ( Need3,0,255,0 )
        else
        guiLabelSetColor ( Need3,255,0,0 )
        end
        guiSetText ( Need4,"Potrzeba: "..need4.."~>"..need4quat )
        if getElementData(getLocalPlayer(),need4) > need4quat-1 then
        guiLabelSetColor ( Need4,0,255,0 )
        else
        guiLabelSetColor ( Need4,255,0,0 )
        end
       
   
        addEventHandler ( "onClientGUIClick", craftbutton,
        function()
        guiSetText ( infotext,"ERROR! Zgłoś to administracji" )
            guiLabelSetColor ( infotext,255,1,255 )
    if getElementData(getLocalPlayer(),"isinprog") then
            guiSetText ( infotext,"Please wait" )
            guiLabelSetColor ( infotext,255,255,5 )
        else
            if win then
             
                if getElementData(getLocalPlayer(),need1) > need1quat-1 and getElementData(getLocalPlayer(),need2) > need2quat-1 and getElementData(getLocalPlayer(),need3) > need3quat-1 and getElementData(getLocalPlayer(),need4) > need4quat-1 then
                    guiSetText ( infotext,"Buduje..." )
                    guiSetEnabled ( craftbutton, false )
                    guiLabelSetColor ( infotext,0,150,0 )
                    function startpogressbar() guiProgressBarSetProgress(progressBar,guiProgressBarGetProgress (progressBar)+5 )setElementData(getLocalPlayer(),"isinprog",true) end setTimer(startpogressbar,500,20)
                    function endpogressbar()
                    setElementData(getLocalPlayer(),"isinprog",false)
                        guiSetText ( infotext,"Zakończone! Przedmiot dodany do ekwipunku." )
                        guiLabelSetColor ( infotext,0,150,0 )
                        guiProgressBarSetProgress(progressBar,0 )
                        setElementData(getLocalPlayer(),need1,getElementData(getLocalPlayer(),need1)-need1quat)
                        setElementData(getLocalPlayer(),need2,getElementData(getLocalPlayer(),need2)-need2quat)
                        setElementData(getLocalPlayer(),need3,getElementData(getLocalPlayer(),need3)-need3quat)
                        setElementData(getLocalPlayer(),need4,getElementData(getLocalPlayer(),need4)-need4quat)
                        setElementData(getLocalPlayer(),item,getElementData(getLocalPlayer(),item)+win)
                         guiSetEnabled ( craftbutton, true )
                         refreshInventory()
                        guiSetText ( itemname, "przedmiot: "..item.." wytworzysz: "..win  )
                        guiSetText ( Need1,"Potrzeba: "..need1.."~>"..need1quat)
                        if getElementData(getLocalPlayer(),need1) > need1quat-1 then
                        guiLabelSetColor ( Need1,0,255,0 )
                        else
                        guiLabelSetColor ( Need1,255,0,0 )
                        end
                        guiSetText ( Need2,"Potrzeba: "..need2.."~>"..need2quat )
                        if getElementData(getLocalPlayer(),need2) > need2quat-1 then
                        guiLabelSetColor ( Need2,0,255,0 )
                        else
                        guiLabelSetColor ( Need2,255,0,0 )
                        end
                        guiSetText ( Need3,"Potrzeba: "..need3.."~>"..need3quat )
                        if getElementData(getLocalPlayer(),need3) > need3quat-1 then
                        guiLabelSetColor ( Need3,0,255,0 )
                        else
                        guiLabelSetColor ( Need3,255,0,0 )
                        end
                        guiSetText ( Need4,"Potrzeba: "..need4.."~>"..need4quat )
                        if getElementData(getLocalPlayer(),need4) > need4quat-1 then
                        guiLabelSetColor ( Need4,0,255,0 )
                        else
                        guiLabelSetColor ( Need4,255,0,0 )
                        end
                       
                    end setTimer(endpogressbar,11000,1)
 
                    else
                    guiSetText ( infotext,"Nie masz wymaganych przedmiotów" )
                    guiLabelSetColor ( infotext,150,0,0 )
                end
            else
                guiSetText ( infotext,"Proszę, wybierz przedmiot" )
                guiLabelSetColor ( infotext,150,0,0 )
            end
    end
        end, false )
        end )
    -------------------------------------------------------------------------------
        GUIEditor.tab[3] = guiCreateTab("Pozyskiwanie", GUIEditor.tabpanel[1])  
        GUIEditor.combobox[3] = guiCreateComboBox(25, 44, 170, 120, "Kategoria", false, GUIEditor.tab[3])
        GUIEditor.combobox[4] = guiCreateComboBox(225, 44, 170, 120, "Przedmiot", false, GUIEditor.tab[3])
        local progressBar = guiCreateProgressBar( 25, 200, 430, 20, false, GUIEditor.tab[3] )
        guiProgressBarSetProgress(progressBar,0 )
        close2 = guiCreateButton(420, 19, 58, 20, "Zamknij", false, GUIEditor.tab[3])
        bcraftbutton = guiCreateButton(25, 160, 430, 30, "Wytwórz", false,GUIEditor.tab[3])
        local itemname = guiCreateLabel( 25, 80, 800,15, "przedmiot:", false,GUIEditor.tab[3] )
        local Win1 = guiCreateLabel(25, 95, 800, 15,"Dostaniesz:", false,GUIEditor.tab[3] )
        local Win2 = guiCreateLabel(25, 110, 800, 15,"Dostaniesz:", false,GUIEditor.tab[3] )
        local Win3 = guiCreateLabel(25, 125, 800, 15,"Dostaniesz:", false,GUIEditor.tab[3] )
        local Win4 = guiCreateLabel(25, 140, 800, 15,"Dostaniesz:", false,GUIEditor.tab[3] )
        local infotext2 = guiCreateLabel (225, 95, 800, 15,"Proszę postępuj zgodznie z instrukcją", false,GUIEditor.tab[3] )
       
       
 
    for key, value in pairs (backitems) do
        if type(value) == "table" then
            guiComboBoxAddItem(GUIEditor.combobox[3], key)
        end
    end
   
    addEventHandler("onClientGUIComboBoxAccepted", GUIEditor.combobox[3],
    function()
    local text = guiComboBoxGetItemText(GUIEditor.combobox[3], guiComboBoxGetSelected(GUIEditor.combobox[3]))
        guiComboBoxClear(GUIEditor.combobox[4])
        for i, st in ipairs(backitems[text]) do
            guiComboBoxAddItem(GUIEditor.combobox[4], st)
        end
   end )
   
    addEventHandler("onClientGUIComboBoxAccepted", GUIEditor.combobox[4],
    function()
      local num = guiComboBoxGetSelected ( GUIEditor.combobox[4])
      local item = tostring ( guiComboBoxGetItemText ( GUIEditor.combobox[4] , num ) )
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...