Jump to content

Urgent problem about GUI


jingzhi

Recommended Posts

Client side

  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
local screenW, screenH = guiGetScreenSize() 
        AmmoMenu = guiCreateWindow((screenW - 465) / 2, (screenH - 834) / 2, 465, 834, "Ammu-Nation", false) 
        guiWindowSetSizable(AmmoMenu, false) 
        AmmuNationImage = guiCreateStaticImage(67, 54, 332, 88, ":weapons/ammu-nation.png", false, AmmoMenu) 
        TazerImage = guiCreateStaticImage(52, 179, 70, 56, ":weapons/Tazer.png", false, AmmoMenu) 
        PistolImage = guiCreateStaticImage(52, 253, 70, 59, ":weapons/Pistol.png", false, AmmoMenu) 
        DeserteagleImage = guiCreateStaticImage(52, 328, 70, 55, ":weapons/Desert_Eagle.png", false, AmmoMenu) 
        Ak47Image = guiCreateStaticImage(33, 739, 113, 44, ":weapons/ak47.png", false, AmmoMenu) 
        UziImage = guiCreateStaticImage(53, 401, 69, 52, ":weapons/uzi.png", false, AmmoMenu) 
        Tec9Image = guiCreateStaticImage(53, 468, 69, 50, ":weapons/tec9.png", false, AmmoMenu) 
        Mp5Image = guiCreateStaticImage(46, 532, 86, 45, ":weapons/mp5.png", false, AmmoMenu) 
        Spas12Image = guiCreateStaticImage(33, 592, 113, 50, ":weapons/Spas-12.png", false, AmmoMenu) 
        M4Image = guiCreateStaticImage(33, 663, 114, 55, ":weapons/M4A1.png", false, AmmoMenu) 
        AmmountLabel = guiCreateLabel(196, 478, 55, 17, "Ammount", false, AmmoMenu) 
        AmmountTextbox = guiCreateEdit(172, 508, 104, 24, "", false, AmmoMenu) 
        guiEditSetMaxLength(QuantityTextbox, 6) 
        BuyButton = guiCreateButton(172, 729, 126, 59, "Buy Cart", false, AmmoMenu) 
        guiSetFont(BuyButton, "default-bold-small") 
        guiSetProperty(BuyButton, "NormalTextColour", "FF0000FF") 
        QuitButton = guiCreateButton(315, 729, 126, 59, "Quit", false, AmmoMenu) 
        guiSetFont(QuitButton, "default-bold-small") 
        guiSetProperty(QuitButton, "NormalTextColour", "FFFF0000") 
        Cartlist = guiCreateGridList(172, 551, 269, 122, false, AmmoMenu) 
        Weaponcolumn = guiGridListAddColumn(Cartlist, "Weapon", 0.3) 
        Amountcolumn = guiGridListAddColumn(Cartlist, "Amount", 0.3) 
        Pricecolumn = guiGridListAddColumn(Cartlist, "Price", 0.3)  
        AddcartButton = guiCreateButton(314, 508, 89, 27, "Add to cart", false, AmmoMenu) 
        WeaponInfo = guiCreateScrollPane(177, 179, 223, 238, false, AmmoMenu)     
        Infolabel = guiCreateLabel(17, 150, 150, 19, "Press icon for information", false, AmmoMenu) 
        guiSetFont(Infolabel, "default-bold-small") 
        guiGridListSetSortingEnabled (Cartlist,false) 
        guiSetVisible(AmmoMenu,false) 
    end 
) 
  
  
  
  
function chooseweapon() 
    if source == TazerImage then 
        setElementData(localPlayer,"WeaponChosen",23) 
    end 
    if source == PistolImage then 
        setElementData(localPlayer,"WeaponChosen",22) 
    end 
    if source == DeserteagleImage then 
        setElementData(localPlayer,"WeaponChosen",24) 
    end 
    if source == Ak47Image then 
        setElementData(localPlayer,"WeaponChosen",30) 
    end 
    if source == UziImage then 
        setElementData(localPlayer,"WeaponChosen",28) 
    end 
    if source == Tec9Image then 
        setElementData(localPlayer,"WeaponChosen",32) 
    end 
    if source == Mp5Image then 
        setElementData(localPlayer,"WeaponChosen",29) 
    end 
    if source == Spas12Image then 
        setElementData(localPlayer,"WeaponChosen",27) 
    end 
    if source == M4Image then 
        setElementData(localPlayer,"WeaponChosen",31) 
    end 
    if source == BuyButton then 
        if guiGridListGetRowCount(Cartlist) > 0 then 
            triggerServerEvent("GiveWeapon",resourceRoot,localPlayer,guiGetText(AmmountTextbox)) 
        else 
            outputChatBox("You don't have anything in your cart!",localPlayer,255,0,0) 
        end 
    end 
    if source == QuitButton then 
        showCursor(false) 
        guiSetVisible(AmmoMenu,false)   
        guiGridListClear (Cartlist) 
        guiSetText (AmmountTextbox,"") 
    end 
    if source == AddcartButton then 
        if getElementData("weaponprice") ~= false then 
            if tonumber(guiGetText(AmmountTextbox)) > 0 and tonumber(guiGetText(AmmountTextbox)) ~= nil then  
                guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Weaponcolumn,..getWeaponNameFromID(getElementData(localPlayer,"WeaponChosen"))) 
                guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Amountcolumn,..guiGetText(AmmountTextbox)..) 
                guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Pricecolumn,"$"..tostring(math.floor(10 * guiGetText(AmmountTextbox))))              
            else 
                outputChatBox("Please enter a integer as the ammount of ammo",localPlayer,255,0,0) 
            end 
        else 
            outputChatBox("Please choose a weapon by clicking on the icon of it",localPlayer,255,0,0) 
        end 
    end 
