Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- button1 = guiCreateButton( 0.01, 0.01, 0.2, 0.1, price_colt,"Colt", false, tab1 )
- button2 = guiCreateButton( 0.01, 0.12, 0.2, 0.1, price_silencer, "Silencer", false, tab1 )
- button3 = guiCreateButton( 0.01, 0.23, 0.2, 0.1, price_deagle,"Deagle", false, tab1 )
- button4 = guiCreateButton( 0.01, 0.34, 0.2, 0.1, price_sawn,"Sawn off", false, tab1 )
- button5 = guiCreateButton( 0.01, 0.45, 0.2, 0.1, price_shotgun,"Shotgun", false, tab1 )
- button6 = guiCreateButton( 0.01, 0.56, 0.2, 0.1, price_spaz12,"Spaz 12", false, tab1 )
- button7 = guiCreateButton( 0.01, 0.67, 0.2, 0.1, price_mp5,"MP5", false, tab1 )
- button8 = guiCreateButton( 0.01, 0.78, 0.2, 0.1, price_tec9,"Tec 9", false, tab1 )
- button9 = guiCreateButton( 0.25, 0.01, 0.2, 0.1, price_uzi,"Uzi", false, tab1 )
- button10 = guiCreateButton( 0.25, 0.12, 0.2, 0.1, price_ak,"AK-47", false, tab1 )
- button11 = guiCreateButton( 0.25, 0.23, 0.2, 0.1, price_m4,"M4", false, tab1 )
- button12 = guiCreateButton( 0.25, 0.34, 0.2, 0.1, price_cs,"Country Sniper", false, tab1 )
- button13 = guiCreateButton( 0.25, 0.45, 0.2, 0.1, price_sniper,"Sniper", false, tab1 )
- button14 = guiCreateButton( 0.25, 0.56, 0.2, 0.1, price_ft,"Flame Thrower", false, tab1 )
- button15 = guiCreateButton( 0.25, 0.67, 0.2, 0.1, price_hsrpg,"HS RPG", false, tab1 )
- button16 = guiCreateButton( 0.25, 0.78, 0.2, 0.1, price_minigun,"Minigun", false, tab1 )
- button17 = guiCreateButton( 0.50, 0.01, 0.2, 0.1, price_rpg,"RPG", false, tab1 )
- button18 = guiCreateButton( 0.50, 0.12, 0.2, 0.1, price_grenade,"Grenade", false, tab1 )
- button19 = guiCreateButton( 0.50, 0.23, 0.2, 0.1, price_motolov,"Motolov", false, tab1 )
- button20 = guiCreateButton( 0.50, 0.34, 0.2, 0.1, price_satchel,"Satchel", false, tab1 )
- button21 = guiCreateButton( 0.50, 0.45, 0.2, 0.1, price_teargas,"Tear gas", false, tab1 )
- button22 = guiCreateButton( 0.50, 0.56, 0.2, 0.1, price_fire,"Fire Extinguiser", false, tab1 )
- button23 = guiCreateButton( 0.50, 0.67, 0.2, 0.1, price_parachute,"Parachute", false, tab1 )
- button24 = guiCreateButton( 0.50, 0.78, 0.2, 0.1, price_baseball,"Baseball bat", false, tab1 )
- button25 = guiCreateButton( 0.75, 0.01, 0.2, 0.1, price_cane,"Cane", false, tab1 )
- button26 = guiCreateButton( 0.75, 0.12, 0.2, 0.1, price_chainsaw,"Chainsaw", false, tab1 )
- button27 = guiCreateButton( 0.75, 0.23, 0.2, 0.1, price_golf,"Golf club", false, tab1 )
- button28 = guiCreateButton( 0.75, 0.34, 0.2, 0.1, price_pool,"Pool cue", false, tab1 )
- button29 = guiCreateButton( 0.75, 0.45, 0.2, 0.1, price_katana,"Katana", false, tab1 )
- button30 = guiCreateButton( 0.75, 0.56, 0.2, 0.1, price_knife,"Knife", false, tab1 )
- button31 = guiCreateButton( 0.75, 0.67, 0.2, 0.1, price_nightstick,"Nightstick", false, tab1 )
- button32 = guiCreateButton( 0.75, 0.78, 0.2, 0.1, price_shovel,"Shovel", false, tab1 )
- function BuyWeapon(button, state)
- if (button == "left") then
- if(source == button1) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_colt")
- elseif(source == button2) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_silencer")
- elseif(source == button3) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_deagle")
- elseif(source == button4) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_sawn")
- elseif(source == button5) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_shotgun")
- elseif(source == button6) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_spaz12")
- elseif(source == button7) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_mp5")
- elseif(source == button8) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_tec9")
- elseif(source == button9) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_uzi")
- elseif(source == button10) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_ak")
- elseif(source == button11) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_m4")
- elseif(source == button12) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_cs")
- elseif(source == button13) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_sniper")
- elseif(source == button14) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_ft")
- elseif(source == button15) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_hsrpg")
- elseif(source == button16) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_minigun")
- elseif(source == button17) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_rpg")
- elseif(source == button18) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_grenade")
- elseif(source == button19) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_motolov")
- elseif(source == button20) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_satchel")
- elseif(source == button21) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_teargas")
- elseif(source == button22) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_fire")
- elseif(source == button23) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_parachute")
- elseif(source == button24) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_baseball")
- elseif(source == button25) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_cane")
- elseif(source == button26) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_chainsaw")
- elseif(source == button27) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_golf")
- elseif(source == button28) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_pool")
- elseif(source == button29) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_katana")
- elseif(source == button30) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_knife")
- elseif(source == button31) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_nightstick")
- elseif(source == button32) then
- triggerServerEvent("onClientBuyWeapon", localPlayer, "weapon_shovel")
- end
- end
- end
- [/lua]
- server side:
- [lua]
- function BuyWeaponOnServer(weapon_name)
- player_money = getPlayerMoney(source)
- player_account = getPlayerAccount(source)
- local price_colt = "150"
- local price_silencer = "200"
- local price_deagle = "350"
- local price_sawn = "500"
- local price_shotgun = "450"
- local price_spaz12 = "600"
- local price_mp5 = "500"
- local price_tec9 = "500"
- local price_uzi = "500"
- local price_ak = "700"
- local price_m4 = "800"
- local price_cs = "650"
- local price_sniper = "700"
- local price_ft = "1000"
- local price_hsrpg = "1000"
- local price_minigun = "5000"
- local price_rpg = "1000"
- local price_grenade = "500"
- local price_motolov = "500"
- local price_satchel = "600"
- local price_teargas = "500"
- local price_fire = "180"
- local price_parachute = "250"
- local price_baseball = "80"
- local price_cane = "80"
- local price_chainsaw = "120"
- local price_golf = "50"
- local price_pool = "50"
- local price_katana = "150"
- local price_knife = "90"
- local price_nightstick = "60"
- local price_shovel = "50"
- if(weapon_name == "weapon_colt") then
- if(player_money >= tonumber(price_colt)) then
- giveWeapon(source, 22)
- takePlayerMoney(source, tonumber(price_colt))
- outputChatBox("You bought a colt.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a colt.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_silencer") then
- if(player_money >= tonumber(price_silencer)) then
- giveWeapon(source, 23, 1)
- takePlayerMoney(source, tonumber(price_silencer))
- outputChatBox("You bought an silencer.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy an silencer", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_deagle") then
- if(player_money >= tonumber(price_ak)) then
- giveWeapon(source, 24, 1)
- takePlayerMoney(source, tonumber(price_ak))
- outputChatBox("You bought an deagle.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy an deagle.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_sawn") then
- if(player_money >= tonumber(price_sawn)) then
- giveWeapon(source, 26, 1)
- takePlayerMoney(source, tonumber(price_sawn))
- outputChatBox("You bought a sawn off.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a sawn off.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_shotgun") then
- if(player_money >= tonumber(price_shotgun)) then
- giveWeapon(source, 25, 1)
- takePlayerMoney(source, tonumber(price_shotgun))
- outputChatBox("You bought an shotgun.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy an shotgun.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_spaz12") then
- if(player_money >= tonumber(price_spaz12)) then
- giveWeapon(source, 27, 1)
- takePlayerMoney(source, tonumber(price_spaz12))
- outputChatBox("You bought a spaz12.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a spaz12.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_mp5") then
- if(player_money >= tonumber(price_mp5)) then
- giveWeapon(source, 29, 1)
- 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_tec9") then
- if(player_money >= tonumber(price_tec9)) then
- giveWeapon(source, 32, 1)
- takePlayerMoney(source, tonumber(price_tec9))
- outputChatBox("You bought a tec9.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a tec9.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_uzi") then
- if(player_money >= tonumber(price_uzi)) then
- giveWeapon(source, 28, 1)
- takePlayerMoney(source, tonumber(price_uzi))
- outputChatBox("You bought a uzi.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a uzi.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_ak") then
- if(player_money >= tonumber(price_ak)) then
- giveWeapon(source, 30, 1)
- takePlayerMoney(source, tonumber(price_ak))
- outputChatBox("You bought a ak.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a ak.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_m4") then
- if(player_money >= tonumber(price_m4)) then
- giveWeapon(source, 31, 1)
- takePlayerMoney(source, tonumber(price_m4))
- outputChatBox("You bought a m4.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a m4.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_cs") then
- if(player_money >= tonumber(price_cs)) then
- giveWeapon(source, 33, 1)
- takePlayerMoney(source, tonumber(price_cs))
- outputChatBox("You bought a Country Rifle", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a Country Rifle.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_sniper") then
- if(player_money >= tonumber(price_sniper)) then
- giveWeapon(source, 34, 1)
- 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_hsrpg") then
- if(player_money >= tonumber(price_hsrpg)) then
- giveWeapon(source, 36, 1)
- takePlayerMoney(source, tonumber(price_hsrpg))
- outputChatBox("You bought a Heat-Seak RPG.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a Heat-Seak RPG.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_ft") then
- if(player_money >= tonumber(price_ft)) then
- giveWeapon(source, 37, 1)
- takePlayerMoney(source, tonumber(price_ft))
- outputChatBox("You bought a flame thrower.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a flame thrower.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_minigun") then
- if(player_money >= tonumber(price_minigun)) then
- giveWeapon(source, 38, 1)
- takePlayerMoney(source, tonumber(price_minigun))
- outputChatBox("You bought a minigun.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a minigun.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_rpg") then
- if(player_money >= tonumber(price_rpg)) then
- giveWeapon(source, 35, 1)
- takePlayerMoney(source, tonumber(price_rpg))
- outputChatBox("You bought a RPG.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a RPG.", 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 flame Grenade.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a Grenade.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_motolov") then
- if(player_money >= tonumber(price_motolov)) then
- giveWeapon(source, 37, 1)
- takePlayerMoney(source, tonumber(price_motolov))
- outputChatBox("You bought a motolov.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a motolov.", 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.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a satchel.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_teargas") then
- if(player_money >= tonumber(price_ft)) then
- giveWeapon(source, 17, 1)
- takePlayerMoney(source, tonumber(price_ft))
- 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_fire") then
- if(player_money >= tonumber(price_fire)) then
- giveWeapon(source, 42, 1)
- takePlayerMoney(source, tonumber(price_fire))
- outputChatBox("You bought a fire extinguisher.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a fire extinguisher.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_parachute") then
- if(player_money >= tonumber(price_parachute)) then
- giveWeapon(source, 46, 1)
- takePlayerMoney(source, tonumber(price_parachute))
- outputChatBox("You bought a flame thrower.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a parachute.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_baseball") then
- if(player_money >= tonumber(price_baseball)) then
- giveWeapon(source, 5)
- takePlayerMoney(source, tonumber(price_baseball))
- outputChatBox("You bought a baseball bat.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a baseball bat.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_cane") then
- if(player_money >= tonumber(price_cane)) then
- giveWeapon(source, 15)
- takePlayerMoney(source, tonumber(price_cane))
- outputChatBox("You bought a cane.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a cane.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_chainsaw") then
- if(player_money >= tonumber(price_chainsaw)) then
- giveWeapon(source, 9)
- takePlayerMoney(source, tonumber(price_chainsaw))
- outputChatBox("You bought a chainsaw.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a chainsaw.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_golf") then
- if(player_money >= tonumber(price_golf)) then
- giveWeapon(source, 2)
- takePlayerMoney(source, tonumber(price_golf))
- outputChatBox("You bought a golf club.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a golf club.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_pool") then
- if(player_money >= tonumber(price_pool)) then
- giveWeapon(source, 7)
- takePlayerMoney(source, tonumber(price_pool))
- outputChatBox("You bought a pool cue.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a pool cue.", source, 255, 0, 0)
- end
- elseif(weapon_name == "weapon_katana") then
- if(player_money >= tonumber(price_katana)) then
- giveWeapon(source, <!-- s8) --><img src=\"{SMILIES_PATH}/icon_cool.gif\" alt=\"8)\" title=\"Cool\" /><!-- s8) -->
- takePlayerMoney(source, tonumber(price_katana))
- outputChatBox("You bought a katana.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a katana.", 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_nightstick") then
- if(player_money >= tonumber(price_nightstick)) then
- giveWeapon(source, 3)
- takePlayerMoney(source, tonumber(price_nightstick))
- 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_shovel") then
- if(player_money >= tonumber(price_shovel)) then
- giveWeapon(source, 6)
- takePlayerMoney(source, tonumber(price_shovel))
- outputChatBox("You bought a shovel.", source, 0, 255, 0)
- else
- outputChatBox("You do not have enough money to buy a shovel.", source, 255, 0, 0)
- end
- end
- end
- addEvent("onClientBuyWeapon", true)
- addEventHandler("onClientBuyWeapon", getRootElement(), BuyWeaponOnServer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement