Jump to content

Swagy

Members
  • Posts

    88
  • Joined

  • Last visited

Posts posted by Swagy

  1. @Necktrox I was running your JS on my Debian 8 machine, but I got 2 Errors, the first was solved thanks to Luca, the second one, isn't fixed which is: SyntaxError: Unexpected Identifier.
    at Module._compile (module.js:439:25)
    at Object.Module._extensions (module.js:470:10)
    at Module.load (module.js:356:32)
    ...etc what to do?

     

    1. --[[
    2. -- Resource Name: Information.
    3. -- Author: Om (RipeMangoes69)
    4. -- Date: 4/12/2016
    5. -- File: client.lua
    6. ]]--
    7.  
    8. -- GUI
    9.  
    10.  
    11.  
    12. GUIEditor = {
    13. window = {},
    14. label = {},
    15. memo = {}
    16. }
    17.  
    18. GUIEditor.window[1] = guiCreateWindow(645, 250, 266, 378, "Information: " .. m.area, false)
    19. guiWindowSetSizable(GUIEditor.window[1], false)
    20. guiSetVisible(GUIEditor.window[1], false)
    21. GUIEditor.label[1] = guiCreateLabel(5, 353, 190, 15, "* Click anywhere on GUI Window to close it.", false, GUIEditor.window[1])
    22. guiSetFont(GUIEditor.label[1], "default-small")
    23. GUIEditor.memo[1] = guiCreateMemo(9, 24, 247, 324, "", false, GUIEditor.window[1])
    24. guiMemoSetReadOnly(GUIEditor.memo[1], true)
    25. local markers = {}
    26.  
    1. function createInfoObjects()
    2. local markers = {
    3. {area = "Los Santos Airport", x = 1582.45, y = -2286.32, z = 12},
    4. {area = "Las Vegas Airport", x = 1674.30859375, y = 1444.9501953125, z = 9.2}
    5. }
    6.  
    7. for i, m in ipairs(markers) do
    8. local marker = createMarker(m.x, m.y, m.z, "cylinder", 1, 255, 255, 255, 100)
    9. markers[marker] = i
    10. end
    11. end
    12. addEventHandler("onClientResourceStart", getRootElement(), createInfoObjects)
    13.  
    14.  
    15. function openGUI( hitElement, matchingDimension )
    16. if getElementType( hitElement ) == "player" and markers[source] then
    17. if isPedInVehicle(hitElement) then
    18. outputChatBox("You cannot access GUI from vehicle!", 255, 0, 0)
    19. guiSetVisible(GUIEditor.window[1], false)
    20. showCursor(false)
    21. else
    22. guiSetVisible(GUIEditor.window[1], true)
    23. guiSetText(GUIEditor.window[1],makers[source]["area"])
    24. showCursor(true)
    25. end
    26. end
    27. end
    28. addEventHandler("onClientMarkerHit", resourceRoot, openGUI)
    29.  
    30. function closeGUI()
    31. guiSetVisible(GUIEditor.window[1], false)
    32. showCursor(false)
    33. end
    34. addEventHandler("onClientGUIClick", resourceRoot, closeGUI)
  2. Well, this is an inventory system, so If you drop the item, it will create a pickup and when you take the pickup it gives +1 that item, 

     

    the error is: Expected element at argument 2, got boolean 

     

    for addEventHandler ("onClientPickupHit", pickUp, function)

  3. Well title says it all, check this

    GUIEditor = {
        gridlist = {},
        window = {},
        button = {}
    }
    GUIEditor.window[1] = guiCreateWindow(0.04, 0.22, 0.40, 0.71, "My Inventory", true)
    guiWindowSetSizable(GUIEditor.window[1], false)
    	GUIEditor.gridlist[1] = guiCreateGridList(0.03, 0.07, 0.93, 0.82, true, GUIEditor.window[1])
    guiGridListAddColumn(GUIEditor.gridlist[1], "Item", 0.5)
    guiGridListAddColumn(GUIEditor.gridlist[1], "Amount", 0.5)
    GUIEditor.button[1] = guiCreateButton(0.03, 0.89, 0.31, 0.08, "Use", true, GUIEditor.window[1])
    guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA")
    GUIEditor.button[2] = guiCreateButton(0.66, 0.89, 0.31, 0.08, "Drop", true, GUIEditor.window[1])
    guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA")
    	
    guiSetVisible (GUIEditor.window[1], false)
    	
    PR = {
        label = {},
        progressbar = {}
    }
    PR.progressbar[1] = guiCreateProgressBar(0.18, 0.47, 0.64, 0.06, true)
    	PR.label[1] = guiCreateLabel((516 - 101) / 2, (34 - 16) / 2, 101, 16, "Using Repair Kit...", false, PR.progressbar[1])
    guiSetFont(PR.label[1], "default-bold-small")
    guiLabelSetColor(PR.label[1], 1, 126, 253)
    	guiProgressBarSetProgress(PR.progressbar[1], 0)
    guiSetVisible (PR.progressbar[1], false)
    	
    function openGUI (result)
    	if guiGetVisible (GUIEditor.window[1]) == true then
    guiSetVisible (GUIEditor.window[1], false)
    showCursor (false)
    guiGridListClear (GUIEditor.gridlist[1], true)
    outputChatBox ("Bag closed successfully !", 255,0,0)
    else
    guiSetVisible (GUIEditor.window[1], true)
    showCursor (true)
    guiGridListClear (GUIEditor.gridlist[1], true)
    outputChatBox ("Bag opened successfully !", 255,255,0)
        for k,v in ipairs (result) do
            local row1 = guiGridListAddRow(GUIEditor.gridlist[1])
            guiGridListSetItemText(GUIEditor.gridlist[1], row1, 1, v["itemname"] , false, false)
            guiGridListSetItemText(GUIEditor.gridlist[1], row1, 2, v["amoun"] , false, false)
        end
    end
    end
    addEvent ("onOpenGUI", true)
    addEventHandler ("onOpenGUI", root, openGUI)
    	function useObject ()
    	local item = guiGridListGetItemText(GUIEditor.gridlist[1], guiGridListGetSelectedItem(GUIEditor.gridlist[1]), 1)
    local amount = guiGridListGetItemText(GUIEditor.gridlist[1], guiGridListGetSelectedItem(GUIEditor.gridlist[1]), 2)
    if (source == GUIEditor.button[1]) then
        if item == "Medic Kits" then
            if tonumber(amount) > 0 then
                local pHp = getElementHealth (localPlayer)
                if tonumber (pHp) < 100 then
                guiSetVisible (PR.progressbar[1], true)
                guiSetText (PR.label[1], "Using Medic Kit...")
                guiProgressBarSetProgress(PR.progressbar[1], 0)
                setTimer (function () guiProgressBarSetProgress(PR.progressbar[1], 20)end,500,1)
                setTimer (function () guiProgressBarSetProgress(PR.progressbar[1], 40)end,1000,1)
                setTimer (function () guiProgressBarSetProgress(PR.progressbar[1], 60)end,1500,1)
                setTimer (function () guiProgressBarSetProgress(PR.progressbar[1], 80)end,2000,1)
                setTimer (function ()setElementHealth (localPlayer, pHp+30) guiProgressBarSetProgress (PR.progressbar[1],100) guiSetVisible (PR.progressbar[1], false)end,2500,1)
                triggerServerEvent ("onUse", localPlayer, item)
                outputChatBox ("You have taken 1 Medic Kit It will take effect in 5 seconds.", 255,255,255)
                guiSetVisible (GUIEditor.window[1], false)
                showCursor (false)
                else
                outputChatBox ("Your HP is full!", 255,0,0)
                end
            end
        elseif item == "Food" then
            if tonumber(amount) > 0 then
                local pHp = getElementHealth (localPlayer)
                if tonumber (getElementHealth (localPlayer)) < 100 then
                guiSetVisible (PR.progressbar[1], true)
                guiSetText (PR.label[1], "Eating some food...")
                guiProgressBarSetProgress(PR.progressbar[1], 0)
                setTimer (function () guiProgressBarSetProgress(PR.progressbar[1], 20)end,500,1)
                setTimer (function () guiProgressBarSetProgress(PR.progressbar[1], 40)end,1000,1)
                setTimer (function () guiProgressBarSetProgress(PR.progressbar[1], 60)end,1500,1)
                setTimer (function () guiProgressBarSetProgress(PR.progressbar[1], 80)end,2000,1)
                setTimer (function ()setElementHealth (localPlayer, pHp+10) guiProgressBarSetProgress (PR.progressbar[1],100) guiSetVisible (PR.progressbar[1], false)end,2500,1)
                triggerServerEvent ("onUse", localPlayer, item)
                outputChatBox ("You have taken some Food It will take effect in 5 seconds.", 255,255,255)
                guiSetVisible (GUIEditor.window[1], false)
                showCursor (false)
                else
                outputChatBox ("Your HP is full!", 255,0,0)
                end
            end
        elseif item == "Repair Kits" then
            if tonumber(amount) > 0 then
            local vehicle = getPedOccupiedVehicle (localPlayer)
            local vehHP = getElementHealth (vehicle)
                if (vehicle) then
                if tonumber (vehHP) < 1000 then
                guiSetVisible (PR.progressbar[1], true)
                setElementFrozen (localPlayer, true)
                guiProgressBarSetProgress(PR.progressbar[1], 0)
                setTimer (function () guiProgressBarSetProgress(PR.progressbar[1], 20)end,500,1)
                setTimer (function () guiProgressBarSetProgress(PR.progressbar[1], 40)end,1000,1)
                setTimer (function () guiProgressBarSetProgress(PR.progressbar[1], 60)end,1500,1)
                setTimer (function () guiProgressBarSetProgress(PR.progressbar[1], 80)end,2000,1)
                setTimer (function () setElementHealth (vehicle, vehHP+250) guiProgressBarSetProgress (PR.progressbar[1],100) guiSetVisible (PR.progressbar[1], false) setElementFrozen (localPlayer, false)end,2500,1)
                triggerServerEvent ("onUse", localPlayer, item)
                outputChatBox ("You have taken 1 Repair Kit It will take effect in 5 seconds.", 255,255,255)
                guiSetVisible (GUIEditor.window[1], false)
                showCursor (false)
                else
                outputChatBox ("Your Vehicle's HP is full!", 255,0,0)
                end
                else
                outputChatBox ("You're not in a vehicle!",255,0,0)
                end
            end
        else
        outputChatBox ("You either can't use this item or you have 0 units of this item !" ,255,0,0)
        end
    end
    end
    addEventHandler ("onClientGUIClick", root, useObject)
    	function dropItem ()
    local item = guiGridListGetItemText(GUIEditor.gridlist[1], guiGridListGetSelectedItem(GUIEditor.gridlist[1]), 1)
    local x,y,z = getElementPosition (localPlayer)
    	if (source == GUIEditor.button[2]) then
    if (item) then
        if item == "Medic Kits" then
                  pickUp = createPickup ( x, y, z, 3, 1240 )
                 outputChatBox ("You have dropped a Medic Kit !",255,255,255)
                 guiSetVisible(GUIEditor.window[1], false)
                 showCursor(false)
            dropped = "Medic Kits"
            triggerServerEvent ("onUse", localPlayer, item)
        elseif item == "Repair Kits" then
                 pickUp = createPickup ( x, y, z, 3, 1277 )
                 outputChatBox ("You have dropped a Repair Kit !",255,255,255)
                 guiSetVisible(GUIEditor.window[1], false)
                 showCursor(false)
            dropped = "Repair Kits"
            triggerServerEvent ("onUse", localPlayer, item)
        elseif item == "Food" then
                 pickUp = createPickup ( x, y, z, 3, 2212 )
                 outputChatBox ("You have dropped some food !",255,255,255)
                 guiSetVisible(GUIEditor.window[1], false)
                 showCursor(false)
            dropped = "Food"
            triggerServerEvent ("onUse", localPlayer, item)
        elseif item == "Wood" then
                 pickUp = createPickup ( x, y, z, 3, 1448 )
                 outputChatBox ("You have dropped wood !",255,255,255)
                 guiSetVisible(GUIEditor.window[1], false)
                 showCursor(false)
            dropped = "Wood"
            triggerServerEvent ("onUse", localPlayer, item)
        elseif item == "Oil" then
                 pickUp = createPickup ( x, y, z, 3, 1217 )
                 outputChatBox ("You have dropped some Oil !",255,255,255)
                 guiSetVisible(GUIEditor.window[1], false)
                 showCursor(false)
            dropped = "Oil"
            triggerServerEvent ("onUse", localPlayer, item)
        else
            pickUp = createPickup ( x, y, z, 3, 1279 )
                 outputChatBox ("You have dropped a ".. item .." !",255,255,255)
                 guiSetVisible(GUIEditor.window[1], false)
                 showCursor(false)
            dropped = item
            triggerServerEvent ("onUse", localPlayer, item)
        end
    end
    end
    end
    addEventHandler ("onClientGUIClick", root, dropItem)
    	
    function takeObject ()
    triggerServerEvent ("onTakeObject", localPlayer, dropped)
    end
    addEventHandler ("onClientPickupHit", pickUp, takeObject)
    

×
×
  • Create New...