end  
addEventHandler("onClientGUIClick",resourceRoot,chooseweapon) 
     
addEvent("showweaponGUI",true) 
function showGUI(player) 
    if getElementType(player) == "player" then 
    outputChatBox("true") 
    showCursor(true) 
    guiSetVisible(AmmoMenu,true) 
end 
end 
addEventHandler("showweaponGUI",getRootElement(),showGUI) 
     
  

Server Side

local weaponmarker = createMarker(296.42404,-38.29199,1000.5,"cylinder",1.5,0,255,0) 
setElementInterior(weaponmarker,1) 
  
function showClientGUI(marker) 
    if marker == weaponmarker then 
        if getTeamName(getPlayerTeam(source)) ~= "Criminal" then 
            triggerClientEvent(source,"showweaponGUI",resourceRoot,source) 
        else 
            outputChatBox("Ammunation won't sell guns&ammos to criminals, buy it in black market",source,255,0,0) 
        end 
    end 
end 
addEventHandler("onPlayerMarkerHit",getRootElement(),showClientGUI) 
  
addEvent("GiveWeapon",true) 
addEventHandler("GiveWeapon",getRootElement(), 
function(buyer,quantity) 
    if getPlayerMoney(buyer) >= math.floor(quantity * 10) then 
        giveWeapon(buyer,getElementData(buyer,"WeaponChosen"),quantity) 
        takePlayerMoney(buyer,math.floor(quantity * 10)) 
    else 
        outputChatBox("You don't have enough money for this",buyer,255,0,0) 
    end 
end) 

I am trying to make the GUI for ammunation, but now when i walk in the marker the GUI doesn't show, please help and thanks :)

