Jump to content

Ayuda con Weapon shop


NodZen

Recommended Posts

Amigos , encontre en la comunidad un script para comprar armas. Bueno el tema es que el script tiene una "licencia" osea , tenes que comprar en el juego la licencia que sale $55.000. Pero a la hora de intentar sacar eso el script deja de funcionar

client

function CreateShopWindow() 
    ShopWindow = guiCreateWindow(350,250,450,320,"Ammunation",false) 
    guiCreateLabel(35,35,250,60,"To buy weapons u need a license:$55.000",false,ShopWindow) 
    btn_buy_license = guiCreateButton(270,33,135,20,"License for Weapons",false,ShopWindow) 
  
        -- Below, not original price. It's just strings to the buttons. If you must change the weapon price, go to server-side script. 
        -- Abaixo, as variáveis não são o preço real das armas. É apenas as strings para serem escritas nos botões. Se quer mudar o preço, mude no arquivo server-side. 
        local price_porrete     = "2.500" 
        local price_m4          = "2.500" 
        local price_ak          = "2.500" 
        local price_tec9        = "2.500" 
        local price_mp5         = "2.500" 
        local price_knife       = "2.500" 
        local price_uzi         = "2.500" 
        local price_sniper      = "2.500" 
        local price_shotgun     = "2.500" 
        local price_spaz12      = "2.500" 
        local price_pistol      = "2.500" 
        local price_teargas     = "2.500" 
        local price_rifle       = "2.500" 
        local price_satchel     = "2.500" 
        local price_grenade     = "2.500" 
  
        btn_buy_porrete   = guiCreateButton(29,140,60,15,price_porrete,false,ShopWindow) 
        btn_buy_m4        = guiCreateButton(109,140,60,15,price_m4,false,ShopWindow) 
        btn_buy_ak        = guiCreateButton(189,140,60,15,price_ak,false,ShopWindow) 
        btn_buy_tec9      = guiCreateButton(269,140,60,15,price_tec9,false,ShopWindow) 
        btn_buy_mp5       = guiCreateButton(349,140,60,15,price_mp5,false,ShopWindow) 
        btn_buy_knife     = guiCreateButton(29,220,60,15,price_knife,false,ShopWindow) 
        btn_buy_uzi       = guiCreateButton(109,220,60,15,price_uzi,false,ShopWindow) 
        btn_buy_sniper    = guiCreateButton(189,220,60,15,price_sniper,false,ShopWindow) 
        btn_buy_shotgun   = guiCreateButton(269,220,60,15,price_shotgun,false,ShopWindow) 
        btn_buy_spaz12    = guiCreateButton(349,220,60,15,price_spaz12,false,ShopWindow) 
        btn_buy_pistol    = guiCreateButton(29,295,60,15,price_pistol,false,ShopWindow) 
        btn_buy_teargas   = guiCreateButton(109,295,60,15,price_teargas,false,ShopWindow) 
        btn_buy_rifle     = guiCreateButton(189,295,60,15,price_rifle,false,ShopWindow) 
        btn_buy_satchel   = guiCreateButton(269,295,60,15,price_satchel,false,ShopWindow) 
        btn_buy_grenade   = guiCreateButton(349,295,60,15,price_grenade,false,ShopWindow) 
         
        addEventHandler("onClientGUIClick", btn_buy_porrete, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_m4, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_ak, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_tec9, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_mp5, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_knife, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_uzi, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_sniper, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_shotgun, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_spaz12, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_pistol, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_teargas, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_rifle, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_satchel, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_grenade, BuyWeapon) 
        addEventHandler("onClientGUIClick", btn_buy_license, BuyLicense) 
         
        guiCreateMemo(25,60,405,15,"                                                         ",false,ShopWindow) 
        guiCreateStaticImage(30,80,60,60,"imagens/3.png", false,ShopWindow ) 
        guiCreateStaticImage(110,80,60,60,"imagens/31.png", false,ShopWindow ) 
        guiCreateStaticImage(190,80,60,60,"imagens/30.png", false,ShopWindow ) 
        guiCreateStaticImage(270,80,60,60,"imagens/32.png", false,ShopWindow ) 
        guiCreateStaticImage(350,80,60,60,"imagens/33.png", false,ShopWindow ) 
        guiCreateStaticImage(30,160,60,60,"imagens/1.png", false,ShopWindow ) 
        guiCreateStaticImage(110,160,60,60,"imagens/20.png", false,ShopWindow ) 
        guiCreateStaticImage(270,160,60,60,"imagens/27.png", false,ShopWindow ) 
        guiCreateStaticImage(350,160,60,60,"imagens/28.png", false,ShopWindow ) 
        guiCreateStaticImage(190,160,60,60,"imagens/29.png", false,ShopWindow ) 
        guiCreateStaticImage(30,240,60,60,"imagens/2.png", false,ShopWindow ) 
        guiCreateStaticImage(110,240,60,60,"imagens/26.png", false,ShopWindow ) 
        guiCreateStaticImage(190,240,60,60,"imagens/25.png", false,ShopWindow ) 
        guiCreateStaticImage(270,240,60,60,"imagens/4.png", false,ShopWindow ) 
        guiCreateStaticImage(350,240,60,60,"imagens/5.png", false,ShopWindow ) 
  
    guiWindowSetSizable(ShopWindow,false) 
    guiSetVisible(ShopWindow,false) 
