Jump to content

Buy Menu


Anubhav

Recommended Posts

  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        E = guiCreateWindow(421, 269, 572, 475, "Buy Menu By Anubhav", false) 
  
        button[1] = guiCreateButton(62, 163, 169, 93, "Buy M4", false, E) 
function buyweapon (player) 
            if getPlayerMoney(player) >= 5000 then 
        takePlayerMoney ( player, 5000 ) 
            outputChatBox ( "#00FF00You Bought  A M4.!",player, 255, 255, 255, true ) 
        giveWeapon ( player, 31, 300 ) 
      else 
                outputChatBox ( "#00FF00You Don't Have Enough Money!",player, 255, 255, 255, true ) 
            end 
    end 
addCommandHandler ( "buym4", buyweapon ) 
      
    end 
) 
bindKey ( "F6","down", showGUI ) 
  

Problem is bind key is not working.

Link to comment

The script is weird from the start. You have it configured so when the resource starts, the GUI automatically launches.

The real reason your bind isn't working is because it isn't tied to a command handler.

Edited by Guest
Link to comment

This actually totally wrong and make no sense.

The script is weird from the start. You have it configured so when the resource starts, the GUI automatically launches.

The real reason your bind isn't working is because it isn't tied to a command handler.

        window = guiCreateWindow(421, 269, 572, 475, "Buy Menu By Anubhav", false) 
        guiSetVisible(window, false) 
        buybutton = guiCreateButton(62, 163, 169, 93, "Buy M4", false, window) 
function buyweapon (player) 
            if getPlayerMoney(player) >= 5000 then 
        takePlayerMoney ( player, 5000 ) 
            outputChatBox ( "#00FF00You Bought  A M4.!", player, 255, 255, 255, true ) 
        giveWeapon ( player, 31, 300 ) 
      else 
                outputChatBox ( "#00FF00You Don't Have Enough Money!", player, 255, 255, 255, true ) 
         end 
    end 
addCommandHandler ( "buym4", buyweapon ) 
function openGUI() 
    guiSetVisible(window, true) 
    showCursor(true) 
end 
addCommandHandler("cmdname", openGUI) 
bindKey ("F6", "both", "cmdname") 
addEventHandler("onClientGUIClick", buybutton, buyweapon, false) 

Tested and working

Where did you test it? on the moon? or maybe mars.

Link to comment
  • 3 weeks later...

Client:

        E = guiCreateWindow(421, 269, 572, 475, "Buy Menu By Anubhav", false) 
        guiSetVisible(E, false) 
        button1 = guiCreateButton(62, 163, 169, 93, "Buy M4", false, E)  
         
function showGUI() 
    guiSetVisible(E, true) 
    showCursor(true) 
end 
 bindKey ( "F6","down", showGUI ) 
  
function buyWeaponOnButtonClick() 
        triggerServerEvent("buym4", thePlayer, thePlayer) 
end 
addEventHandler("onClientGUIClick", button1, buyWeaponOnButtonClick) 

Server:

function buyweapon (thePlayer) 
            if getPlayerMoney(thePlayer) >= 5000 then 
            takePlayerMoney ( thePlayer, 5000 ) 
            outputChatBox ( "#00FF00You Bought  A M4.!",thePlayer, 255, 255, 255, true ) 
            giveWeapon ( thePlayer, 31, 300 ) 
            else 
            outputChatBox ( "#00FF00You Don't Have Enough Money!",thePlayer, 255, 255, 255, true ) 
            end 
end 
addCommandHandler ( "buym4", buyweapon ) 
addEvent("buym4", true) 
addEventHandler("buym4", root, buyweapon) 

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