Link to comment
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
local screenW, screenH = guiGetScreenSize() 
        AmmoMenu = guiCreateWindow((screenW - 465) / 2, (screenH - 834) / 2, 465, 834, "Ammu-Nation", false) 
        guiWindowSetSizable(AmmoMenu, false) 
        AmmuNationImage = guiCreateStaticImage(67, 54, 332, 88, ":weapons/ammu-nation.png", false, AmmoMenu) 
        TazerImage = guiCreateStaticImage(52, 179, 70, 56, ":weapons/Tazer.png", false, AmmoMenu) 
        PistolImage = guiCreateStaticImage(52, 253, 70, 59, ":weapons/Pistol.png", false, AmmoMenu) 
        DeserteagleImage = guiCreateStaticImage(52, 328, 70, 55, ":weapons/Desert_Eagle.png", false, AmmoMenu) 
        Ak47Image = guiCreateStaticImage(33, 739, 113, 44, ":weapons/ak47.png", false, AmmoMenu) 
        UziImage = guiCreateStaticImage(53, 401, 69, 52, ":weapons/uzi.png", false, AmmoMenu) 
        Tec9Image = guiCreateStaticImage(53, 468, 69, 50, ":weapons/tec9.png", false, AmmoMenu) 
        Mp5Image = guiCreateStaticImage(46, 532, 86, 45, ":weapons/mp5.png", false, AmmoMenu) 
        Spas12Image = guiCreateStaticImage(33, 592, 113, 50, ":weapons/Spas-12.png", false, AmmoMenu) 
        M4Image = guiCreateStaticImage(33, 663, 114, 55, ":weapons/M4A1.png", false, AmmoMenu) 
        AmmountLabel = guiCreateLabel(196, 478, 55, 17, "Ammount", false, AmmoMenu) 
        AmmountTextbox = guiCreateEdit(172, 508, 104, 24, "", false, AmmoMenu) 
        guiEditSetMaxLength(QuantityTextbox, 6) 
        BuyButton = guiCreateButton(172, 729, 126, 59, "Buy Cart", false, AmmoMenu) 
        guiSetFont(BuyButton, "default-bold-small") 
        guiSetProperty(BuyButton, "NormalTextColour", "FF0000FF") 
        QuitButton = guiCreateButton(315, 729, 126, 59, "Quit", false, AmmoMenu) 
        guiSetFont(QuitButton, "default-bold-small") 
        guiSetProperty(QuitButton, "NormalTextColour", "FFFF0000") 
        Cartlist = guiCreateGridList(172, 551, 269, 122, false, AmmoMenu) 
        Weaponcolumn = guiGridListAddColumn(Cartlist, "Weapon", 0.3) 
        Amountcolumn = guiGridListAddColumn(Cartlist, "Amount", 0.3) 
        Pricecolumn = guiGridListAddColumn(Cartlist, "Price", 0.3) 
        AddcartButton = guiCreateButton(314, 508, 89, 27, "Add to cart", false, AmmoMenu) 
        WeaponInfo = guiCreateScrollPane(177, 179, 223, 238, false, AmmoMenu)     
        Infolabel = guiCreateLabel(17, 150, 150, 19, "Press icon for information", false, AmmoMenu) 
        guiSetFont(Infolabel, "default-bold-small") 
        guiGridListSetSortingEnabled (Cartlist,false) 
        guiSetVisible(AmmoMenu,false) 
    end 
) 
  
  
  
  
function chooseweapon() 
    if source == TazerImage then 
        setElementData(localPlayer,"WeaponChosen",23) 
    end 
    if source == PistolImage then 
        setElementData(localPlayer,"WeaponChosen",22) 
    end 
    if source == DeserteagleImage then 
        setElementData(localPlayer,"WeaponChosen",24) 
    end 
    if source == Ak47Image then 
        setElementData(localPlayer,"WeaponChosen",30) 
    end 
    if source == UziImage then 
        setElementData(localPlayer,"WeaponChosen",28) 
    end 
    if source == Tec9Image then 
        setElementData(localPlayer,"WeaponChosen",32) 
    end 
    if source == Mp5Image then 
        setElementData(localPlayer,"WeaponChosen",29) 
    end 
    if source == Spas12Image then 
        setElementData(localPlayer,"WeaponChosen",27) 
    end 
    if source == M4Image then 
        setElementData(localPlayer,"WeaponChosen",31) 
    end 
    if source == BuyButton then 
        if guiGridListGetRowCount(Cartlist) > 0 then 
            triggerServerEvent("GiveWeapon",resourceRoot,localPlayer,guiGetText(AmmountTextbox)) 
        else 
            outputChatBox("You don't have anything in your cart!",localPlayer,255,0,0) 
        end 
    end 
    if source == QuitButton then 
        showCursor(false) 
        guiSetVisible(AmmoMenu,false)   
        guiGridListClear (Cartlist) 
        guiSetText (AmmountTextbox,"") 
    end 
    if source == AddcartButton then 
        if getElementData("weaponprice") ~= false then 
            if tonumber(guiGetText(AmmountTextbox)) > 0 and tonumber(guiGetText(AmmountTextbox)) ~= nil then 
                guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Weaponcolumn,..getWeaponNameFromID(getElementData(localPlayer,"WeaponChosen"))) 
                guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Amountcolumn,..guiGetText(AmmountTextbox)..) 
                guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Pricecolumn,"$"..tostring(math.floor(10 * guiGetText(AmmountTextbox))))             
            else 
                outputChatBox("Please enter a integer as the ammount of ammo",localPlayer,255,0,0) 
            end 
        else 
            outputChatBox("Please choose a weapon by clicking on the icon of it",localPlayer,255,0,0) 
        end 
    end 
end 
addEventHandler("onClientGUIClick",resourceRoot,chooseweapon) 
    
addEvent("showweaponGUI",true) 
function showGUI() 
    outputChatBox("true") 
    showCursor(true) 
    guiSetVisible(AmmoMenu,true) 
end 
addEventHandler("showweaponGUI",getRootElement(),showGUI) 

  
local weaponmarker = createMarker(296.42404,-38.29199,1000.5,"cylinder",1.5,0,255,0) 
setElementInterior(weaponmarker,1) 
  
