Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 KB | None | 0 0
  1. --> Created by n0pe
  2.  
  3. local hanfPrice = tonumber(math.random(10, 30))
  4. local weedPrice = tonumber(math.random(1, 50))
  5. local matsPrice = tonumber(math.random(1, 50))
  6.  
  7. local hanfPed = createPed(200, -2579.93213, 310.14310, 5.17969)
  8. local hanfSphere = createColSphere(-2579.93213, 310.14310, 5.17969, 3)
  9. setElementRotation(hanfPed, 0, 0, 90)
  10. setElementData(hanfPed, "allowedDamage", true)
  11.  
  12. local weedPed = createPed(29, -2311.59790, 1068.02820, 65.58594)
  13. local weedSphere = createColSphere(-2311.59790, 1068.02820, 65.58594, 3)
  14. setElementRotation(weedPed, 0, 0, 90)
  15. setElementData(weedPed, "allowedDamage", true)
  16.  
  17. local matsPed = createPed(29, -2311.59790, 1066.02820, 65.58594)
  18. local matsSphere = createColSphere(-2311.59790, 1066.02820, 65.58594, 3)
  19. setElementRotation(matsPed, 0, 0, 90)
  20. setElementData(matsPed, "allowedDamage", true)
  21.  
  22. addEventHandler("onColShapeHit", hanfSphere, function(uElement, iDimension)
  23. if getElementType(uElement) == "player" and iDimension then
  24. outputChatBox("Hey du,hier kannst du Hanfsamen Kaufen.", uElement, 255, 255, 0)
  25. end
  26. end)
  27.  
  28. addEventHandler("onColShapeHit", weedSphere, function(uElement, iDimension)
  29. if getElementType(uElement) == "player" and iDimension then
  30. outputChatBox("Hey du, hier kannst du Weed verkaufen.", uElement, 255, 255, 0)
  31. end
  32. end)
  33.  
  34. addEventHandler("onColShapeHit", matsSphere, function(uElement, iDimension)
  35. if getElementType(uElement) == "player" and iDimension then
  36. outputChatBox("Hey du, hier kannst du Mats verkaufen.", uElement, 255, 255, 0)
  37. end
  38. end)
  39.  
  40. addEventHandler("onPlayerClick", getRootElement(), function(btn, state, clickedElement)
  41. if btn == "left" and state == "down" and not getElementClicked(source) then
  42. if clickedElement then
  43. if clickedElement == hanfPed then
  44. triggerClientEvent(source, "onBuyHanf", getRootElement(), hanfPrice)
  45. setElementClicked(source, true)
  46. elseif clickedElement == weedPed then
  47. triggerClientEvent(source, "onSellWeed", getRootElement(), weedPrice)
  48. setElementClicked(source, true)
  49. elseif clickedElement == matsPed then
  50. triggerClientEvent(source, "onSellMats", getRootElement(), matsPrice)
  51. setElementClicked(source, true)
  52. end
  53. end
  54. end
  55. end)
  56.  
  57. addEvent("sellDrugstoNPC", true)
  58. addEventHandler("sellDrugstoNPC", root, function(amount)
  59. if amount then
  60. if (vioGetElementData(client, "drugs") >= amount) then
  61. vioSetElementData(client, "drugs", vioGetElementData(client, "drugs") - amount)
  62. vioSetElementData(client, "money", vioGetElementData(client, "money") + (amount * weedPrice))
  63. outputChatBox("Drogendealer: Danke für " .. amount .. " Gramm.", client, 255, 255, 255, false)
  64. outputChatBox("Drogendealer: Komm gerne wieder wenn du mehr hast.", client, 255, 255, 255, false)
  65. triggerClientEvent(client, "closeDrugSellWindow", client)
  66. else
  67. outputChatBox("Du hast nicht genug Drogen dabei.", client, 255, 0, 0, false)
  68. end
  69. end
  70. end)
  71.  
  72. addEvent("sellMatstoNPC", true)
  73. addEventHandler("sellMatstoNPC", root, function(amount)
  74. if amount then
  75. if (vioGetElementData(client, "mats") >= amount) then
  76. vioSetElementData(client, "mats", vioGetElementData(client, "mats") - amount)
  77. vioSetElementData(client, "money", vioGetElementData(client, "money") + (amount * matsPrice))
  78. outputChatBox("Matsdealer: Danke für " .. amount .. " Materialen.", client, 255, 255, 255, false)
  79. outputChatBox("Matsdealer: Komm gerne wieder wenn du mehr hast.", client, 255, 255, 255, false)
  80. triggerClientEvent(client, "closeMatsSellWindow", client)
  81. else
  82. outputChatBox("Du hast nicht genug Materialien dabei.", client, 255, 0, 0, false)
  83. end
  84. end
  85. end)
  86.  
  87. addEvent("buyHanfFromNPC", true)
  88. addEventHandler("buyHanfFromNPC", root, function(amount)
  89. if amount then
  90. if (vioGetElementData(client, "money") >= amount * hanfPrice) then
  91. vioSetElementData(client, "money", vioGetElementData(client, "money") - amount * hanfPrice)
  92. vioSetElementData(client, "flowerseeds", vioGetElementData(client, "flowerseeds") + amount)
  93. outputChatBox("Samenhändler: Hier hast du die Samen.", client, 255, 255, 255, false)
  94. outputChatBox("Samenhändler: Komm gerne wieder wenn du mehr brauchst.", client, 255, 255, 255, false)
  95. triggerClientEvent(client, "closeHanfBuyWindow", client)
  96. else
  97. outputChatBox("Du hast nicht genug Geld dabei.", client, 255, 0, 0, false)
  98. end
  99. end
  100. end)
  101.  
  102. local function changePrices()
  103. hanfPrice = tonumber(math.random(10, 30))
  104. weedPrice = tonumber(math.random(1, 50))
  105. matsPrice = tonumber(math.random(1, 50))
  106. end
  107.  
  108. setTimer(changePrices, 1000 * 60 * 30, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement