Added Some More Stuff

This commit is contained in:
MiddleSkillz
2021-05-05 01:18:20 -06:00
parent 77f34b0176
commit 8f91023bd9
3 changed files with 26 additions and 32 deletions
+17 -24
View File
@@ -10,38 +10,24 @@ end)
RegisterNetEvent('esx:playerLoaded') RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(playerData) AddEventHandler('esx:playerLoaded', function(playerData, isNew)
ESX.PlayerLoaded = true ESX.PlayerLoaded = true
ESX.PlayerData = playerData ESX.PlayerData = playerData
if GetEntityModel(PlayerPedId()) == GetHashKey('PLAYER_ZERO') then
local defaultModel = GetHashKey('a_m_y_stbla_02')
RequestModel(defaultModel)
while not HasModelLoaded(defaultModel) do
Citizen.Wait(10)
end
SetPlayerModel(PlayerId(), defaultModel)
SetPedDefaultComponentVariation(PlayerPedId())
SetPedRandomComponentVariation(PlayerPedId(), true)
SetModelAsNoLongerNeeded(defaultModel)
end
FreezeEntityPosition(PlayerPedId(), true) FreezeEntityPosition(PlayerPedId(), true)
-- enable PVP -- enable PVP
if Config.EnablePVP then if Config.EnablePVP then
SetCanAttackFriendly(PlayerPedId(), true, false) SetCanAttackFriendly(PlayerPedId(), true, false)
NetworkSetFriendlyFireOption(true) NetworkSetFriendlyFireOption(true)
end end
-- disable wanted level -- disable wanted level
if not Config.EnableWantedLevel then if not Config.EnableWantedLevel then
ClearPlayerWantedLevel(PlayerId()) ClearPlayerWantedLevel(PlayerId())
SetMaxWantedLevel(0) SetMaxWantedLevel(0)
end end
if Config.EnableHud then if Config.EnableHud then
for k,v in ipairs(playerData.accounts) do for k,v in ipairs(playerData.accounts) do
@@ -61,11 +47,13 @@ end
}) })
end end
ESX.Game.Teleport(PlayerPedId(), { exports.spawnmanager:spawnPlayer({
x = playerData.coords.x, x = playerData.coords.x,
y = playerData.coords.y, y = playerData.coords.y,
z = playerData.coords.z + 0.25, z = playerData.coords.z + 0.25,
heading = playerData.coords.heading heading = playerData.coords.heading,
model = Config.DefaultPlayerModel,
skipFade = false
}, function() }, function()
TriggerServerEvent('esx:onPlayerSpawn') TriggerServerEvent('esx:onPlayerSpawn')
TriggerEvent('esx:onPlayerSpawn') TriggerEvent('esx:onPlayerSpawn')
@@ -78,6 +66,11 @@ end
FreezeEntityPosition(PlayerPedId(), false) FreezeEntityPosition(PlayerPedId(), false)
DoScreenFadeIn(10000) DoScreenFadeIn(10000)
StartServerSyncLoops() StartServerSyncLoops()
if isNew then
-- Put your code for if you want to do something with new players.
else
-- If they aren't new put that code here.
end
end) end)
TriggerEvent('esx:loadingScreenOff') TriggerEvent('esx:loadingScreenOff')
+5 -4
View File
@@ -12,9 +12,10 @@ Config.StartingAccountMoney = {bank = 50000}
Config.EnableSocietyPayouts = false -- pay from the society account that the player is employed at? Requirement: esx_society Config.EnableSocietyPayouts = false -- pay from the society account that the player is employed at? Requirement: esx_society
Config.EnableHud = true -- enable the default hud? Display current job and accounts (black, bank & cash) Config.EnableHud = true -- enable the default hud? Display current job and accounts (black, bank & cash)
Config.MaxWeight = 24 -- the max inventory weight without backpack Config.MaxWeight = 24 -- the max inventory weight without backpack
Config.PaycheckInterval = 7 * 60000 -- how often to recieve pay checks in milliseconds Config.PaycheckInterval = 7 * 60000 -- how often to recieve pay checks in milliseconds
Config.EnableDebug = false -- Use Debug options? Config.EnableDebug = false -- Use Debug options?
Config.EnableDefaultInventory = true -- Display the default Inventory ( F2 ) Config.EnableDefaultInventory = true -- Display the default Inventory ( F2 )
Config.EnableWantedLevel = false -- Use Normal GTA wanted Level? Config.EnableWantedLevel = false -- Use Normal GTA wanted Level?
Config.EnablePVP = true -- Allow Player to player combat Config.EnablePVP = true -- Allow Player to player combat
Config.DefaultPlayerModel = `mp_m_freemode_01` -- Don't Change this there is absolutely no need
+4 -4
View File
@@ -29,7 +29,7 @@ function onPlayerJoined(playerId)
['@identifier'] = identifier ['@identifier'] = identifier
}, function(result) }, function(result)
if result then if result then
loadESXPlayer(identifier, playerId) loadESXPlayer(identifier, playerId, false)
else else
local accounts = {} local accounts = {}
@@ -49,7 +49,7 @@ function onPlayerJoined(playerId)
['@identifier'] = identifier, ['@identifier'] = identifier,
['@group'] = defaultGroup ['@group'] = defaultGroup
}, function(rowsChanged) }, function(rowsChanged)
loadESXPlayer(identifier, playerId) loadESXPlayer(identifier, playerId, true)
end) end)
end end
end) end)
@@ -83,7 +83,7 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals)
end end
end) end)
function loadESXPlayer(identifier, playerId) function loadESXPlayer(identifier, playerId, isNew)
local tasks = {} local tasks = {}
local userData = { local userData = {
@@ -235,7 +235,7 @@ function loadESXPlayer(identifier, playerId)
loadout = xPlayer.getLoadout(), loadout = xPlayer.getLoadout(),
maxWeight = xPlayer.getMaxWeight(), maxWeight = xPlayer.getMaxWeight(),
money = xPlayer.getMoney() money = xPlayer.getMoney()
}) }, isNew)
xPlayer.triggerEvent('esx:createMissingPickups', ESX.Pickups) xPlayer.triggerEvent('esx:createMissingPickups', ESX.Pickups)
xPlayer.triggerEvent('esx:registerSuggestions', ESX.RegisteredCommands) xPlayer.triggerEvent('esx:registerSuggestions', ESX.RegisteredCommands)