function showClientGUI(marker) 
    if marker == weaponmarker then 
        if getPlayerTeam(source) and getTeamName(getPlayerTeam(source)) ~= "Criminal" then 
            triggerClientEvent(source,"showweaponGUI",source) 
        else 
            outputChatBox("Ammunation won't sell guns&ammos to criminals, buy it in black market",source,255,0,0) 
        end 
    end 
end 
addEventHandler("onPlayerMarkerHit",getRootElement(),showClientGUI) 
  
addEvent("GiveWeapon",true) 
addEventHandler("GiveWeapon",getRootElement(), 
function(buyer,quantity) 
    if getPlayerMoney(buyer) >= math.floor(quantity * 10) then 
        giveWeapon(buyer,getElementData(buyer,"WeaponChosen"),quantity) 
        takePlayerMoney(buyer,math.floor(quantity * 10)) 
    else 
        outputChatBox("You don't have enough money for this",buyer,255,0,0) 
    end 
end) 

Link to comment
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
local screenW, screenH = guiGetScreenSize() 
        AmmoMenu = guiCreateWindow((screenW - 465) / 2, (screenH - 834) / 2, 465, 834, "Ammu-Nation", false) 
        guiWindowSetSizable(AmmoMenu, false) 
        AmmuNationImage = guiCreateStaticImage(67, 54, 332, 88, ":weapons/ammu-nation.png", false, AmmoMenu) 
        TazerImage = guiCreateStaticImage(52, 179, 70, 56, ":weapons/Tazer.png", false, AmmoMenu) 
        PistolImage = guiCreateStaticImage(52, 253, 70, 59, ":weapons/Pistol.png", false, AmmoMenu) 
        DeserteagleImage = guiCreateStaticImage(52, 328, 70, 55, ":weapons/Desert_Eagle.png", false, AmmoMenu) 
        Ak47Image = guiCreateStaticImage(33, 739, 113, 44, ":weapons/ak47.png", false, AmmoMenu) 
        UziImage = guiCreateStaticImage(53, 401, 69, 52, ":weapons/uzi.png", false, AmmoMenu) 
        Tec9Image = guiCreateStaticImage(53, 468, 69, 50, ":weapons/tec9.png", false, AmmoMenu) 
        Mp5Image = guiCreateStaticImage(46, 532, 86, 45, ":weapons/mp5.png", false, AmmoMenu) 
        Spas12Image = guiCreateStaticImage(33, 592, 113, 50, ":weapons/Spas-12.png", false, AmmoMenu) 
        M4Image = guiCreateStaticImage(33, 663, 114, 55, ":weapons/M4A1.png", false, AmmoMenu) 
        AmmountLabel = guiCreateLabel(196, 478, 55, 17, "Ammount", false, AmmoMenu) 
        AmmountTextbox = guiCreateEdit(172, 508, 104, 24, "", false, AmmoMenu) 
        guiEditSetMaxLength(QuantityTextbox, 6) 
        BuyButton = guiCreateButton(172, 729, 126, 59, "Buy Cart", false, AmmoMenu) 
        guiSetFont(BuyButton, "default-bold-small") 
        guiSetProperty(BuyButton, "NormalTextColour", "FF0000FF") 
        QuitButton = guiCreateButton(315, 729, 126, 59, "Quit", false, AmmoMenu) 
        guiSetFont(QuitButton, "default-bold-small") 
        guiSetProperty(QuitButton, "NormalTextColour", "FFFF0000") 
        Cartlist = guiCreateGridList(172, 551, 269, 122, false, AmmoMenu) 
        Weaponcolumn = guiGridListAddColumn(Cartlist, "Weapon", 0.3) 
        Amountcolumn = guiGridListAddColumn(Cartlist, "Amount", 0.3) 
        Pricecolumn = guiGridListAddColumn(Cartlist, "Price", 0.3) 
        AddcartButton = guiCreateButton(314, 508, 89, 27, "Add to cart", false, AmmoMenu) 
        WeaponInfo = guiCreateScrollPane(177, 179, 223, 238, false, AmmoMenu)     
        Infolabel = guiCreateLabel(17, 150, 150, 19, "Press icon for information", false, AmmoMenu) 
        guiSetFont(Infolabel, "default-bold-small") 
        guiGridListSetSortingEnabled (Cartlist,false) 
        guiSetVisible(AmmoMenu,false) 
    end 
) 
  
  
  
  
function chooseweapon() 
    if source == TazerImage then 
        setElementData(localPlayer,"WeaponChosen",23) 
    end 
    if source == PistolImage then 
        setElementData(localPlayer,"WeaponChosen",22) 
    end 
    if source == DeserteagleImage then 
        setElementData(localPlayer,"WeaponChosen",24) 
    end 
    if source == Ak47Image then 
        setElementData(localPlayer,"WeaponChosen",30) 
    end 
    if source == UziImage then 
        setElementData(localPlayer,"WeaponChosen",28) 
    end 
    if source == Tec9Image then 
        setElementData(localPlayer,"WeaponChosen",32) 
    end 
    if source == Mp5Image then 
        setElementData(localPlayer,"WeaponChosen",29) 
    end 
    if source == Spas12Image then 
        setElementData(localPlayer,"WeaponChosen",27) 
    end 
    if source == M4Image then 
        setElementData(localPlayer,"WeaponChosen",31) 
    end 
    if source == BuyButton then 
        if guiGridListGetRowCount(Cartlist) > 0 then 
            triggerServerEvent("GiveWeapon",resourceRoot,localPlayer,guiGetText(AmmountTextbox)) 
        else 
            outputChatBox("You don't have anything in your cart!",localPlayer,255,0,0) 
        end 
    end 
    if source == QuitButton then 
        showCursor(false) 
        guiSetVisible(AmmoMenu,false)   
        guiGridListClear (Cartlist) 
        guiSetText (AmmountTextbox,"") 
    end 
    if source == AddcartButton then 
        if getElementData("weaponprice") ~= false then 
            if tonumber(guiGetText(AmmountTextbox)) > 0 and tonumber(guiGetText(AmmountTextbox)) ~= nil then 
                guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Weaponcolumn,..getWeaponNameFromID(getElementData(localPlayer,"WeaponChosen"))) 
                guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Amountcolumn,..guiGetText(AmmountTextbox)..) 
                guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Pricecolumn,"$"..tostring(math.floor(10 * guiGetText(AmmountTextbox))))             
            else 
                outputChatBox("Please enter a integer as the ammount of ammo",localPlayer,255,0,0) 
            end 
        else 
            outputChatBox("Please choose a weapon by clicking on the icon of it",localPlayer,255,0,0) 
        end 
    end 
