-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution for servers using esx_multicharacter #24
base: master
Are you sure you want to change the base?
Conversation
Added a fix to prevent player coordinates error when connecting. multicharacter is not recognized by the player immediately and this causes this error. SCRIPT ERROR: @dream-postal/client.lua:755: attempt to perform arithmetich on a nil value (upvalue 'POSTAL_BOSS_COORDS') > fn (@dream-postal/client.lua:755) You can improve it and adapt it to your programming style, I just added it to offer a solution!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some ideas for consideration. Overall I like the approach and this does sound annoying with esx having the game be spammed with trying to have player coords be indexed
@@ -1,3 +1,21 @@ | |||
FRAMEWORK = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of code is held globally within client_util.lua
, BUT i think it's loaded afterwards -> https://github.com/kylemcshea/dream-postal/blob/master/fxmanifest.lua#L18
So we can go with 1 of 2 routes
- Delete this block of code and within
fxmanifest.lua
we haveclient_util.lua
loaded up beforeclient.lua
'client_util.lua',
'client.lua',
- we delete this block of code from
client_util.lua
and leave everything as is. I'm down for either.
I'll leave the decision to you :) we just dont want duplicate blocks of code is the only thing we are looking to move from
isPedSpawned = true | ||
spawnPostalBossPed() | ||
end | ||
if (Config.FRAMEWORK == 'esx') then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change would break qb
compatibility. Here's what I propose to decouple and for us to be more pure
!
modify this thread to be
CreateThread(function()
local spawnFunction = Config.FRAMEWORK == 'qb' and handlePedSpawnQB or handlePedSpawnESX
while true do
Wait(2000)
spawnFunction()
end
end)
we make two functions
function handlePedSpawnESX()
local isLoaded = FRAMEWORK.IsPlayerLoaded()
if not isLoaded then
return
end
local playerCoords = GetEntityCoords(PlayerPedId())
local distanceFromPed = #(POSTAL_BOSS_COORDS - playerCoords)
if distanceFromPed < 200 and not isPedSpawned then
isPedSpawned = true
spawnPostalBossPed()
end
if postalBossPed and distanceFromPed >= 200 and isPedSpawned then
isPedSpawned = false
DeletePed(postalBossPed)
end
end
function handlePedSpawnQB()
local playerCoords = GetEntityCoords(PlayerPedId())
local distanceFromPed = #(POSTAL_BOSS_COORDS - playerCoords)
if distanceFromPed < 200 and not isPedSpawned then
isPedSpawned = true
spawnPostalBossPed()
end
if postalBossPed and distanceFromPed >= 200 and isPedSpawned then
isPedSpawned = false
DeletePed(postalBossPed)
end
end
Let me know your thoughts!
@Misha0717 If you see this notification would love for you to chime in and throw a second opinion :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good imo. But I should change the isPedSpawned
variable to DoesEntityExist(postalBossPed)
instead of a boolean. The functions should show like this.
function handlePedSpawnQB()
local playerCoords = GetEntityCoords(PlayerPedId())
local distanceFromPed = #(POSTAL_BOSS_COORDS - playerCoords)
local isPedSpawned = DoesEntityExist(postalBossPed)
if distanceFromPed < 200 and not isPedSpawned then
spawnPostalBossPed()
end
if distanceFromPed >= 200 and isPedSpawned then
DeletePed(postalBossPed)
end
end
I have never worked with multicharacter from ESX so I don't know if the fix of @lush0n3 so fix the issue. But if he tested it and it works fine I think this pr could be merged
Added a fix to prevent player coordinates error when connecting. multicharacter is not recognized by the player immediately and this causes this error.
SCRIPT ERROR: @dream-postal/client.lua:755: attempt to perform arithmetich on a nil value (upvalue 'POSTAL_BOSS_COORDS')
You can improve it and adapt it to your programming style, I just added it to offer a solution!