Jump to content

Shop


Recommended Posts

Hey i have this Script Which allow me to buy Hydra or Hunter or WeaponsSkills

but i have problem that i can't make F6 Bind For it

Server Side

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 ("#006400You Bought A : #FFFFFF" .. name, source, 255, 255, 255, true) 
    outputChatBox ("#006400ID: #FFFFFF" .. id, source, 255, 255, 255, true) 
    outputChatBox ("#006400Costs #FFFFFF" .. cost, source, 255, 255, 255, true) 
    takePlayerMoney (source, tonumber (cost)) 
    giveWeapon(source, tonumber(id),1000) 
  else 
    outputChatBox ("#006400You Don't Have Enough #FFFFFFMoney", source, 255, 255, 255, true) 
  end 
end) 
  
addEvent ("carBuy", true) 
addEventHandler ("carBuy", getRootElement(),  
function(id2, cost2, name2,x, y, z, sRz) 
  if (getPlayerMoney (source) >= tonumber(cost2)) then 
    outputChatBox ("#006400You Bought A : #FFFFFF" .. name2, source, 255, 255, 255, true) 
    outputChatBox ("#006400ID: #FFFFFF" .. id2, source, 255, 255, 255, true) 
    outputChatBox ("#006400Costs: #FFFFFF" .. cost2, source, 255, 0, 0, true) 
    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 ("#006400You Don't Have Enough #FFFFFFMoney", source, 255, 255, 255, true) 
  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 (50000,source,70) 
    elseif (id == "2") then 
    skillBuyPlayer (50000,source,71) 
    elseif (id == "3") then 
    skillBuyPlayer (50000,source,72) 
    elseif (id == "4") then 
    skillBuyPlayer (50000,source,73) 
    elseif (id == "5") then 
    skillBuyPlayer (50000,source,74) 
    elseif (id == "6") then 
    skillBuyPlayer (50000,source,75) 
    elseif (id == "7") then 
    skillBuyPlayer (50000,source,76) 
    elseif (id == "8") then 
    skillBuyPlayer (50000,source,77)     
    elseif (id == "9") then 
    skillBuyPlayer (50000,source,78) 
    elseif (id == "10") then 
    skillBuyPlayer (50000,source,79) 
elseif (id == "11") then 
    skillBuyPlayer (50000,source,24) 
    elseif (id == "12") then 
    skillBuyPlayer (50000,source,23) 
    elseif (id == "13") then 
    skillBuyPlayer (50000,source,21) 
  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, 1000) 
    else outputChatBox ("#006400You Don't Have Enough #FFFFFFMoney", 255, 255, 255, true) 
  end 
end 

i tried this bind but not working

bindKey("F6", "down", showGui) 

Link to comment

like that ? there is bug -_-

addEventHandler("onResourceStart",resourceRoot, 
function(resource) 
local players = getElementsByType("player") 
for i,player in ipairs(players) do 
bindKey(player,"F4","down",showGui) 
end 
end) 
  
addEventHandler("onPlayerJoin",root, 
function() 
bindKey(source,"F4","down",showGui) 
end) 

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