end 
addEventHandler("onClientGUIClick",resourceRoot,chooseweapon) 
    
addEvent("showweaponGUI",true) 
function showGUI() 
    outputChatBox("true") 
    showCursor(true) 
    guiSetVisible(AmmoMenu,true) 
end 
addEventHandler("showweaponGUI",getRootElement(),showGUI) 

  
local weaponmarker = createMarker(296.42404,-38.29199,1000.5,"cylinder",1.5,0,255,0) 
setElementInterior(weaponmarker,1) 
  
function showClientGUI(marker) 
    if marker == weaponmarker then 
        if getPlayerTeam(source) and getTeamName(getPlayerTeam(source)) ~= "Criminal" then 
            triggerClientEvent(source,"showweaponGUI",source) 
        else 
            outputChatBox("Ammunation won't sell guns&ammos to criminals, buy it in black market",source,255,0,0) 
        end 
    end 
end 
addEventHandler("onPlayerMarkerHit",getRootElement(),showClientGUI) 
  
addEvent("GiveWeapon",true) 
addEventHandler("GiveWeapon",getRootElement(), 
function(buyer,quantity) 
    if getPlayerMoney(buyer) >= math.floor(quantity * 10) then 
        giveWeapon(buyer,getElementData(buyer,"WeaponChosen"),quantity) 
        takePlayerMoney(buyer,math.floor(quantity * 10)) 
    else 
        outputChatBox("You don't have enough money for this",buyer,255,0,0) 
    end 
end) 

It still got the same problem, when I walk in, nothing happens :|

Link to comment

----ServerSide

local weaponmarker = createMarker(296.42404,-38.29199,1000.5,"cylinder",1.5,0,255,0) 
setElementInterior(weaponmarker,1) 
  
function showClientGUI(marker) 
    if marker == weaponmarker then 
        if getPlayerTeam(source) and getTeamName(getPlayerTeam(source)) ~= "Criminal" then 
            triggerClientEvent(source,"showweaponGUI",source) 
        else 
            outputChatBox("Ammunation won't sell guns&ammos to criminals, buy it in black market",source,255,0,0) 
        end 
    end 
end 
addEventHandler("onPlayerMarkerHit",getRootElement(),showClientGUI) 
  
