Hello i am using esx and i was wondering how do i make it so that when a player scraps a car, the script will pay it a random amount so for example math.random(45, 125)
If anyone can help me that would be great!
Hello i am using esx and i was wondering how do i make it so that when a player scraps a car, the script will pay it a random amount so for example math.random(45, 125)
If anyone can help me that would be great!
Share your script…
basically you just need to use
xPlayer.addMoney(money)
i want it to make it so that it gives the money to the player after the Citizen.Wait(1)
if Vdist(GetEntityCoords(GetPlayerPed(-1), false), GetEntityCoords(GetPlayersLastVehicle(GetPlayerPed(-1), false))) < distancetoscrap then
SetEntityAsMissionEntity(GetPlayersLastVehicle(GetPlayerPed(-1), 1), true, true)
DeleteVehicle(GetPlayersLastVehicle(GetPlayerPed(-1), 1), true, true)
TriggerEvent("chatMessage", "[Notification]", {255,0,0}, "Car was successfully scraped.")
Citizen.Wait(1)
else
TriggerEvent("chatMessage", "[Notification]", {255,0,0}, "You need to be near the car to scrap it.")
end
TriggerEvent("chatMessage", "[Notification]", {255,0,0}, "Car was successfully scraped.")
You spelled “scrapped” wrong
and you need to trigger a server event to give money so it should be something like
// CLIENT SIDE after Citizen.Wait(1)
TriggerServerEvent('car_scrap:Payout')
// SERVER SIDE
RegisterNetEvent('car_scrap:Payout')
AddEventHandler('car_scrap:Payout', function()
xPlayer.addmoney(amount)
end)
For the payout, you could just grab the vehicles and prices from the database, return them in the server event and then make it half the payout or something.
i got this error:
https://gyazo.com/e82fcdcd2e8bf36c377b2c8d121bb1a0
You haven’t defined ESX anywhere in your script that’s the problem, I’m not gonna give you a basic’s on how to do a ESX script, that’s where the boilerplate release is there for.
Dude share your script so we can help you. Not a part of it…
__resource.lua:
dependency 'es_extended'
server.lua:
ESX = nil
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local amount = math.random(450, 1500)
RegisterNetEvent('testblips:Payout')
AddEventHandler('testblips:Payout', function()
xPlayer.addmoney(amount)
end)
client.lua:
TriggerServerEvent('testblips:Payout')
Error I’m currently getting:
https://gyazo.com/18496b890fb4a5ea561499b6cc96e05c