end 
addEventHandler("onClientResourceStart", getRootElement(), CreateShopWindow) 
  
  
  
  
function BuyWeapon(button, state) 
  
    if (button == "left") then 
     
        if(source == btn_buy_porrete) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_porrete") 
        elseif(source == btn_buy_m4) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_m4")    
        elseif(source == btn_buy_ak) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_ak") 
        elseif(source == btn_buy_tec9) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_tec9") 
        elseif(source == btn_buy_mp5) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_mp5") 
        elseif(source == btn_buy_knife) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_knife") 
        elseif(source == btn_buy_uzi) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_uzi") 
        elseif(source == btn_buy_sniper) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_sniper") 
        elseif(source == btn_buy_shotgun) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_shotgun") 
        elseif(source == btn_buy_spaz12) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_spaz12") 
        elseif(source == btn_buy_pistol) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_pistol") 
        elseif(source == btn_buy_teargas) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_teargas") 
        elseif(source == btn_buy_rifle) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_rifle") 
        elseif(source == btn_buy_satchel) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_satchel") 
        elseif(source == btn_buy_grenade) then 
            triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_grenade")   
        end 
     
    end 
end 
  
  
function BuyLicense(button) 
  
    if(button == "left" and source == btn_buy_license) then 
        triggerServerEvent("onClientBuyLicense", localPlayer) 
    end 
  
end 
  
  
function ShowGUI ( ) 
    guiSetVisible ( ShopWindow, not guiGetVisible ( ShopWindow ) ) 
    showCursor ( not isCursorShowing( ) ) 
end 
bindKey ( "F7","down", ShowGUI ) 

server

