-
Notifications
You must be signed in to change notification settings - Fork 14
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
This stops the errors that are within the standard Qbox recipe #12
Conversation
This returns the thread if the player is not logged in
This makes sure the thread returns if player is not logged in
remove unwanted wait time
Adding isLoggedIn variable. I forgot...
client/main.lua
Outdated
@@ -433,6 +433,7 @@ local function init() | |||
registerEnterRoof() | |||
registerExitRoof() | |||
|
|||
if not isLoggedIn then return end |
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.
So rather than blocking the zone creation if you don't match the job we should put the job check inside these respective zones. The onEnter and inside functions can have the if QBX.PlayerData.job.name ~= 'reporter' then return end
added to them to early return.
@@ -136,6 +137,7 @@ end) | |||
|
|||
CreateThread(function() | |||
while true do | |||
if not isLoggedIn then return end |
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.
if not isLoggedIn then return end | |
local function handleCamera() | |
CreateThread(function() | |
while holdingCam do | |
lib.requestAnimDict(camanimDict) | |
if not IsEntityPlayingAnim(cache.ped, camanimDict, camanimName, 3) then | |
TaskPlayAnim(cache.ped, camanimDict, camanimName, 1.0, -1, -1, 50, 0, 0, 0, 0) | |
end | |
DisablePlayerFiring(cache.playerId, true) | |
DisableControlAction(0,25, true) | |
DisableControlAction(0, 44, true) | |
DisableControlAction(0,37, true) | |
SetCurrentPedWeapon(cache.ped, `WEAPON_UNARMED`, true) | |
Wait(100) | |
end | |
end) | |
RegisterNetEvent('qbx_newsjob:client:toggleCam', function() | |
if QBX.PlayerData.job.name ~= 'reporter' then return end | |
if not holdingCam then | |
lib.requestModel(camModel) | |
local plyCoords = GetOffsetFromEntityInWorldCoords(cache.ped, 0.0, 0.0, -5.0) | |
local camspawned = CreateObject(camModel, plyCoords.x, plyCoords.y, plyCoords.z, 1, 1, 1) | |
Wait(1000) | |
local netid = ObjToNet(camspawned) | |
SetNetworkIdExistsOnAllMachines(netid, true) | |
NetworkSetNetworkIdDynamic(netid, true) | |
SetNetworkIdCanMigrate(netid, false) | |
AttachEntityToEntity(camspawned, cache.ped, GetPedBoneIndex(cache.ped, 28422), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 0, 1, 0, 1) | |
TaskPlayAnim(cache.ped, camanimDict, camanimName, 1.0, -1, -1, 50, 0, 0, 0, 0) | |
cam_net = netid | |
holdingCam = true | |
lib.showTextUI(Lang:t('info.weazle_overlay')) | |
handleCamera() | |
else | |
lib.hideTextUI() | |
ClearPedSecondaryTask(cache.ped) | |
DetachEntity(NetToObj(cam_net), 1, 1) | |
DeleteEntity(NetToObj(cam_net)) | |
cam_net = nil | |
holdingCam = false | |
end | |
end) |
So rather than return this thread early we should delay the thread creation until we actually need it. Something like this to replace everything in this area. Then do something similar for the other threads where
they get put them into functions and then call those functions as needed when you activate the camera/mic boom etc.
This will reduce the thread count as well as clean up the readability of this resource.
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.
You are correct. Making changes now..
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.
Just testing now
Remove wasted wait time
Target zones already check if player is logged in. Added extra isLoggedIn check to make sure before checking players job and then creating zones
A lot of weird things happening here, but newsjob isn't a high priority at all for me to care enough. |
Description
This returns the thread while the player is not logged in to stop any errors
So basically this has a couple looped threads that check for the players job to = "reporter". Now if the player is not logged in, it can not possibly get the player's job and/or any other data.
To fix this I simply returned all the threads if the player is not logged in, now this checking every ms so it should allow the thread to continue to run properly after the player has loaded its data properly.
I am sure there are better ways to do this but this needs slight optimization at some point anyway which I am in the process of doing at the moment. I hope this gets pushed for now. Thanks Qbox <3
Checklist