Jump to content

Need help changing command in bindkey?


Admigo

Recommended Posts

Heey guys,

I use solids shop resource and i want to change the command /shop to a f1 key so if you press f1 the shop opens and if the shop is open and you press again the shop close.

Server:

addEvent ("viewGUI", true) 
function showGui (hitPlayer, matchingDimension) 
    triggerClientEvent ("viewGUI", hitPlayer) 
end 
addCommandHandler("shop",showGui) 
  
addEvent ("weapBuy", true) 
addEventHandler ("weapBuy", getRootElement(),  
function(id, cost, name, ammo) 
  if (getPlayerMoney (source) >= tonumber(cost)) then 
    outputChatBox ("You Bought a " .. name, source, 255, 0, 0, false) 
    outputChatBox ("ID: " .. id, source, 255, 0, 0, false) 
    outputChatBox ("Cost: " .. cost, source, 255, 0, 0, false) 
    takePlayerMoney (source, tonumber (cost)) 
    giveWeapon(source, tonumber(id),1000) 
  else 
    outputChatBox ("You are too poor!", source, 255, 0, 0, false) 
  end 
end) 
  
addEvent ("carBuy", true) 
addEventHandler ("carBuy", getRootElement(),  
function(id2, cost2, name2,x, y, z, sRz) 
  if (getPlayerMoney (source) >= tonumber(cost2)) then 
    outputChatBox ("Bought a " .. name2, source, 255, 0, 0, false) 
    outputChatBox ("ID: " .. id2, source, 255, 0, 0, false) 
    outputChatBox ("Cost: " .. cost2, source, 255, 0, 0, false) 
    takePlayerMoney (source, tonumber (cost2)) 
    local x,y,z = getElementPosition (source) 
    local vehicle = createVehicle (id2, x, y, z, 0, 0, sRz ) 
    warpPedIntoVehicle(source, vehicle) 
  else 
    outputChatBox ("You are too poor!", source, 255, 0, 0, false) 
  end 
end) 
  
  
function vExplode () 
        toggleVehicleRespawn ( source, false ) 
        setTimer(destroyElement, 5000, 1, source) 
end 
addEventHandler ( "onVehicleExplode", getResourceRootElement(getThisResource()), vExplode ) 
  
function skillButton (id, cost) 
  if (id == "0") then 
    skillBuyPlayer (250,source,69) 
    elseif (id == "1") then 
    skillBuyPlayer (2000,source,70) 
    elseif (id == "2") then 
    skillBuyPlayer (500,source,71) 
    elseif (id == "3") then 
    skillBuyPlayer (5800,source,72) 
    elseif (id == "4") then 
    skillBuyPlayer (11000,source,73) 
    elseif (id == "5") then 
    skillBuyPlayer (7500,source,74) 
    elseif (id == "6") then 
    skillBuyPlayer (5500,source,75) 
    elseif (id == "7") then 
    skillBuyPlayer (7000,source,76) 
    elseif (id == "8") then 
    skillBuyPlayer (8000,source,77)  
    elseif (id == "9") then 
    skillBuyPlayer (10000,source,78) 
    elseif (id == "10") then 
    skillBuyPlayer (10000,source,79)     
  end 
end 
addEvent ("skillBuy", true) 
addEventHandler ("skillBuy", getRootElement(),skillButton) 
  
function skillBuyPlayer (cash,player,id) 
    if (getPlayerMoney (player) >= cash) then 
      takePlayerMoney (player,cash) 
      setPedStat(player, id, 999) 
    else outputChatBox ("You are too poor!", player, 255,0,0) 
  end 
end 

Pls help.

Thanks Admigo

Link to comment

Does /shop toggle the GUI on and off? If so, try adding this to then end of your server-side script:

function guiBind() 
     bindKey(source, "F1", "down", "shop") 
end 
addEventHandler("onPlayerJoin", getRootElement(), guiBind) 

Note: you'll still be able to use /shop to open/close the GUI

Link to comment

just add this in client-side

function ToggleShop() 
    if guiGetVisible(shopWindow) == true then 
        guiSetVisible(shopWindow,false) 
        showCursor(false) 
    else 
        guiSetVisible(shopWindow,true) 
        showCursor(true) 
    end 
end 
bindKey("F1","down",ToggleShop) 

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