addEvent("GiveWeapon",true) 
addEventHandler("GiveWeapon",getRootElement(), 
function(buyer,quantity) 
    if getPlayerMoney(buyer) >= math.floor(quantity * 10) then 
        giveWeapon(buyer,getElementData(buyer,"WeaponChosen"),quantity) 
        takePlayerMoney(buyer,math.floor(quantity * 10)) 
    else 
        outputChatBox("You don't have enough money for this",buyer,255,0,0) 
    end 
end) 

---ClientSide

  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
local screenW, screenH = guiGetScreenSize() 
        AmmoMenu = guiCreateWindow((screenW - 465) / 2, (screenH - 834) / 2, 465, 834, "Ammu-Nation", false) 
        guiWindowSetSizable(AmmoMenu, false) 
        AmmuNationImage = guiCreateStaticImage(67, 54, 332, 88, ":weapons/ammu-nation.png", false, AmmoMenu) 
        TazerImage = guiCreateStaticImage(52, 179, 70, 56, ":weapons/Tazer.png", false, AmmoMenu) 
        PistolImage = guiCreateStaticImage(52, 253, 70, 59, ":weapons/Pistol.png", false, AmmoMenu) 
        DeserteagleImage = guiCreateStaticImage(52, 328, 70, 55, ":weapons/Desert_Eagle.png", false, AmmoMenu) 
        Ak47Image = guiCreateStaticImage(33, 739, 113, 44, ":weapons/ak47.png", false, AmmoMenu) 
        UziImage = guiCreateStaticImage(53, 401, 69, 52, ":weapons/uzi.png", false, AmmoMenu) 
        Tec9Image = guiCreateStaticImage(53, 468, 69, 50, ":weapons/tec9.png", false, AmmoMenu) 
        Mp5Image = guiCreateStaticImage(46, 532, 86, 45, ":weapons/mp5.png", false, AmmoMenu) 
        Spas12Image = guiCreateStaticImage(33, 592, 113, 50, ":weapons/Spas-12.png", false, AmmoMenu) 
        M4Image = guiCreateStaticImage(33, 663, 114, 55, ":weapons/M4A1.png", false, AmmoMenu) 
        AmmountLabel = guiCreateLabel(196, 478, 55, 17, "Ammount", false, AmmoMenu) 
        AmmountTextbox = guiCreateEdit(172, 508, 104, 24, "", false, AmmoMenu) 
        guiEditSetMaxLength(QuantityTextbox, 6) 
        BuyButton = guiCreateButton(172, 729, 126, 59, "Buy Cart", false, AmmoMenu) 
        guiSetFont(BuyButton, "default-bold-small") 
        guiSetProperty(BuyButton, "NormalTextColour", "FF0000FF") 
        QuitButton = guiCreateButton(315, 729, 126, 59, "Quit", false, AmmoMenu) 
        guiSetFont(QuitButton, "default-bold-small") 
        guiSetProperty(QuitButton, "NormalTextColour", "FFFF0000") 
        Cartlist = guiCreateGridList(172, 551, 269, 122, false, AmmoMenu) 
        Weaponcolumn = guiGridListAddColumn(Cartlist, "Weapon", 0.3) 
        Amountcolumn = guiGridListAddColumn(Cartlist, "Amount", 0.3) 
        Pricecolumn = guiGridListAddColumn(Cartlist, "Price", 0.3) 
        AddcartButton = guiCreateButton(314, 508, 89, 27, "Add to cart", false, AmmoMenu) 
        WeaponInfo = guiCreateScrollPane(177, 179, 223, 238, false, AmmoMenu)     
        Infolabel = guiCreateLabel(17, 150, 150, 19, "Press icon for information", false, AmmoMenu) 
        guiSetFont(Infolabel, "default-bold-small") 
        guiGridListSetSortingEnabled (Cartlist,false) 
        guiSetVisible(AmmoMenu,false) 
    end 
) 
  
  
  
  
function chooseweapon() 
    if source == TazerImage then 
        setElementData(localPlayer,"WeaponChosen",23) 
    end 
    if source == PistolImage then 
        setElementData(localPlayer,"WeaponChosen",22) 
    end 
    if source == DeserteagleImage then 
        setElementData(localPlayer,"WeaponChosen",24) 
    end 
    if source == Ak47Image then 
        setElementData(localPlayer,"WeaponChosen",30) 
    end 
    if source == UziImage then 
        setElementData(localPlayer,"WeaponChosen",28) 
    end 
    if source == Tec9Image then 
        setElementData(localPlayer,"WeaponChosen",32) 
    end 
    if source == Mp5Image then 
        setElementData(localPlayer,"WeaponChosen",29) 
    end 
    if source == Spas12Image then 
        setElementData(localPlayer,"WeaponChosen",27) 
    end 
    if source == M4Image then 
        setElementData(localPlayer,"WeaponChosen",31) 
    end 
    if source == BuyButton then 
        if guiGridListGetRowCount(Cartlist) > 0 then 
            triggerServerEvent("GiveWeapon",resourceRoot,localPlayer,guiGetText(AmmountTextbox)) 
        else 
            outputChatBox("You don't have anything in your cart!",localPlayer,255,0,0) 
        end 
    end 
    if source == QuitButton then 
        showCursor(false) 
        guiSetVisible(AmmoMenu,false)   
        guiGridListClear (Cartlist) 
        guiSetText (AmmountTextbox,"") 
    end 
    if source == AddcartButton then 
        if getElementData("weaponprice") ~= false then 
        if tonumber(guiGetText(AmmountTextbox)) > 0 and tonumber(guiGetText(AmmountTextbox)) ~= nil then 
        guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Weaponcolumn ..getWeaponNameFromID(getElementData(localPlayer,"WeaponChosen"))) 
        guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Amountcolumn ..guiGetText(AmmountTextbox)) 
                guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Pricecolumn,"$"..tostring(math.floor(10 * guiGetText(AmmountTextbox))))             
            else 
                outputChatBox("Please enter a integer as the ammount of ammo",localPlayer,255,0,0) 
            end 
        else 
            outputChatBox("Please choose a weapon by clicking on the icon of it",localPlayer,255,0,0) 
        end 
    end 
