Guest User

vblihfdgkhdfbjbfjfjhf

a guest
Jul 12th, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.64 KB | None | 0 0
  1. Client .....
  2. gMe = getLocalPlayer()
  3.  
  4. shopWindow = guiCreateWindow(367,105,334,435,"Waffenladen",false)
  5. guiSetVisible (shopWindow, false)
  6. guiSetAlpha(shopWindow,1)
  7. guiWindowSetSizable(shopWindow,false)
  8. tabPanel = guiCreateTabPanel(11,23,314,372,false,shopWindow)
  9. tab2 = guiCreateTab("Waffen",tabPanel)
  10. weapGrid = guiCreateGridList(4,6,305,291,false,tab2)
  11. guiGridListSetSelectionMode(weapGrid,0)
  12. weapColumn = guiGridListAddColumn(weapGrid,"Waffe",0.4)
  13. costColumn = guiGridListAddColumn(weapGrid,"Preis",0.2)
  14. ammoColumn = guiGridListAddColumn(weapGrid,"Mun",0.2)
  15. weapButton = guiCreateButton(107,308,100,29,"Kaufen",false,tab2)
  16. tab3 = guiCreateTab("Skills",tabPanel)
  17. skillsGrid = guiCreateGridList(4,6,305,291,false,tab3)
  18. guiGridListSetSelectionMode(skillsGrid,0)
  19. idColumn = guiGridListAddColumn(skillsGrid,"ID",0.3)
  20. skillsColumn = guiGridListAddColumn(skillsGrid,"Skill",0.5)
  21. costColumn = guiGridListAddColumn(skillsGrid,"Preis",0.3)
  22. -------------------------------------------------------------
  23. tab4 = guiCreateTab("Extras",tabPanel)
  24. extraGrid = guiCreateGridList(4,6,305,291,false,tab4)
  25. guiGridListSetSelectionMode(extraGrid,0)
  26. IdColumn = guiGridListAddColumn(extraGrid,"ID",0.2)
  27. extraColumn = guiGridListAddColumn(extraGrid,"Extra",0.5)
  28. costColumn = guiGridListAddColumn(extraGrid,"Preis",0.2)
  29. extraButton = guiCreateButton(107,308,100,29,"Kaufen",false,tab4)
  30. --------------------------------------
  31.  
  32. weapButton = guiCreateButton(107,308,100,29,"Kaufen",false,tab2)
  33. skillsButton = guiCreateButton(107,308,100,29,"Kaufen",false,tab3)
  34. local weapons = {{5,100,1},{6,100,1},{8,1000,1},{9,10000,1},{16,18000,15},{22,1800,100},{23,1000,100},{24,2000,100},{25,8000,100},{26,2500,100},{27,2500,100},{28,1500,100},{29,2000,100},{30,2900,100},{31,3200,100},{32,10000,500},{33,5300,100},{34,5500,100},{46,500,1}}
  35.  
  36. for i,v in ipairs (weapons) do
  37.     local itemName = getWeaponNameFromID (v[1])
  38.     local row = guiGridListAddRow (weapGrid)
  39.     local ammo = v[3] or 200
  40.     guiGridListSetItemText (weapGrid, row, 1, itemName, false, true)
  41.     guiGridListSetItemText (weapGrid, row, 2, tostring(v[2]), false, true)
  42.     guiGridListSetItemText (weapGrid, row, 3, tostring(ammo), false, true)
  43. end
  44. guiSetAlpha(weapGrid,1)
  45. closeButton = guiCreateButton(112,401,113,24,"Schließen",false,shopWindow)
  46.  
  47.  
  48. skillsTable = {{"0","Colt-45 Skill","250"},{"1","Silenced-Pistol Skill","2000"},{"2","Desert-Eagle Skill","5000"},{"3","Shotgun Skill","16000"},{"4","Sawed-off Skill","22000"},{"5","Spaz-12 Skill","15000"},{"6","Uzi Skill","11000"},{"7","MP5 Skill","14000"},{"8","AK-47 Skill","16000"},{"9","M4 Skill","20000"},{"10","Sniper","20000"}}
  49. for i,v in ipairs (skillsTable) do
  50.   local row = guiGridListAddRow (skillsGrid)
  51.   guiGridListSetItemText (skillsGrid, row, 1, v[1], false, true)
  52.   guiGridListSetItemText (skillsGrid, row, 2, v[2], false, true)
  53.   guiGridListSetItemText (skillsGrid, row, 3, v[3], false, true)
  54. end
  55.  
  56.  
  57. extraTable = {{"0","Doppelt Soviel Leben","5000"},{"1","Permanentes Jetpack","50000"},{"2","2x Money Reward","90000"},{"3","4x Money Reward","120000"},{"4","10x Money Reward","420000"},{"5","Double Ammo","35000"}}
  58. for i,v in ipairs (extraTable) do
  59.   local row = guiGridListAddRow (extraGrid)
  60.   guiGridListSetItemText (extraGrid, row, 1, v[1], false, true)
  61.   guiGridListSetItemText (extraGrid, row, 2, v[2], false, true)
  62.    guiGridListSetItemText (extraGrid, row, 3, v[3], false, true)
  63. end
  64.  
  65.  
  66. function closeShop()
  67.     if guiGetVisible(shopWindow) then
  68.         guiSetVisible(shopWindow,false)
  69.         showCursor(false)
  70.     end
  71. end
  72. addEventHandler ("onClientGUIClick", closeButton, closeShop)
  73.  
  74. addEvent ("viewGUI", true)
  75. function viewGUI ()
  76.   if (getLocalPlayer() == source) then
  77.     guiSetVisible (shopWindow, true)
  78.     showCursor (true)
  79.   end
  80. end
  81. addEventHandler ("viewGUI", getRootElement(), viewGUI)
  82.  
  83. function onClientWeapBuy (button, state, absoluteX, absoluteYe)
  84.  if (source == weapButton) then guiSetVisible (shopWindow, true) showCursor (true)
  85.    if (guiGridListGetSelectedItem (weapGrid)) then
  86.      local itemName = guiGridListGetItemText (weapGrid, guiGridListGetSelectedItem (weapGrid), 1)
  87.      local itemID = getWeaponIDFromName (itemName)
  88.      local itemCost = guiGridListGetItemText (weapGrid, guiGridListGetSelectedItem (weapGrid), 2)
  89.      local itemAmmo = guiGridListGetItemText (weapGrid, guiGridListGetSelectedItem (weapGrid), 3)
  90.      triggerServerEvent ("weapBuy", getLocalPlayer(), itemID, itemCost, itemName, itemAmmo)
  91.     end
  92.   end
  93. end
  94. addEventHandler ("onClientGUIClick", weapButton, onClientWeapBuy)
  95.  
  96. function cursor()
  97.        local currentState = isCursorShowing ()
  98.         local oppositeState = not currentState  
  99.         showCursor ( oppositeState )
  100. end
  101. addCommandHandler("mouse", cursor)
  102.  
  103. function onClientSkillBuy (button, state, absoluteX, absoluteYe)
  104.  if (source == skillsButton) then guiSetVisible (shopWindow, true) showCursor (true)
  105.     if (guiGridListGetSelectedItem (skillsGrid)) then
  106.      local id = guiGridListGetItemText (skillsGrid, guiGridListGetSelectedItem (skillsGrid), 1)
  107.       local cost = guiGridListGetItemText (skillsGrid, guiGridListGetSelectedItem (skillsGrid), 2)
  108.       triggerServerEvent ("skillBuy", getLocalPlayer(), id, cost)
  109.     end
  110.  end
  111. end
  112. addEventHandler ("onClientGUIClick", skillsButton, onClientSkillBuy)
  113.  
  114.  
  115. function onClientExtraBuy (button, state, absoluteX, absoluteYe)
  116.  if (source == extraButton) then guiSetVisible (shopWindow, true) showCursor (true)
  117.     if (guiGridListGetSelectedItem (extraGrid)) then
  118.      local idextra = guiGridListGetItemText (extraGrid, guiGridListGetSelectedItem (extraGrid), 1)
  119.       local costextra = guiGridListGetItemText (extraGrid, guiGridListGetSelectedItem (extraGrid), 2)
  120.       triggerServerEvent ("extraBuy", getLocalPlayer(), idextra, costextra)
  121.     end
  122.  end
  123. end
  124. addEventHandler ("onClientGUIClick", extraButton, onClientSkillBuy)
  125.  
  126.  
  127. function create3DDrawText(text, x, y, z, r, g, b, thick, view, line, dr, dg, db)
  128. z = z+0.2
  129. --createPickup(x, y, z, 3, 1239, 500)
  130. addEventHandler("onClientRender", getRootElement(),
  131.     function()
  132.         local xp, yp, zp = getElementPosition( gMe )
  133.         local x1, y1 = getScreenFromWorldPosition( x, y, z+0.5)
  134.         if(getDistanceBetweenPoints3D(  x, y, z, xp, yp, zp ) < view) and (x1) then
  135.             x1 = x1-40
  136.             if(line == true) then
  137.                 if(isLineOfSightClear(x, y, z, xp, yp, zp, true, true, false, false, false, false, false)) then
  138.                     dxDrawText (text, x1, y1, x1, y1, tocolor ( r, g, b, 255 ), thick, "default-bold")
  139.                 end
  140.             else
  141.                 dxDrawText (text, x1, y1, x1, y1, tocolor ( r, g, b, 255 ), thick, "default-bold")
  142.             end
  143.         end
  144.     end)
  145. end
  146.  
  147. -- Texte --
  148.  
  149. create3DDrawText("Waffenladen", 2306.7231445313, -5.3885803222656, 26.120220184326, 0, 255, 0, 2, 50, true, 0, 0, 0)
  150.  
  151. Server ...
  152.  
  153.  
  154. automat = createObject(956, 2305.7231445313, -5.3885803222656, 26.120220184326, 0, 0, 88)
  155.  
  156. addEvent ("viewGUI", true)
  157. function showGui(but, stat, hitPlayer)
  158.     if(but == "left") and (stat == "down") then
  159.     triggerClientEvent ("viewGUI", hitPlayer)
  160.     end
  161. end
  162. addEventHandler("onElementClicked", automat,showGui)
  163.  
  164.  
  165. addEvent ("weapBuy", true)
  166. addEventHandler ("weapBuy", getRootElement(),
  167. function(id, cost, name, ammo)
  168.   if (getPlayerMoney (source) >= tonumber(cost)) then
  169.     outputChatBox ("Du hast: ein/eine" .. name.." für  $"..cost.." Gekauft!", source, 0, 255, 0, false)
  170.     takePlayerMoney (source, tonumber (cost))
  171.     giveWeapon(source, tonumber(id),tonumber(ammo),true)
  172.   else
  173.     outputChatBox ("Du hast nicht Genug Geld", source, 255, 0, 0, false)
  174.   end
  175. end)
  176.  
  177. function skillButton (id, cost)
  178.   if (id == "0") then
  179.     skillBuyPlayer (250,source,69)
  180.     elseif (id == "1") then
  181.     skillBuyPlayer (2000,source,70)
  182.     elseif (id == "2") then
  183.     skillBuyPlayer (5000,source,71)
  184.     elseif (id == "3") then
  185.     skillBuyPlayer (16000,source,72)
  186.     elseif (id == "4") then
  187.     skillBuyPlayer (22000,source,73)
  188.     elseif (id == "5") then
  189.     skillBuyPlayer (15000,source,74)
  190.     elseif (id == "6") then
  191.     skillBuyPlayer (11000,source,75)
  192.     elseif (id == "7") then
  193.     skillBuyPlayer (14000,source,76)
  194.     elseif (id == "8") then
  195.     skillBuyPlayer (16000,source,77)   
  196.     elseif (id == "9") then
  197.     skillBuyPlayer (20000,source,78)
  198.     elseif (id == "10") then
  199.     skillBuyPlayer (20000,source,79)   
  200.   end
  201. end
  202. addEvent ("skillBuy", true)
  203. addEventHandler ("skillBuy", getRootElement(),skillButton)
  204.  
  205. function skillBuyPlayer (cash,player,id)
  206.     if (getPlayerMoney (player) >= cash) then
  207.       takePlayerMoney (player,cash)
  208.       setPedStat(player, id, 999)
  209.     else outputChatBox ("Du hast nicht Genug Geld!", player, 255,0,0)
  210.   end
  211. end
  212.  
  213.  
  214. function extraButton (id, cost)
  215.   if (id == "0") then
  216.      if (getPlayerMoney (source) >= cost) then
  217.       takePlayerMoney (source,cost)
  218.       setPedStat(source, 24, 999)
  219.             outputChatBox ("Du hast Extra "..id.." für "..cost.." Gekauft !", source, 255,0,0)
  220.     else
  221.         outputChatBox ("Du hast nicht Genug Geld!", source, 255,0,0)
  222.         end
  223.     elseif (id == "1") then
  224.     ------------------Jetpack
  225.      if (getPlayerMoney (source) >= cost) then
  226.           takePlayerMoney (source,cost)
  227.         givesourceJetPack ( source )
  228.         outputChatBox ("Du hast Extra "..id.." für "..cost.." Gekauft !", source, 255,0,0)
  229.     else
  230.         outputChatBox ("Du hast nicht Genug Geld!", source, 255,0,0)
  231.         end
  232.     elseif (id == "2") then
  233.     --------------2x Money
  234.      if (getPlayerMoney (source) >= cost) then
  235.           takePlayerMoney (source,cost)
  236.         setElementData(source, "2x", true)
  237.         outputChatBox ("Du hast Extra "..id.." für "..cost.." Gekauft !", source, 255,0,0)
  238.     else
  239.         outputChatBox ("Du hast nicht Genug Geld!", source, 255,0,0)
  240.     end
  241.     elseif (id == "3") then
  242.     ----------------4x Money
  243.      if (getPlayerMoney (source) >= cost) then
  244.           takePlayerMoney (source,cost)
  245.         setElementData(source, "4x", true)
  246.         outputChatBox ("Du hast Extra "..id.." für "..cost.." Gekauft !", source, 255,0,0)
  247.     else
  248.         outputChatBox ("Du hast nicht Genug Geld!", source, 255,0,0)
  249.     end
  250.     elseif (id == "4") then
  251.     -------------10x Money
  252.      if (getPlayerMoney (source) >= cost) then
  253.           takePlayerMoney (source,cost)
  254.         setElementData(source, "10x", true)
  255.         outputChatBox ("Du hast Extra "..id.." für "..cost.." Gekauft !", source, 255,0,0)
  256.     else
  257.         outputChatBox ("Du hast nicht Genug Geld!", source, 255,0,0)
  258.     end
  259.     elseif (id == "5") then
  260.     --------Double Ammo
  261.      if (getPlayerMoney (source) >= cost) then
  262.           takePlayerMoney (source,cost)
  263.          local munition = getPedTotalAmmo ( source )
  264.         local wpn =  getPedWeapon ( source, current )
  265.         giveWeaponAmmo ( source, wpn, munition*2 )
  266.         outputChatBox ("Du hast Extra "..id.." für "..cost.." Gekauft !", source, 255,0,0)
  267.     else
  268.         outputChatBox ("Du hast nicht Genug Geld!", source, 255,0,0)
  269.     end
  270.     end
  271. end
  272. addEvent ("extraBuy", true)
  273. addEventHandler ("extraBuy", getRootElement(),extraButton)
Advertisement
Add Comment
Please, Sign In to add comment