Jump to content

Shop


-.Paradox.-

Recommended Posts

Posted

Hello, i got an error in debug, and i cant find the problem (it was working before)

here is the error

ERROR: Shops\c_gui:92: attempt to index field 'window' (a nil value)

Here is my code (Client)

  
GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    button = {} 
} 
  
  
  
        GUIEditor.window[2] = guiCreateWindow(527, 227, 409, 336, "Shop ", false) 
        guiWindowSetSizable(GUIEditor.window[2], false) 
        guiSetAlpha(GUIEditor.window[2], 1.00) 
        GUIEditor.gridlist[1] = guiCreateGridList(12, 27, 276, 299, false, GUIEditor.window[2]) 
        guiGridListAddColumn(GUIEditor.gridlist[1], "Shop", 0.4) 
        guiGridListAddColumn(GUIEditor.gridlist[1], "$", 0.4) 
        for i = 1, 8 do 
            guiGridListAddRow(GUIEditor.gridlist[1]) 
        end 
        guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "Health", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 0, 2, "$1000", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "Armor", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 1, 2, "$1000", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "Repair Vehicle", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 2, 2, "$1000", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 3, 1, "Jetpack", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 3, 2, "$7600", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 4, 1, "Parachute", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 4, 2, "$500", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 5, 1, "Night Vision Googles", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 5, 2, "$750", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 6, 1, "Infrared Googles", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 6, 2, "$750", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 7, 1, "Camera", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 7, 2, "$2000", false, false) 
        GUIEditor.button[1] = guiCreateButton(295, 253, 104, 63, "Close", false, GUIEditor.window[2]) 
        guiSetFont(GUIEditor.button[1], "default-bold-small") 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFFFFFF") 
        GUIEditor.button[2] = guiCreateButton(295, 174, 103, 63, "Buy", false, GUIEditor.window[2]) 
        guiSetFont(GUIEditor.button[2], "default-bold-small") 
        guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFFFFFFF")     
        guiSetVisible(GUIEditor.window[2], false) 
        showCursor(false) 
  
function enableShop() 
    if guiGetVisible(GUIEditor.window[2]) == false then 
        guiSetVisible(GUIEditor.window[2], true) 
        showCursor(true) 
    else 
        guiSetVisible(GUIEditor.window[2], false) 
        showCursor(false) 
    end 
end 
bindKey("F4","down", enableShop) 
  
function closeButton() 
        guiSetVisible(GUIEditor.window[2], false) 
        showCursor(false) 
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[1], closeButton, false ) 
  
addEventHandler("onClientGUIClick", guiRoot, 
function() 
    if source == GUIEditor.button[2] then 
        local row = guiGridListGetSelectedItem(GUIEditor.gridlist[1]) 
        if row == 0 then 
            triggerServerEvent("setMyHealth", localPlayer) 
        elseif row == 1 then 
            triggerServerEvent("setMyArmor", localPlayer) 
        elseif row == 2 then 
            triggerServerEvent("repairMyCar", localPlayer) 
        elseif row == 3 then 
            triggerServerEvent("giveMeJetpack", localPlayer) 
        elseif row == 4 then 
            triggerServerEvent("giveMeParachute", localPlayer) 
        elseif row == 5 then 
            triggerServerEvent("giveMeNight", localPlayer) 
        elseif row == 6 then 
            triggerServerEvent("giveMeInfrared", localPlayer) 
        elseif row == 7 then 
            triggerServerEvent("giveMeCamera", localPlayer) 
        end 
    end 
end) 
  
local Marker = createMarker(241.39999,1861.90002,7.7, "cylinder", 1, 0,250,138) 
setElementInterior (Marker,0) 
setElementDimension (Marker, 0) 
  
  
 function shopHealth(hitElement) 
             if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
                  if not guiGetVisible(GUIEditor.window[2]) then 
                       guiSetVisible(GUIEditor.window[2], true) 
                       showCursor(true) 
                  end 
             end 
        end 
addEventHandler("onClientMarkerHit",Marker, shopHealth) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

I can't see anything wrong here, make sure you have these lines include in your script (never forget them).

GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    button = {} 
} 

CiTLh.png
Posted

They are, i tried several times to find the problem but idk where :/

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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