Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function carshop_blockEnterVehicle(thePlayer)
- if vehicleOwner == dbid then return end
- local salePrice = tonumber(getElementData(source,"salePrice"))
- if salePrice > 0 then
- local vehicleOwner = getElementData(source,"owner")
- local dbid = getElementData(thePlayer,"dbid")
- local payByCash = true
- local payByBank = true
- if not exports.global:hasMoney(thePlayer, salePrice) or salePrice == 0 then
- payByCash = false
- end
- local activeacc = getElementData(thePlayer, "activeacc:id")
- if (tonumber(activeacc) <= 0) then
- payByBank = false
- else
- local moneeh = getElementData(thePlayer, "activeacc:balance")
- if (moneeh) then
- local money = tonumber(moneeh) - salePrice
- if money < 0 or salePrice == 0 then
- payByBank = false
- end
- else
- payByBank = false
- end
- end
- triggerClientEvent(thePlayer, "buyCar", source, salePrice, payByCash, payByBank)
- cancelEvent()
- end
- end
- addEventHandler( "onVehicleEnter", root, carshop_blockEnterVehicle)
- addEventHandler( "onVehicleStartEnter", root, carshop_blockEnterVehicle)
- -- EVENTS
- addEvent("onVehicleDelete", false)
- function setSale ( thePlayer, commandName, salePrice )
- local salePrice = tonumber(salePrice)
- if not salePrice then return outputChatBox("Comandă: /"..commandName.." [Preț]",thePlayer, 255, 255, 255) end
- if salePrice < 0 then return outputChatBox("Nu poti seta pretul mai mic ca 0",thePlayer, 255, 0, 0) end
- local veh = getPedOccupiedVehicle(thePlayer)
- if not veh then return outputChatBox("Nu ești într-un vehicul!",thePlayer, 255, 0, 0) end
- local vehOwner = getElementData(veh,"owner")
- if vehOwner < 0 then return outputChatBox("Nu poti pune un vehicul civil la vanzare!",thePlayer, 255, 0, 0) end
- if not vehOwner == getElementData(thePlayer,"dbid") then return outputChatBox("Nu poți pune la vânzare vehiculul altui individ!", thePlayer, 255, 0, 0) end
- exports['anticheat-system']:changeProtectedElementDataEx(veh, "salePrice", salePrice, true)
- outputChatBox("Vehiculul a fost pus la vânzare pentru suma de "..salePrice.." lei!",thePlayer,0, 255, 0)
- end
- addCommandHandler("vanzare",setSale)
- function resetSale ( thePlayer, commandName )
- local veh = getPedOccupiedVehicle(thePlayer)
- if not veh then return outputChatBox("Nu ești într-un vehicul!",thePlayer, 255, 0, 0) end
- local dbid = getElementData(thePlayer,"dbid")
- local vehOwner = getElementData(veh,"owner")
- if not vehOwner == dbid then return outputChatBox("Nu poți pune la vânzare vehiculul altui individ!", thePlayer, 255, 0, 0) end
- local sellPrice = getElementData(veh, "salePrice")
- if sellPrice > 0 then
- exports['anticheat-system']:changeProtectedElementDataEx(veh, "salePrice", 0, true)
- outputChatBox("Vehiculul a fost scos de la vânzare!",thePlayer,0, 255, 0)
- else
- outputChatBox("Acest vehicul nu este la vânzare!", thePlayer, 255, 0, 0)
- end
- end
- addCommandHandler("cvanzare",resetSale)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement