Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. function carshop_blockEnterVehicle(thePlayer)
  2.  
  3. if vehicleOwner == dbid then return end
  4.  
  5. local salePrice = tonumber(getElementData(source,"salePrice"))
  6.  
  7. if salePrice > 0 then
  8.  
  9. local vehicleOwner = getElementData(source,"owner")
  10.  
  11. local dbid = getElementData(thePlayer,"dbid")
  12.  
  13. local payByCash = true
  14.  
  15. local payByBank = true
  16.  
  17. if not exports.global:hasMoney(thePlayer, salePrice) or salePrice == 0 then
  18.  
  19. payByCash = false
  20.  
  21. end
  22.  
  23. local activeacc = getElementData(thePlayer, "activeacc:id")
  24.  
  25. if (tonumber(activeacc) <= 0) then
  26.  
  27. payByBank = false
  28.  
  29. else
  30.  
  31. local moneeh = getElementData(thePlayer, "activeacc:balance")
  32.  
  33. if (moneeh) then
  34.  
  35. local money = tonumber(moneeh) - salePrice
  36.  
  37. if money < 0 or salePrice == 0 then
  38.  
  39. payByBank = false
  40.  
  41. end
  42.  
  43. else
  44.  
  45. payByBank = false
  46.  
  47. end
  48.  
  49. end
  50.  
  51. triggerClientEvent(thePlayer, "buyCar", source, salePrice, payByCash, payByBank)
  52.  
  53. cancelEvent()
  54.  
  55. end
  56.  
  57. end
  58.  
  59. addEventHandler( "onVehicleEnter", root, carshop_blockEnterVehicle)
  60.  
  61. addEventHandler( "onVehicleStartEnter", root, carshop_blockEnterVehicle)
  62.  
  63.  
  64.  
  65. -- EVENTS
  66.  
  67. addEvent("onVehicleDelete", false)
  68.  
  69.  
  70.  
  71. function setSale ( thePlayer, commandName, salePrice )
  72.  
  73. local salePrice = tonumber(salePrice)
  74.  
  75. if not salePrice then return outputChatBox("Comandă: /"..commandName.." [Preț]",thePlayer, 255, 255, 255) end
  76.  
  77. if salePrice < 0 then return outputChatBox("Nu poti seta pretul mai mic ca 0",thePlayer, 255, 0, 0) end
  78.  
  79. local veh = getPedOccupiedVehicle(thePlayer)
  80.  
  81. if not veh then return outputChatBox("Nu ești într-un vehicul!",thePlayer, 255, 0, 0) end
  82.  
  83. local vehOwner = getElementData(veh,"owner")
  84.  
  85. if vehOwner < 0 then return outputChatBox("Nu poti pune un vehicul civil la vanzare!",thePlayer, 255, 0, 0) end
  86.  
  87. if not vehOwner == getElementData(thePlayer,"dbid") then return outputChatBox("Nu poți pune la vânzare vehiculul altui individ!", thePlayer, 255, 0, 0) end
  88.  
  89. exports['anticheat-system']:changeProtectedElementDataEx(veh, "salePrice", salePrice, true)
  90.  
  91. outputChatBox("Vehiculul a fost pus la vânzare pentru suma de "..salePrice.." lei!",thePlayer,0, 255, 0)
  92.  
  93. end
  94.  
  95. addCommandHandler("vanzare",setSale)
  96.  
  97.  
  98.  
  99. function resetSale ( thePlayer, commandName )
  100.  
  101. local veh = getPedOccupiedVehicle(thePlayer)
  102.  
  103. if not veh then return outputChatBox("Nu ești într-un vehicul!",thePlayer, 255, 0, 0) end
  104.  
  105. local dbid = getElementData(thePlayer,"dbid")
  106.  
  107. local vehOwner = getElementData(veh,"owner")
  108.  
  109. if not vehOwner == dbid then return outputChatBox("Nu poți pune la vânzare vehiculul altui individ!", thePlayer, 255, 0, 0) end
  110.  
  111. local sellPrice = getElementData(veh, "salePrice")
  112.  
  113. if sellPrice > 0 then
  114.  
  115. exports['anticheat-system']:changeProtectedElementDataEx(veh, "salePrice", 0, true)
  116.  
  117. outputChatBox("Vehiculul a fost scos de la vânzare!",thePlayer,0, 255, 0)
  118.  
  119. else
  120.  
  121. outputChatBox("Acest vehicul nu este la vânzare!", thePlayer, 255, 0, 0)
  122.  
  123. end
  124.  
  125. end
  126.  
  127. addCommandHandler("cvanzare",resetSale)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement