Mefisto_PL Posted January 26, 2014 Posted January 26, 2014 Hi, I made code which shows how many players is alive, it was working, but now it doesn't.. Debugscript: "@bad argument 'dxDrawText'' [expected number at argument 16, got boolean]". - but wtf, there is no needed number.. Here is a code: bnt_font = dxCreateFont ( "fonts/bnt.ttf", 20 ) function aliveplayers ( ) local screenWidth, screenHeight = guiGetScreenSize() dxDrawText ( '#006699ALIVE: #FFFFFF' .. tonumber(getRaceAlivePlayers ( )), 2, screenHeight - dxGetFontHeight(0.7, bnt_font)/0.5, 0.5, 1.5, tocolor ( 255, 255, 255, 255 ), 0.9, bnt_font, 'left', 'top', false, false, false, true, false, false) end addEventHandler ( "onClientRender", getRootElement(), aliveplayers ) function getRaceAlivePlayers ( ) local players = 0 for _, player in ipairs ( getElementsByType ( "player" ) ) do if ( getElementData ( player, "state" ) == "alive" ) then players = ( players + 1 ) end end return players end
Memory Posted January 26, 2014 Posted January 26, 2014 Try bnt_font = dxCreateFont ( "fonts/bnt.ttf", 20 ) function aliveplayers ( ) local screenWidth, screenHeight = guiGetScreenSize() dxDrawText ( '#006699ALIVE: #FFFFFF' .. tonumber(getRaceAlivePlayers ( )), 2, screenHeight - dxGetFontHeight(0.7, bnt_font)/0.5, 0.5, 1.5, tocolor ( 255, 255, 255, 255 ), 0.9, bnt_font, 'left', 'top', false, false, false, true, false) end addEventHandler ( "onClientRender", getRootElement(), aliveplayers ) function getRaceAlivePlayers ( ) local players = 0 for _, player in ipairs ( getElementsByType ( "player" ) ) do if ( getElementData ( player, "state" ) == "alive" ) then players = ( players + 1 ) end end return players end Ingame name: [sV]Kostya Name in scripts: Kostya
DNL291 Posted January 26, 2014 Posted January 26, 2014 getRaceAlivePlayers already returns a number. Also, i think you should to use tostring instead. bnt_font = dxCreateFont ( "fonts/bnt.ttf", 20 ) function aliveplayers ( ) local screenWidth, screenHeight = guiGetScreenSize() dxDrawText ( '#006699ALIVE: #FFFFFF' .. tostring(getRaceAlivePlayers ( )), 2, screenHeight - dxGetFontHeight(0.7, bnt_font)/0.5, 0.5, 1.5, tocolor ( 255, 255, 255, 255 ), 0.9, bnt_font, 'left', 'top', false, false, false, true) end addEventHandler ( "onClientRender", getRootElement(), aliveplayers ) function getRaceAlivePlayers ( ) local players = 0 for _, player in ipairs ( getElementsByType ( "player" ) ) do if ( getElementData ( player, "state" ) == "alive" ) then players = ( players + 1 ) end end return players end Please do not PM me with scripting related question nor support, use the forums instead.
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