function BuyWeaponOnServer(weapon_name) 
  
    player_money      = getPlayerMoney(source) 
    player_account    = getPlayerAccount(source) 
  
    local price_porrete     = "2500" 
    local price_m4          = "2500" 
    local price_ak          = "2500" 
    local price_tec9        = "2500" 
    local price_mp5         = "2500" 
    local price_knife       = "2500" 
    local price_uzi         = "2500" 
    local price_sniper      = "2500" 
    local price_shotgun     = "2500" 
    local price_spaz12      = "2500" 
    local price_pistol      = "2500" 
    local price_teargas     = "2500" 
    local price_rifle       = "2500" 
    local price_satchel     = "2500" 
    local price_grenade     = "2500" 
     
    if(getAccountData(player_account, "GunLicense") == true) then 
     
        if(weapon_name == "weapon_porrete") then 
            if(player_money >= tonumber(price_porrete)) then 
                giveWeapon(source, 3) 
                takePlayerMoney(source, tonumber(price_porrete)) 
                outputChatBox("You bought a Nightstick.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy a Nightstick.", source, 255, 0, 0) 
            end 
  
        elseif(weapon_name == "weapon_m4") then 
            if(player_money >= tonumber(price_m4)) then 
                giveWeapon(source, 31, 100) 
                takePlayerMoney(source, tonumber(price_m4)) 
                outputChatBox("You bought an M4.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy an M4.", source, 255, 0, 0) 
            end 
         
        elseif(weapon_name == "weapon_ak") then 
            if(player_money >= tonumber(price_ak)) then 
                giveWeapon(source, 30, 100) 
                takePlayerMoney(source, tonumber(price_ak)) 
                outputChatBox("You bought an AK-47.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy an AK-47.", source, 255, 0, 0) 
            end 
             
        elseif(weapon_name == "weapon_tec9") then 
            if(player_money >= tonumber(price_tec9)) then 
                giveWeapon(source, 32, 100) 
                takePlayerMoney(source, tonumber(price_tec9)) 
                outputChatBox("You bought a TEC-9.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy a TEC-9.", source, 255, 0, 0) 
            end 
             
        elseif(weapon_name == "weapon_mp5") then 
            if(player_money >= tonumber(price_mp5)) then 
                giveWeapon(source, 29, 100) 
                takePlayerMoney(source, tonumber(price_mp5)) 
                outputChatBox("You bought an MP5.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy an MP5.", source, 255, 0, 0) 
            end 
             
        elseif(weapon_name == "weapon_knife") then 
            if(player_money >= tonumber(price_knife)) then 
                giveWeapon(source, 4) 
                takePlayerMoney(source, tonumber(price_knife)) 
                outputChatBox("You bought a knife.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy a knife.", source, 255, 0, 0) 
            end 
             
        elseif(weapon_name == "weapon_uzi") then 
            if(player_money >= tonumber(price_uzi)) then 
                giveWeapon(source, 28, 100) 
                takePlayerMoney(source, tonumber(price_uzi)) 
                outputChatBox("You bought an UZI.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy an UZI.", source, 255, 0, 0) 
            end 
             
        elseif(weapon_name == "weapon_sniper") then 
            if(player_money >= tonumber(price_sniper)) then 
                giveWeapon(source, 34, 100) 
                takePlayerMoney(source, tonumber(price_sniper)) 
                outputChatBox("You bought a Sniper.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy a Sniper.", source, 255, 0, 0) 
            end 
             
        elseif(weapon_name == "weapon_shotgun") then 
            if(player_money >= tonumber(price_shotgun)) then 
                giveWeapon(source, 25, 100) 
                takePlayerMoney(source, tonumber(price_shotgun)) 
                outputChatBox("You bought a Shotgun.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy a Shotgun.", source, 255, 0, 0) 
            end 
             
        elseif(weapon_name == "weapon_spaz12") then 
            if(player_money >= tonumber(price_spaz12)) then 
                giveWeapon(source, 27, 100) 
                takePlayerMoney(source, tonumber(price_spaz12)) 
                outputChatBox("You bought a SPAZ-12.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy a SPAZ-12.", source, 255, 0, 0) 
            end 
             
        elseif(weapon_name == "weapon_pistol") then 
            if(player_money >= tonumber(price_pistol)) then 
                giveWeapon(source, 22, 100) 
                takePlayerMoney(source, tonumber(price_pistol)) 
                outputChatBox("You bought a Pistol.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy a Pistol.", source, 255, 0, 0) 
            end 
             
        elseif(weapon_name == "weapon_teargas") then 
            if(player_money >= tonumber(price_teargas)) then 
                giveWeapon(source, 17, 1) 
                takePlayerMoney(source, tonumber(price_teargas)) 
                outputChatBox("You bought a teargas", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy a teargas.", source, 255, 0, 0) 
            end 
             
        elseif(weapon_name == "weapon_rifle") then 
            if(player_money >= tonumber(price_rifle)) then 
                giveWeapon(source, 33, 100) 
                takePlayerMoney(source, tonumber(price_rifle)) 
                outputChatBox("You bought a Rifle.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy a Rifle.", source, 255, 0, 0) 
            end 
             
        elseif(weapon_name == "weapon_satchel") then 
            if(player_money >= tonumber(price_satchel)) then 
                giveWeapon(source, 39, 1) 
                takePlayerMoney(source, tonumber(price_satchel)) 
                outputChatBox("You bought a Satchel Charges.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy a Satchel Charges.", source, 255, 0, 0) 
            end 
             
        elseif(weapon_name == "weapon_grenade") then 
            if(player_money >= tonumber(price_grenade)) then 
                giveWeapon(source, 16, 1) 
                takePlayerMoney(source, tonumber(price_grenade)) 
                outputChatBox("You bought a grenade.", source, 0, 255, 0) 
            else 
                outputChatBox("You do not have enough money to buy a grenade.", source, 255, 0, 0) 
            end 
             
             
        end 
         
    else 
        outputChatBox("You dont have a license to bear arms.", source, 255, 0, 0) 
    end 
  
end 
addEvent("onClientBuyWeapon", true) 
addEventHandler("onClientBuyWeapon", getRootElement(), BuyWeaponOnServer) 
  
  
  
function BuyWeaponLicense() 
     
    player_money = getPlayerMoney(source) 
    player_account = getPlayerAccount(source) 
     
    local license_price = "55000" 
     
    if(getAccountData(player_account, "GunLicense") == false) then 
        if(player_money >= tonumber(license_price)) then 
            setAccountData(player_account, "GunLicense", true) 
            takePlayerMoney(source, tonumber(license_price)) 
            outputChatBox("You now have a license to bear arms.", source, 0, 255, 0) 
        else 
            outputChatBox("You do not have enough money to buy a license to bear arms.", source, 255, 0, 0) 
        end 
    else 
        outputChatBox("You already have a license to bear arms.", source, 255, 0, 0) 
    end 
     
end 
addEvent("onClientBuyLicense", true) 
addEventHandler("onClientBuyLicense", getRootElement(), BuyWeaponLicense) 

que lineas debo borrar?

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...