Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
tweak(server): Restore Old mod upon disconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
renzuzu committed Sep 29, 2021
1 parent 8166e10 commit a4e1714
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
12 changes: 10 additions & 2 deletions client/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ AddEventHandler('renzu_customs:openmenu', function()
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
oldprop = GetVehicleProperties(vehicle)
for k,v in pairs(Config.Customs) do
local distance = #(GetEntityCoords(PlayerPedId()) - vector3(v.shopcoord.x,v.shopcoord.y,v.shopcoord.z))
if distance < v.radius then
Expand All @@ -548,7 +549,6 @@ AddEventHandler('renzu_customs:openmenu', function()
SetCamActive(cam, true)
ControlCam('front',-2.5,0.1,1.3)
end
oldprop = GetVehicleProperties(vehicle)
SetModable(vehicle)
local livery = false
local vehicle_val = GetVehicleValue(GetEntityModel(vehicle)) * Config.VehicleValuePercent
Expand Down Expand Up @@ -620,11 +620,19 @@ AddEventHandler('renzu_customs:openmenu', function()
shop = k,
})
SetNuiFocus(true,true)
end)
end, NetworkGetNetworkIdFromEntity(vehicle), oldprop)
end
end
end)

RegisterNetEvent('renzu_customs:restoremod')
AddEventHandler('renzu_customs:restoremod', function(net,prop)
local ent = NetworkGetEntityFromNetworkId(net)
SetModable(ent)
SetVehicleProp(ent, prop)
print('restoring mod')
end)

RegisterNetEvent('renzu_customs:paint')
AddEventHandler('renzu_customs:paint', function(color,spray)
if not spray then
Expand Down
3 changes: 3 additions & 0 deletions client/nui_event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ RegisterNUICallback('Close', function(data, cb)
show = false,
})
inmark = false
TriggerServerEvent('renzu_customs:leaveshop')
end)

RegisterNUICallback('closedoor', function(data, cb)
Expand Down Expand Up @@ -269,6 +270,7 @@ RegisterNUICallback('pay', function(data, cb)
show = false,
})
inmark = false
TriggerServerEvent('renzu_customs:leaveshop')
else
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
Expand All @@ -291,6 +293,7 @@ RegisterNUICallback('pay', function(data, cb)
show = false,
})
inmark = false
TriggerServerEvent('renzu_customs:leaveshop')
end
end,t,currentprivate,GetVehicleClass(vehicle))
end)
Expand Down
19 changes: 18 additions & 1 deletion server/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,29 @@ RegisterServerCallBack_('renzu_customs:repair', function (source, cb, shop)
end
end)

RegisterServerCallBack_('renzu_customs:getmoney', function (source, cb, t)
local inshop = {}
RegisterServerCallBack_('renzu_customs:getmoney', function (source, cb, net, props)
local src = source
local xPlayer = GetPlayerFromId(src)
inshop[source] = {net = net , props = props}
cb(xPlayer.getMoney())
end)

RegisterServerEvent('playerDropped')
AddEventHandler('playerDropped', function(reason)
for k,v in pairs(inshop) do
if tonumber(source) == tonumber(k) then
TriggerClientEvent('renzu_customs:restoremod',-1 , v.net, v.props)
--DeleteEntity(v)
end
end
end)

RegisterServerEvent('renzu_customs:leaveshop')
AddEventHandler('renzu_customs:leaveshop', function()
inshop[source] = nil
end)

function GetVehicleNetWorkIdByPlate(plate,source,dist)
local source = source
for k,v in ipairs(GetAllVehicles()) do
Expand Down

0 comments on commit a4e1714

Please sign in to comment.