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

[Request] setEffectDensity() to maximum instead of "density out of bounds" debug message #785

Einheit-101 opened this Issue Jan 20, 2019 · 2 comments


None yet
3 participants
Copy link

Einheit-101 commented Jan 20, 2019

(Moved from
setEffectDensity can return a debug warning about "density out of bounds" when a player has low fx settings set.

To reproduce
local x, y, z = getElementPosition(localPlayer)
local effect = createEffect("camflash", x, y, z, 0, 0, 0, 300)
setEffectDensity (effect, 2)

Will output a debug message if you are using low or medium fx setting.

Expected behaviour
Instead of a debug warning it should just set it to the max that is allowed for the current graphic setting.


Latest MTA Nightly

Additional context
FX setting - maximum effect density without outputting debug warning
Low ---------- 1
Medium ----- 1.5
High --------- 2
Very High --- 2

Current workaround that only causes 1 debug message when joining:

local maxDensity = 2
function onStart()
if not setEffectDensity(createEffect("camflash", 0, 0, 0), maxDensity) then
maxDensity = 1
addEventHandler("onClientResourceStart", resourceRoot, onStart)


This comment has been minimized.

Copy link

forkerer commented Jan 20, 2019

While it's not a fix, here's what we use on our server to mitigate this issue:

_setEffectDensity = setEffectDensity
function setEffectDensity(effect, density)
	local stat = dxGetStatus()
	if stat then
		local fx = stat.SettingFXQuality
		if fx then
			if tostring(fx) == "0" then
				density = math.min(1, density)
			elseif tostring(fx) == "1" then
				density = math.min (1.5, density)
	return _setEffectDensity(effect, density)

This comment has been minimized.

Copy link

Einheit-101 commented Jan 20, 2019

Didnt know that. Good idea. Thx.

@botder botder added the enhancement label Jan 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment