├── scrapman-job ├── scrapman.sql ├── main │ ├── config.lua │ ├── sv_scrapman.lua │ └── cl_scrapman.lua ├── fxmanifest.lua └── readme.md └── README.md /scrapman-job/scrapman.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO `items` (`name`, `label`, `weight`) VALUES 2 | ('scrap', 'scrap', 1) -------------------------------------------------------------------------------- /scrapman-job/main/config.lua: -------------------------------------------------------------------------------- 1 | Config = {} 2 | 3 | Config.OldEsx = true -- Set to true if you are using esx version under esx legacy version, if not set to false. 4 | -------------------------------------------------------------------------------- /scrapman-job/fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | games { 'rdr3', 'gta5' } 3 | 4 | author 'ArielZ' 5 | description 'OverTrue RolePlay scrapman-job for esx, you can convert it if you want to other frameworks feel free to use the script but please dont sell the script.' 6 | version '1.0.0' 7 | 8 | shared_scripts { 9 | 'main/config.lua', 10 | } 11 | 12 | client_scripts { 13 | 'main/cl_scrapman.lua', 14 | } 15 | 16 | server_scripts { 17 | 'main/sv_scrapman.lua', 18 | } 19 | -------------------------------------------------------------------------------- /scrapman-job/main/sv_scrapman.lua: -------------------------------------------------------------------------------- 1 | if Config.OldEsx == true then 2 | ESX = nil 3 | TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) 4 | end 5 | 6 | RegisterServerEvent('scrapjob:scrap:find') 7 | AddEventHandler('scrapjob:scrap:find', function() 8 | local _source = source 9 | local xPlayer = ESX.GetPlayerFromId(_source) 10 | xPlayer.addInventoryItem('scrap', 1) 11 | end) 12 | 13 | RegisterServerEvent('scrapjob:scrap:sell') 14 | AddEventHandler('scrapjob:scrap:sell', function() 15 | local _source = source 16 | local xPlayer = ESX.GetPlayerFromId(_source) 17 | local scrapQuantity = xPlayer.getInventoryItem('scrap').count 18 | local addmoney = math.random(20, 50) -- change here the price of the scrap sell 19 | if scrapQuantity >= 1 then 20 | xPlayer.removeInventoryItem('scrap', 1) 21 | xPlayer.addMoney(addmoney) 22 | TriggerClientEvent("pNotify:SendNotification", source, { 23 | text = "you sold a scrap type for " .. addmoney .. " keep working", 24 | type = "success", 25 | queue = "lmao", 26 | timeout = 7000, 27 | layout = "Centerleft" 28 | }) 29 | elseif scrapQuantity then 30 | TriggerClientEvent("pNotify:SendNotification", source, { 31 | text = "you dont have any scrap type", 32 | type = "success", 33 | queue = "lmao", 34 | timeout = 7000, 35 | layout = "Centerleft" 36 | }) 37 | end 38 | end) 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Scrapman-job 2 | OverTrue RolePlay scrapman-job 3 | 4 | [![Scrapman-job](https://img.shields.io/badge/Lua-Fivem-orange)](https://img.shields.io/badge/Lua-Fivem-orange) 5 | # Note: 6 | Hi there, Thank you for download my cool job here you can get all the information about the job. 7 | 8 | About the job: I posted this job a long time ago -> https://forum.cfx.re/t/esx-scrapman-job/3807213/42 9 | But unfortunately i had some problems there, and after a while i decided to post the job again with fixes for all the problems that i had there. 10 | If you find new problems or old ones keep in touch with me in the fivem forums or take my discord name from my github profile link -> https://github.com/ArielZ123 11 | I will be happy to help or get from you tips to fix things or change. 12 | 13 | Settings in the script: There are 3 things you can add or remove from the client side in lines -> 15, 21, 25, all of them are coords for add or remove positions of markers to search or sell and also add the npc Character 14 | that using as a 'dealer'. 15 | 16 | Server side change: In Line 17 you can change the price of the scrap sell -> local addmoney = math.random(20, 50) -> please pay attention to change the numbers to (High or low amount) as your choice. 17 | 18 | DO NOT FORGET TO CONNECT THE SQL FILE TO YOUR DB!!! 19 | 20 | To sum up things: I recommend you to give it a try and read about me in my github profile -> https://github.com/ArielZ123 21 | 22 | If you need anything feel free to ask me. 23 | 24 | Fivem Forum Link: https://forum.cfx.re/t/esx-scrapman-job-fixed-version-last-update/4841799 25 | 26 | -------- Update - > 21/1/2023 -------- 27 | Welcome legacy version :wave:. 28 | here is what you need to do if you use this version: 29 | Config.Lua - > will give you the option to switch between the old esx to the new one (esx legacy). 30 | If you are using the esx legacy version please set the config to false and do the following thing: 31 | Go to → fxmanifest.lua - > then go to → shared_scripts and then add this line → ‘@es_extended/imports.lua’ under → ‘main/config.lua’. 32 | -------------------------------------------------------------------------------- /scrapman-job/readme.md: -------------------------------------------------------------------------------- 1 | Hi there, Thank you for download my cool job here you can get all the information about the job. 2 | 3 | About the job: I posted this job a long time ago -> https://forum.cfx.re/t/esx-scrapman-job/3807213/42 4 | But unfortunately i had some problems there, and after a while i decided to post the job again with fixes for all the problems that i had there. 5 | If you find new problems or old ones keep in touch with me in the fivem forums or take my discord name from my github profile link -> https://github.com/ArielZ123 6 | I will be happy to help or get from you tips to fix things or change. 7 | 8 | Settings in the script: There are 3 things you can add or remove from the client side in lines -> 15, 21, 25, all of them are coords for add or remove positions of markers to search or sell and also add the npc Character 9 | that using as a 'dealer'. 10 | 11 | Server side change: In Line 17 you can change the price of the scrap sell -> local addmoney = math.random(20, 50) -> please pay attention to change the numbers to (High or low amount) as your choice. 12 | 13 | DO NOT FORGET TO CONNECT THE SQL FILE TO YOUR DB!!! 14 | 15 | To sum up things: I recommend you to give it a try and read about me in my github profile -> https://github.com/ArielZ123 16 | If you need anything feel free to ask me. 17 | 18 | -------- Update - > 21/1/2023 -------- 19 | Welcome legacy version :wave:. 20 | here is what you need to do if you use this version: 21 | Config.Lua - > will give you the option to switch between the old esx to the new one (esx legacy). 22 | If you are using the esx legacy version please set the config to false and do the following thing: 23 | Go to → fxmanifest.lua - > then go to → shared_scripts and then add this line → ‘@es_extended/imports.lua’ under → ‘main/config.lua’. 24 | 25 | Pictures from the job: 26 | https://cdn.discordapp.com/attachments/965912875640172594/965934134587432980/unknown.png 27 | https://cdn.discordapp.com/attachments/965912875640172594/965934434371112970/unknown.png 28 | https://cdn.discordapp.com/attachments/965912875640172594/965934652374278184/unknown.png 29 | https://cdn.discordapp.com/attachments/965912875640172594/965934813607522315/unknown.png 30 | https://cdn.discordapp.com/attachments/965912875640172594/965935124120240188/unknown.png 31 | https://cdn.discordapp.com/attachments/965912875640172594/965935831363760148/unknown.png 32 | https://cdn.discordapp.com/attachments/965912875640172594/965936115267801107/unknown.png 33 | https://cdn.discordapp.com/attachments/965912875640172594/965937363111006248/unknown.png 34 | -------------------------------------------------------------------------------- /scrapman-job/main/cl_scrapman.lua: -------------------------------------------------------------------------------- 1 | if Config.OldEsx == true then 2 | ESX = nil 3 | 4 | Citizen.CreateThread(function() 5 | while ESX == nil do 6 | TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) 7 | Citizen.Wait(0) 8 | end 9 | end) 10 | end 11 | 12 | local InJob = false 13 | local WhileSearcing = false 14 | local scrap_type = nil 15 | 16 | ------------------------ 17 | -- settings -- 18 | local Scrappos = { -- Add more positions for search... 19 | {x= -507.06, y= -1741.13, z= 17.94}, 20 | {x= -511.76, y= -1753.97, z= 17.9}, 21 | {x= -501.03, y= -1746.44, z= 17.48}, 22 | } 23 | 24 | local Scrapsell = { -- Add more positions for sell markrer... 25 | {x= -512.01, y= -1738.1, z= 18.29}, 26 | } 27 | 28 | local Npc = { -- Add more npcs for sell markrer... 29 | {x= -512.31, y= -1738.59, z= 18.3, h=324.46}, 30 | } 31 | ------------------------ 32 | 33 | Citizen.CreateThread(function() 34 | while true do 35 | local ped = PlayerPedId() 36 | local plyCoords = GetEntityCoords(ped) 37 | local NearMarker = false 38 | for k in pairs(Scrappos) do 39 | if InJob == false then 40 | local coord1 = vector3(plyCoords.x, plyCoords.y, plyCoords.z) 41 | local coord2 = vector3(Scrappos[k].x, Scrappos[k].y, Scrappos[k].z) 42 | local dist = #(coord1 - coord2) 43 | 44 | if dist <= 1.2 and not NearMarker then 45 | DrawMarker(1, Scrappos[k].x, Scrappos[k].y, Scrappos[k].z, 0, 0, 0, 0, 0, 0, 1.001, 1.0001, 0.2001, 0, 173, 255, 47 ,0 ,0 ,0 ,0) 46 | scrapmantext(Scrappos[k].x, Scrappos[k].y, Scrappos[k].z+ 0.9, tostring('Press ~b~[E]~w~ to search this spot')) 47 | NearMarker = true 48 | if IsControlJustPressed(0,38) then 49 | scrap() 50 | InJob = true 51 | WhileSearcing = true 52 | end 53 | end 54 | end 55 | end 56 | 57 | for k in pairs(Scrapsell) do 58 | if InJob == true then 59 | local coord1 = vector3(plyCoords.x, plyCoords.y, plyCoords.z) 60 | local coord2 = vector3(Scrapsell[k].x, Scrapsell[k].y, Scrapsell[k].z) 61 | local dist = #(coord1 - coord2) 62 | if dist <= 1.2 and not NearMarker then 63 | scrapmantext(Scrapsell[k].x, Scrapsell[k].y, Scrapsell[k].z+ 0.9, tostring('Press ~g~[E]~w~ to sell scraps')) 64 | DrawMarker(1, Scrapsell[k].x, Scrapsell[k].y, Scrapsell[k].z, 0, 0, 0, 0, 0, 0, 1.001, 1.0001, 0.2001, 50, 205, 50, 80 ,0 ,0 ,0 ,0) 65 | NearMarker = true 66 | if IsControlJustPressed(0,38) then 67 | TriggerServerEvent('scrapjob:scrap:sell') 68 | DeleteEntity(scrap_type) 69 | ClearPedTasks(ped) 70 | InJob = false 71 | end 72 | end 73 | end 74 | end 75 | 76 | if not NearMarker then 77 | Citizen.Wait(1000) 78 | end 79 | Citizen.Wait(0) 80 | end 81 | end) 82 | 83 | 84 | Citizen.CreateThread(function() 85 | while true do 86 | if WhileSearcing == true then 87 | DisableControlAction(0, 24, true) 88 | DisableControlAction(0, 257, true) 89 | DisableControlAction(0, 263, true) 90 | DisableControlAction(0, 32, true) 91 | DisableControlAction(0, 34, true) 92 | DisableControlAction(0, 31, true) 93 | DisableControlAction(0, 30, true) 94 | DisableControlAction(0, 45, true) 95 | DisableControlAction(0, 22, true) 96 | DisableControlAction(0, 44, true) 97 | DisableControlAction(0, 37, true) 98 | DisableControlAction(0, 264, true) 99 | DisableControlAction(0, 257, true) 100 | DisableControlAction(0, 140, true) 101 | DisableControlAction(0, 141, true) 102 | DisableControlAction(0, 142, true) 103 | DisableControlAction(0, 143, true) 104 | end 105 | Citizen.Wait(0) 106 | end 107 | end) 108 | 109 | Citizen.CreateThread(function() 110 | local blip = AddBlipForCoord(-511.76, -1753.97, 18.9) 111 | SetBlipSprite(blip, 365) 112 | SetBlipScale(blip, 0.90) 113 | SetBlipColour(blip, 2) 114 | SetBlipAsShortRange(blip, true) 115 | 116 | BeginTextCommandSetBlipName("STRING") 117 | AddTextComponentString('Scrap Area') 118 | EndTextCommandSetBlipName(blip) 119 | 120 | for k in pairs(Npc) do 121 | RequestModel(GetHashKey("s_m_m_dockwork_01")) 122 | while not HasModelLoaded(GetHashKey("s_m_m_dockwork_01")) do 123 | Citizen.Wait(0) 124 | end 125 | local sell_npc = CreatePed(4, GetHashKey("s_m_m_dockwork_01"), Npc[k].x, Npc[k].y, Npc[k].z, Npc[k].h, false, true) 126 | TaskStartScenarioInPlace(sell_npc, "WORLD_HUMAN_CLIPBOARD", 0, 1) 127 | FreezeEntityPosition(sell_npc, true) 128 | SetEntityHeading(sell_npc, Npc[k].h, true) 129 | SetEntityInvincible(sell_npc, true) 130 | SetBlockingOfNonTemporaryEvents(sell_npc, true) 131 | end 132 | end) 133 | 134 | function scrap() 135 | Citizen.CreateThread(function() 136 | local impacts = 0 137 | local ped = PlayerPedId() 138 | local plyCoords = GetEntityCoords(ped) 139 | local time = math.random(1,4) 140 | while impacts < 3 do 141 | Citizen.Wait(0) 142 | LoadDict('anim@gangops@facility@servers@bodysearch@') 143 | TaskPlayAnim(ped, 'anim@gangops@facility@servers@bodysearch@', 'player_search', 8.0, -8.0, -1, 48, 0) 144 | Citizen.Wait(2500) 145 | ClearPedTasks(ped) 146 | impacts = impacts+1 147 | print('search loop->',impacts) 148 | if impacts == 3 then 149 | impacts = 0 150 | TriggerServerEvent('scrapjob:scrap:find') 151 | exports.pNotify:SendNotification({text = "you found some scrap type, go ahead to sell this scrap to the dealer nearby", type = "success", timeout = 8000, layout = "centerRight", queue = "right"}) 152 | WhileSearcing = false 153 | break 154 | end 155 | end 156 | 157 | if time == 1 then 158 | scrap_type = CreateObject(GetHashKey('prop_car_door_01'),plyCoords.x, plyCoords.y,plyCoords.z, true, true, true) 159 | AttachEntityToEntity(scrap_type , ped, GetPedBoneIndex(ped, 60309), 0.025, 0.00, 0.355, -75.0, 470.0, 0.0, true, true, false, true, 1, true) 160 | LoadDict('anim@heists@box_carry@') 161 | TaskPlayAnim(ped, 'anim@heists@box_carry@', "idle", 3.0, -8, -1, 63, 0, 0, 0, 0 ) 162 | elseif time == 2 then 163 | scrap_type = CreateObject(GetHashKey('prop_rub_monitor'),plyCoords.x, plyCoords.y,plyCoords.z, true, true, true) 164 | AttachEntityToEntity(scrap_type , ped, GetPedBoneIndex(ped, 60309), 0.020, 0.00, 0.255, -70.0, 470.0, 0.0, true, true, false, true, 1, true) 165 | LoadDict('anim@heists@box_carry@') 166 | TaskPlayAnim(ped, 'anim@heists@box_carry@', "idle", 3.0, -8, -1, 63, 0, 0, 0, 0 ) 167 | elseif time == 3 then 168 | scrap_type = CreateObject(GetHashKey('prop_car_seat'),plyCoords.x, plyCoords.y,plyCoords.z, true, true, true) 169 | AttachEntityToEntity(scrap_type , ped, GetPedBoneIndex(ped, 60309), 0.020, 0.00, 0.255, -70.0, 470.0, 0.0, true, true, false, true, 1, true) 170 | LoadDict('anim@heists@box_carry@') 171 | TaskPlayAnim(ped, 'anim@heists@box_carry@', "idle", 3.0, -8, -1, 63, 0, 0, 0, 0 ) 172 | else 173 | scrap_type = CreateObject(GetHashKey('prop_rub_tyre_03'),plyCoords.x, plyCoords.y,plyCoords.z, true, true, true) 174 | AttachEntityToEntity(scrap_type , ped, GetPedBoneIndex(ped, 60309), 0.30, 0.35, 0.365, -045.0, 480.0, 0.0, true, true, false, true, 1, true) 175 | LoadDict('anim@heists@box_carry@') 176 | TaskPlayAnim(ped, 'anim@heists@box_carry@', "idle", 3.0, -8, -1, 63, 0, 0, 0, 0 ) 177 | end 178 | end) 179 | end 180 | 181 | function LoadDict(dict) 182 | RequestAnimDict(dict) 183 | while not HasAnimDictLoaded(dict) do 184 | Citizen.Wait(10) 185 | end 186 | end 187 | 188 | function scrapmantext(x, y, z, text) 189 | local onScreen, _x, _y = World3dToScreen2d(x, y, z) 190 | local p = GetGameplayCamCoords() 191 | local distance = GetDistanceBetweenCoords(p.x, p.y, p.z, x, y, z, 1) 192 | local scale = (1 / distance) * 2 193 | local fov = (1 / GetGameplayCamFov()) * 100 194 | local scale = scale * fov 195 | if onScreen then 196 | SetTextScale(0.0, 0.30) 197 | SetTextFont(0) 198 | SetTextProportional(1) 199 | SetTextColour(255, 255, 255, 255) 200 | SetTextDropshadow(0, 0, 0, 0, 255) 201 | SetTextEdge(2, 0, 0, 0, 150) 202 | SetTextDropShadow() 203 | SetTextOutline() 204 | SetTextEntry("STRING") 205 | SetTextCentre(1) 206 | AddTextComponentString(text) 207 | DrawText(_x,_y) 208 | end 209 | end 210 | --------------------------------------------------------------------------------