mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-18 06:16:02 +01:00
update: events and checks
This commit is contained in:
@@ -1,21 +1,30 @@
|
|||||||
RegisterNetEvent("ND:returnCharacters", function(characters)
|
|
||||||
NDCore.Characters = characters
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- updates the money on the client.
|
-- updates the money on the client.
|
||||||
RegisterNetEvent("ND:updateMoney", function(cash, bank)
|
RegisterNetEvent("ND:updateMoney", function(cash, bank)
|
||||||
|
if not NDCore.player then return end
|
||||||
NDCore.player.cash = cash
|
NDCore.player.cash = cash
|
||||||
NDCore.player.bank = bank
|
NDCore.player.bank = bank
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local function removeCharacterFunctions(character)
|
||||||
|
local newData = {}
|
||||||
|
for k, v in pairs(character) do
|
||||||
|
if type(v) ~= "function" then
|
||||||
|
newData[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return newData
|
||||||
|
end
|
||||||
|
|
||||||
-- Sets main character.
|
-- Sets main character.
|
||||||
RegisterNetEvent("ND:setCharacter", function(character)
|
RegisterNetEvent("ND:characterLoaded", function(character)
|
||||||
NDCore.player = character
|
if not NDCore.player then return end
|
||||||
|
NDCore.player = removeCharacterFunctions(character)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Update main character info.
|
-- Update main character info.
|
||||||
RegisterNetEvent("ND:updateCharacter", function(character)
|
RegisterNetEvent("ND:updateCharacter", function(character)
|
||||||
NDCore.player = character
|
if not NDCore.player then return end
|
||||||
|
NDCore.player = removeCharacterFunctions(character)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Updates last lcoation.
|
-- Updates last lcoation.
|
||||||
@@ -23,10 +32,3 @@ RegisterNetEvent("ND:updateLastLocation", function(location)
|
|||||||
if not NDCore.player then return end
|
if not NDCore.player then return end
|
||||||
NDCore.player.lastLocation = location
|
NDCore.player.lastLocation = location
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Enable pvp for players.
|
|
||||||
AddEventHandler("playerSpawned", function()
|
|
||||||
print("^0ND Framework support discord: ^5https://discord.gg/Z9Mxu72zZ6")
|
|
||||||
SetCanAttackFriendly(PlayerPedId(), true, false)
|
|
||||||
NetworkSetFriendlyFireOption(true)
|
|
||||||
end)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user