end 
addEventHandler("onClientGUIClick",resourceRoot,chooseweapon) 
    
addEvent("showweaponGUI",true) 
function showGUI() 
    outputChatBox("true") 
    showCursor(true) 
    guiSetVisible(AmmoMenu,true) 
end 
addEventHandler("showweaponGUI",getRootElement(),showGUI) 
Link to comment
----ServerSide

local weaponmarker = createMarker(296.42404,-38.29199,1000.5,"cylinder",1.5,0,255,0) 
setElementInterior(weaponmarker,1) 
  
function showClientGUI(marker) 
    if marker == weaponmarker then 
        if getPlayerTeam(source) and getTeamName(getPlayerTeam(source)) ~= "Criminal" then 
            triggerClientEvent(source,"showweaponGUI",source) 
        else 
            outputChatBox("Ammunation won't sell guns&ammos to criminals, buy it in black market",source,255,0,0) 
        end 
    end 
end 
addEventHandler("onPlayerMarkerHit",getRootElement(),showClientGUI) 
  
addEvent("GiveWeapon",true) 
addEventHandler("GiveWeapon",getRootElement(), 
function(buyer,quantity) 
    if getPlayerMoney(buyer) >= math.floor(quantity * 10) then 
        giveWeapon(buyer,getElementData(buyer,"WeaponChosen"),quantity) 
        takePlayerMoney(buyer,math.floor(quantity * 10)) 
    else 
        outputChatBox("You don't have enough money for this",buyer,255,0,0) 
    end 
end) 

---ClientSide

  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
