Minotaur Posted June 13, 2013 Share Posted June 13, 2013 function drawTag( size, font, colorCode, teamColor, cR, cG, cB ) local scx, scy = guiGetScreenSize() local max_distance = 20 local max_width = 100 local max_height = 10 local height_sub = 320 for i, player in pairs( getElementsByType("player") ) do local px, py, pz = getElementPosition(player) local cx, cy, cz = getCameraMatrix() local sx, sy = getScreenFromWorldPosition(px, py, pz) local dis = getDistanceBetweenPoints3D(px, py, pz, cx, cy, cz) local alpha = 255 - ( 255/max_distance*dis ) if ( alpha <= 0 ) then alpha = 0 end if ( sx and sy and scx and scy ) then local health = getElementHealth( player ) if ( health < 0 ) then health = 0 elseif ( health > 100 ) then health = 100 end local new_height_sub = height_sub - height_sub/max_distance*dis-40 local x, y, z = getElementPosition( localPlayer ) local ptx, pty, ptz = getElementPosition( player ) local team = getPlayerTeam( player ) if ( team ) then r, g, b = getTeamColor( team ) rgbR, rgbG, rgbB = r, g, b else rgbR, rgbG, rgbB = 255, 255, 255 end if ( teamColor ) then if health > 0 then dxDrawText(getPlayerName( player ), sx, sy-new_height_sub, sx, sy-new_height_sub, tocolor( rgbR,rgbG,rgbB,alpha ), size, font, "center", "center", true, true, true, colorCode) end else if health > 0 then dxDrawText(getPlayerName( player ), sx, sy-new_height_sub, sx, sy-new_height_sub, tocolor( cR, cG, cB,alpha ), size, font, "center", "center", true, true, true, colorCode) end end end end end This script is not good anybody help me please. and i want command:drawtag Link to comment
xXMADEXx Posted June 13, 2013 Share Posted June 13, 2013 Errors? and addCommandHandler ( "drawtag", drawTag ) -- Change: function drawTag( size, font, colorCode, teamColor, cR, cG, cB ) -- To: function drawTag( player, cmd, size, font, colorCode, teamColor, cR, cG, cB ) Link to comment
Minotaur Posted June 13, 2013 Author Share Posted June 13, 2013 function drawTag( player, cmd, size, font, colorCode, teamColor, cR, cG, cB ) local scx, scy = guiGetScreenSize() local max_distance = 20 local max_width = 100 local max_height = 10 local height_sub = 320 for i, player in pairs( getElementsByType("player") ) do local px, py, pz = getElementPosition(player) local cx, cy, cz = getCameraMatrix() local sx, sy = getScreenFromWorldPosition(px, py, pz) local dis = getDistanceBetweenPoints3D(px, py, pz, cx, cy, cz) local alpha = 255 - ( 255/max_distance*dis ) if ( alpha <= 0 ) then alpha = 0 end if ( sx and sy and scx and scy ) then local health = getElementHealth( player ) if ( health < 0 ) then health = 0 elseif ( health > 100 ) then health = 100 end local new_height_sub = height_sub - height_sub/max_distance*dis-40 local x, y, z = getElementPosition( localPlayer ) local ptx, pty, ptz = getElementPosition( player ) local team = getPlayerTeam( player ) if ( team ) then r, g, b = getTeamColor( team ) rgbR, rgbG, rgbB = r, g, b else rgbR, rgbG, rgbB = 255, 255, 255 end if ( teamColor ) then if health > 0 then dxDrawText(getPlayerName( player ), sx, sy-new_height_sub, sx, sy-new_height_sub, tocolor( rgbR,rgbG,rgbB,alpha ), size, font, "center", "center", true, true, true, colorCode) end else if health > 0 then dxDrawText(getPlayerName( player ), sx, sy-new_height_sub, sx, sy-new_height_sub, tocolor( cR, cG, cB,alpha ), size, font, "center", "center", true, true, true, colorCode) end end end end end addCommandHandler ( "drawtag", drawTag ) Not good Link to comment
xXMADEXx Posted June 13, 2013 Share Posted June 13, 2013 Any errors? (By the way, I notice that you're trying to do A LOT of projects at once. I would just recommend to try to keep it down to 1 or 2 at a time, not like 7 or 8.) Link to comment
DiSaMe Posted June 13, 2013 Share Posted June 13, 2013 Since the script is client-side and the clients are not aware of commands typed in by other clients, client-side command handlers don't have the player argument: function drawTag( cmd, size, font, colorCode, teamColor, cR, cG, cB ) (By the way, I notice that you're trying to do A LOT of projects at once. I would just recommend to try to keep it down to 1 or 2 at a time, not like 7 or 8.) I don't agree. For a scripting beginner, it's good to experiment with many different things before focusing on a single project. 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