Jump to content

[HELP] Index a boolean value


Recommended Posts

Hello guys, I got this inventory system from community but I get an error when opening the inventory panel:

local aktuel,oldaktuel = "Potte","Potte" 
  
function showInventar(teil) 
    if(type(teil) == "string" and teil ~= "i") then 
        aktuel = teil 
    end 
    unbindKey("i","down",showInventar) 
    bindKey("i","down",destroyInventar) 
    showCursor ( true ,false) 
    toggleControl ( "fire", false) 
    pClose,pMove,pReset = "images/closeinv.png","images/moveinv.png","images/reset.png" 
    r,g,b = { ["Potte"]=110,["Taschen"]=110,["Keys"]=110,["Waffen"]=110, ["Rahmen"]=255} , { ["Potte"]=110,["Taschen"]=110,["Keys"]=110,["Waffen"]=110 ,["Rahmen"]=255} , { ["Potte"]=110,["Taschen"]=110,["Keys"]=110,["Waffen"]=110,["Rahmen"]=255 } 
      
    slots = tonumber(getElementData(getLocalPlayer(),"Inventar_c")[aktuel.."Platz"]) 
    lines = math.ceil(slots/7) 
    bx,by = 330, 20 - 4 + 45*lines --543,266 
    if(not x and not y) then 
        x,y = fx/2 - bx/2,fy/2 - by/2 
    end 
    r[aktuel],g[aktuel],b[aktuel] = 0,255,0 
    r["o"..aktuel],g["o"..aktuel],b["o"..aktuel] = 0,255,0 
    local line 
    local oline 
    local platz 
     
    for i=0,slots-1,1 do 
        line = math.floor(i/7) 
        if(line ~= oline) then  
            platz = 0  
        end 
        btn_inventar[aktuel][i] = guiCreateButton (x+10 + 40 * platz + 5 * platz,y+10 + 40 * line + 5 * line,40,40, i.."", false) 
        guiSetAlpha(btn_inventar[aktuel][i],0) 
        local id 
        if( getElementData(getLocalPlayer(),"Item_"..aktuel.."_c") ) then 
            id = getElementData(getLocalPlayer(),"Item_"..aktuel.."_c")[i.."_id"] 
            if(id) then 
                item[id]= { ["x"]= x+10 + 40 * platz + 5 * platz ,["y"]=y+10 + 40 * line + 5 * line } 
                itemFront[id] = false 
            end 
        end 
        if(not lockItemUseState[aktuel] or not lockItemUseState[aktuel][tonumber(i)]) then 
            setItemRGB(i,110,110,110) 
        end 
        sitem[i]= { ["x"]= x+10 + 40 * platz + 5 * platz,["y"]=y+10 + 40 * line + 5 * line } 
        oline = line 
        platz = platz + 1 
    end 
     
    btn_Potte = guiCreateButton (x+2,y-48,80.0,48.0, "", false) 
    guiSetAlpha(btn_Potte,0) 
    btn_Keys = guiCreateButton ( x+2 + 82,y-48, 80.0,48.0, "", false ) 
    guiSetAlpha(btn_Keys,0) 
    btn_Taschen = guiCreateButton ( x+2 + 82*2,y-48, 80.0,48.0, "", false ) 
    guiSetAlpha(btn_Taschen,0) 
    btn_Waffen = guiCreateButton ( x+2 + 82*3,y-48, 80.0,48.0, "", false ) 
    guiSetAlpha(btn_Waffen,0) 
    btn_Close = guiCreateButton ( x+bx + 1,y-49, 18,18, "", false  ) 
    guiSetAlpha(btn_Close,0) 
    btn_Move = guiCreateButton ( x+bx + 1,y-49+18, 18,18, "", false ) 
    guiSetAlpha(btn_Move,0) 
    btn_Reset = guiCreateButton ( x+bx + 1,y-49+36, 18,18, "", false ) 
    guiSetAlpha(btn_Reset,0) 
     
     
    addEventHandler("onClientMouseEnter",getRootElement(),onButtonInvEnter) 
    addEventHandler("onClientMouseLeave",getRootElement(),onButtonInvLeave) 
    addEventHandler("onClientGUIClick",getRootElement(),onInvClick) 
     
    addEventHandler("onClientMouseEnter",getRootElement(),onItemMouseOver) 
    addEventHandler("onClientMouseLeave",getRootElement(),onItemMouseLeave) 
     
    addEventHandler("onClientGUIClick",btn_Close,onCloseClick) 
    addEventHandler("onClientGUIMouseDown",btn_Move,onMoveClick) 
    addEventHandler("onClientGUIMouseUp",btn_Move,onStopMove) 
    addEventHandler("onClientGUIClick",btn_Reset,onResetClick) 
     
    addEventHandler("onClientGUIMouseDown",getRootElement(),onClickAndDropDown) 
    addEventHandler("onClientGUIMouseUp",getRootElement(),onClickAndDropUp) 
     
     
    addEventHandler("onClientRender",getRootElement(),renderInventar) 
end 

I get an attempt to index a boolean value here:

slots = tonumber(getElementData(getLocalPlayer(),"Inventar_c")[aktuel.."Platz"]) 

Any ideas what's wrong with it?

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