local screenW, screenH = guiGetScreenSize() 
        AmmoMenu = guiCreateWindow((screenW - 465) / 2, (screenH - 834) / 2, 465, 834, "Ammu-Nation", false) 
        guiWindowSetSizable(AmmoMenu, false) 
        AmmuNationImage = guiCreateStaticImage(67, 54, 332, 88, ":weapons/ammu-nation.png", false, AmmoMenu) 
        TazerImage = guiCreateStaticImage(52, 179, 70, 56, ":weapons/Tazer.png", false, AmmoMenu) 
        PistolImage = guiCreateStaticImage(52, 253, 70, 59, ":weapons/Pistol.png", false, AmmoMenu) 
        DeserteagleImage = guiCreateStaticImage(52, 328, 70, 55, ":weapons/Desert_Eagle.png", false, AmmoMenu) 
        Ak47Image = guiCreateStaticImage(33, 739, 113, 44, ":weapons/ak47.png", false, AmmoMenu) 
        UziImage = guiCreateStaticImage(53, 401, 69, 52, ":weapons/uzi.png", false, AmmoMenu) 
        Tec9Image = guiCreateStaticImage(53, 468, 69, 50, ":weapons/tec9.png", false, AmmoMenu) 
        Mp5Image = guiCreateStaticImage(46, 532, 86, 45, ":weapons/mp5.png", false, AmmoMenu) 
        Spas12Image = guiCreateStaticImage(33, 592, 113, 50, ":weapons/Spas-12.png", false, AmmoMenu) 
        M4Image = guiCreateStaticImage(33, 663, 114, 55, ":weapons/M4A1.png", false, AmmoMenu) 
        AmmountLabel = guiCreateLabel(196, 478, 55, 17, "Ammount", false, AmmoMenu) 
        AmmountTextbox = guiCreateEdit(172, 508, 104, 24, "", false, AmmoMenu) 
        guiEditSetMaxLength(QuantityTextbox, 6) 
        BuyButton = guiCreateButton(172, 729, 126, 59, "Buy Cart", false, AmmoMenu) 
        guiSetFont(BuyButton, "default-bold-small") 
        guiSetProperty(BuyButton, "NormalTextColour", "FF0000FF") 
        QuitButton = guiCreateButton(315, 729, 126, 59, "Quit", false, AmmoMenu) 
        guiSetFont(QuitButton, "default-bold-small") 
        guiSetProperty(QuitButton, "NormalTextColour", "FFFF0000") 
        Cartlist = guiCreateGridList(172, 551, 269, 122, false, AmmoMenu) 
        Weaponcolumn = guiGridListAddColumn(Cartlist, "Weapon", 0.3) 
        Amountcolumn = guiGridListAddColumn(Cartlist, "Amount", 0.3) 
        Pricecolumn = guiGridListAddColumn(Cartlist, "Price", 0.3) 
        AddcartButton = guiCreateButton(314, 508, 89, 27, "Add to cart", false, AmmoMenu) 
        WeaponInfo = guiCreateScrollPane(177, 179, 223, 238, false, AmmoMenu)     
        Infolabel = guiCreateLabel(17, 150, 150, 19, "Press icon for information", false, AmmoMenu) 
        guiSetFont(Infolabel, "default-bold-small") 
        guiGridListSetSortingEnabled (Cartlist,false) 
        guiSetVisible(AmmoMenu,false) 
    end 
) 
  
  
  
  
function chooseweapon() 
    if source == TazerImage then 
        setElementData(localPlayer,"WeaponChosen",23) 
    end 
    if source == PistolImage then 
        setElementData(localPlayer,"WeaponChosen",22) 
    end 
    if source == DeserteagleImage then 
        setElementData(localPlayer,"WeaponChosen",24) 
    end 
    if source == Ak47Image then 
        setElementData(localPlayer,"WeaponChosen",30) 
    end 
    if source == UziImage then 
        setElementData(localPlayer,"WeaponChosen",28) 
    end 
    if source == Tec9Image then 
        setElementData(localPlayer,"WeaponChosen",32) 
    end 
    if source == Mp5Image then 
        setElementData(localPlayer,"WeaponChosen",29) 
    end 
    if source == Spas12Image then 
        setElementData(localPlayer,"WeaponChosen",27) 
    end 
    if source == M4Image then 
        setElementData(localPlayer,"WeaponChosen",31) 
    end 
    if source == BuyButton then 
        if guiGridListGetRowCount(Cartlist) > 0 then 
            triggerServerEvent("GiveWeapon",resourceRoot,localPlayer,guiGetText(AmmountTextbox)) 
        else 
            outputChatBox("You don't have anything in your cart!",localPlayer,255,0,0) 
        end 
    end 
    if source == QuitButton then 
        showCursor(false) 
        guiSetVisible(AmmoMenu,false)   
        guiGridListClear (Cartlist) 
        guiSetText (AmmountTextbox,"") 
    end 
    if source == AddcartButton then 
        if getElementData("weaponprice") ~= false then 
        if tonumber(guiGetText(AmmountTextbox)) > 0 and tonumber(guiGetText(AmmountTextbox)) ~= nil then 
        guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Weaponcolumn ..getWeaponNameFromID(getElementData(localPlayer,"WeaponChosen"))) 
        guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Amountcolumn ..guiGetText(AmmountTextbox)) 
                guiGridListSetItemText(Cartlist,guiGridListAddRow(Cartlist),Pricecolumn,"$"..tostring(math.floor(10 * guiGetText(AmmountTextbox))))             
            else 
                outputChatBox("Please enter a integer as the ammount of ammo",localPlayer,255,0,0) 
            end 
        else 
            outputChatBox("Please choose a weapon by clicking on the icon of it",localPlayer,255,0,0) 
        end 
    end 
end 
addEventHandler("onClientGUIClick",resourceRoot,chooseweapon) 
    
addEvent("showweaponGUI",true) 
function showGUI() 
    outputChatBox("true") 
    showCursor(true) 
    guiSetVisible(AmmoMenu,true) 
end 
addEventHandler("showweaponGUI",getRootElement(),showGUI) 

Ty problem solved :)

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