[Dev-Resource] Mythic Notifications

ESX.StartPayCheck = function()

	function payCheck()
		local xPlayers = ESX.GetPlayers()

		for i=1, #xPlayers, 1 do
			local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
			local job     = xPlayer.job.grade_name
			local salary  = xPlayer.job.grade_salary

			if salary > 0 then
				if job == 'unemployed' then -- unemployed
					xPlayer.addAccountMoney('bank', salary)
					TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = _U('received_salary', salary)})
				elseif Config.EnableSocietyPayouts then -- possibly a society
					TriggerEvent('esx_society:getSociety', xPlayer.job.name, function (society)
						if society ~= nil then -- verified society
							TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function (account)
								if account.money >= salary then -- does the society money to pay its employees?
									xPlayer.addAccountMoney('bank', salary)
									account.removeMoney(salary)
	
									TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = _U('received_salary', salary)})
								else
									TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = _U('received_salary', salary)})
								end
							end)
						else -- not a society
							xPlayer.addAccountMoney('bank', salary)
							TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = _U('received_salary', salary)})
						end
					end)
				else -- generic job
					xPlayer.addAccountMoney('bank', salary)
					TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = _U('received_salary', salary)})
				end
			end

		end

		SetTimeout(Config.PaycheckInterval, payCheck)

	end

	SetTimeout(Config.PaycheckInterval, payCheck)

end

1 Like

Does anyone know how to resolve notifications appearing twice?

Can you share a screenshot?

RegisterCommand('tweet', function(source, args, rawCommand)
    --TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'error', text = 'Twitter is only available through the phone!', length = 2500, style = { ['background-color'] = '#ff0000' } })
    TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = 'Twitter is only available through the phone!' } )
end, true)```

Did you put the notification code into both Client and Server lua? If yes take the Client or Server side out and you should be fine

No, just through server side.

Are you getting double notifications on everything? Any errors in console? I’ve experienced this before when I had an old export (DoHudText) floating around in another resource. Track it down and change it if that is the case.

Not on everything. Just some things, mainly when it’s paid stuff.

I would have to see the code to be able to help any further honestly. If it isn’t due to having mythic_notify in client and server lua then my next guess would be either what UpTime said or that in the server.lua there are multiple notification spots with different wording for the notifications and maybe you accidently put the same notification in 2 spots when one should be for a different worded notification so it is triggering twice. I would say just post the file so we can look at it and give you more than guesses

So I am trying to implement this with the esx_duty script for when officers go on/off duty just as a simple start to learning on how to implement this to all my other scripts. How would I implement this into an en.lua script? Thank you!

you won’t use your en.lua, you will use the Server > server.lua and look for something like esx.shownotification and you will replace that with the server side example given in the post. You will only use the en.lua to add into the notification like if you want it to say Officer Name is on duty.

add top: somenumber%; somewhere in the container

Hey sorry for some reason I just got the notification for this. Did you manage to solve the issue?

Nope, just left it with the double notifications.

If you stop the script with the notification in it, what happens if you try and tweet? Does the notification just not work or does only one pop up?

how i can change line?

citizen:/scripting/lua/scheguler.lua924 dohudtext in resource ls_notify

I have the same issue do you know how to fix it?

1 Like

If you are receiving a error referring to No such export DoHudText, check the client.lua file in the addon that is giving you issues. Change exports[‘mythic_notify’]:DoHudText (‘success’, to exports[‘mythic_notify’]:SendAlert(‘success’, Just replace DoHudText to SendAlert. DoHudText is not supported, I believe it was used in the early release mythic_notifications, not mythic_notify. That goes for any resource that may use the line. You will need to manually change it.