Gallagher Posted February 5, 2014 Share Posted February 5, 2014 Hi ! WHAT I fix on line 1? error ↓ welcome.lua:1: attempt to call global 'guiGetScreenSize' (a nil value) local x,y,z = guiGetScreenSize() local alpha = 0 local fadeOut = true function showPlayerWelcomeMessage() addEventHandler( "onClientRender", root, showWelcomeMessage ) alpha = 0 fadeOut = true end function welcomeOnSpawn ( ) if source == localPlayer then showPlayerWelcomeMessage() end end addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), welcomeOnSpawn ) function showWelcomeMessage() local xOff = dxGetTextWidth ( 'San Andreas ', 1.2, 'bankgothic' ) local xp, yp, zp = getElementPosition () local mins, hour = getTime () if mins > 0 and mins < 10 then mins = '0'..tostring(mins) end local alivetime = getElementData(localPlayer, "alivetime") or 0 dxDrawText ( 'San Andreas\n'..getZoneName ( xp, yp, zp, true )..'\nВремя '..formatTimeFromMinutes(alivetime)..'\n'..tostring(mins)..':'..tostring(hour)..'', x-xOff, y-200, x,y, tocolor ( 255, 255, 255, alpha ), 1.2, 'bankgothic' ) if fadeIn then alpha = alpha-10 if alpha < 10 then fadeIn = false removeEventHandler( "onClientRender", root, showWelcomeMessage ) end end if fadeOut then alpha = alpha+5 if alpha > 245 then alpha = 255 setTimer ( function () fadeIn = true end, 3000, 1 ) fadeOut = false end end end Link to comment
h4x7o0r Posted February 5, 2014 Share Posted February 5, 2014 local x,y = guiGetScreenSize() -- resolution is e.g 800 x 600 etc. 'z' isn't used. Link to comment
myonlake Posted February 6, 2014 Share Posted February 6, 2014 local x,y = guiGetScreenSize() -- resolution is e.g 800 x 600 etc. 'z' isn't used. That wouldn't return a nil value on the whole function, especially because he's not even using the z variable. It's because you are running the code server-side. Renderable graphic functions are only available client-side for obvious reasons. Switch over to client-side by placing type="client" on your meta.xml script-node as follows. <meta> <script src="welcome.lua" type="client" /> </meta> Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now