Deep thinker Posted November 11, 2016 Share Posted November 11, 2016 hello i have created a simple staff tag but i am using dxdrawtext to make it but it's bugged .it includes every time to have this tag when i am in the criminal team it draws the text. function renderStaffTag() local streamedPlayers = getElementsByType ("player", root, true) if getPlayerTeam(p) or getPlayerTeam(p) ~= getTeamFromName("Staff") then if streamedPlayers and #streamedPlayers ~= 0 then local lpos = {getElementPosition(localPlayer)} for _,p in ipairs (streamedPlayers) do if p and isElement (p) then local ppos = {getElementPosition(p)} if getDistanceBetweenPoints3D (lpos[1], lpos[2], lpos[3], ppos[1], ppos[2], ppos[3]) <= 20 then local x, y = getScreenFromWorldPosition (ppos[1], ppos[2], ppos[3]+1.2) if x and y then dxDrawText ("Staff Member", x+1, y+1, x, y, tocolor (0, 0, 0), 1, "pricedown", "center") dxDrawText ("Staff Member", x, y, x, y, tocolor (52, 0, 66), 1, "pricedown", "center") end end end end end end end addEventHandler ("onClientRender", root, renderStaffTag) Link to comment
LoPollo Posted November 11, 2016 Share Posted November 11, 2016 (edited) Line 3: if you have a team (and you said you were in criminal team) the condition is true and then the code is executed, check again that line Edit: i suggest you to fix the tabbings to align the ends to their respective statement if these are presents in your script Edited November 11, 2016 by LoPollo 1 Link to comment
Deep thinker Posted November 11, 2016 Author Share Posted November 11, 2016 29 minutes ago, LoPollo said: Line 3: if you have a team (and you said you were in criminal team) the condition is true and then the code is executed, check again that line Edit: i suggest you to fix the tabbings to align the ends to their respective statement if these are presents in your script i have checked the line 3, i have also edited it but there is a bug function renderStaffTag() local streamedPlayers = getElementsByType ("player", root, true) if not getPlayerTeam(p) or getPlayerTeam(p) ~= getTeamFromName("Staff") then return end if streamedPlayers and #streamedPlayers ~= 0 then local lpos = {getElementPosition(localPlayer)} for _,p in ipairs (streamedPlayers) do if p and isElement (p) then local ppos = {getElementPosition(p)} if getDistanceBetweenPoints3D (lpos[1], lpos[2], lpos[3], ppos[1], ppos[2], ppos[3]) <= 20 then local x, y = getScreenFromWorldPosition (ppos[1], ppos[2], ppos[3]+1.2) if x and y then dxDrawText ("Staff Member", x+1, y+1, x, y, tocolor (0, 0, 0), 1, "pricedown", "center") dxDrawText ("Staff Member", x, y, x, y, tocolor (52, 0, 66), 1, "pricedown", "center") end end end end end end addEventHandler ("onClientRender", root, renderStaffTag) now it doesn't draw anything . Link to comment
' A F . Posted November 11, 2016 Share Posted November 11, 2016 Use this : function renderStaffTag() local streamedPlayers = getElementsByType ("player", root, true) local lpos = {getElementPosition(localPlayer)} for _,p in ipairs (streamedPlayers) do if p and isElement (p) then if not getPlayerTeam(p) or getPlayerTeam(p) ~= getTeamFromName("Staff") then return end if streamedPlayers and #streamedPlayers ~= 0 then local ppos = {getElementPosition(p)} if getDistanceBetweenPoints3D (lpos[1], lpos[2], lpos[3], ppos[1], ppos[2], ppos[3]) <= 20 then local x, y = getScreenFromWorldPosition (ppos[1], ppos[2], ppos[3]+1.2) if x and y then dxDrawText ("Staff Member", x+1, y+1, x, y, tocolor (0, 0, 0), 1, "pricedown", "center") dxDrawText ("Staff Member", x, y, x, y, tocolor (52, 0, 66), 1, "pricedown", "center") end end end end end end addEventHandler ("onClientRender", root, renderStaffTag) 1 Link to comment
Deep thinker Posted November 11, 2016 Author Share Posted November 11, 2016 1 minute ago, Default said: Use this : function renderStaffTag() local streamedPlayers = getElementsByType ("player", root, true) local lpos = {getElementPosition(localPlayer)} for _,p in ipairs (streamedPlayers) do if p and isElement (p) then if not getPlayerTeam(p) or getPlayerTeam(p) ~= getTeamFromName("Staff") then return end if streamedPlayers and #streamedPlayers ~= 0 then local ppos = {getElementPosition(p)} if getDistanceBetweenPoints3D (lpos[1], lpos[2], lpos[3], ppos[1], ppos[2], ppos[3]) <= 20 then local x, y = getScreenFromWorldPosition (ppos[1], ppos[2], ppos[3]+1.2) if x and y then dxDrawText ("Staff Member", x+1, y+1, x, y, tocolor (0, 0, 0), 1, "pricedown", "center") dxDrawText ("Staff Member", x, y, x, y, tocolor (52, 0, 66), 1, "pricedown", "center") end end end end end end addEventHandler ("onClientRender", root, renderStaffTag) thank you ,it worked successfully Link to comment
' A F . Posted November 11, 2016 Share Posted November 11, 2016 you are welcome , any time 1 Link to comment
Deep thinker Posted November 11, 2016 Author Share Posted November 11, 2016 i will stay in touch with you in pm,if you don't mind. 1 minute ago, Default said: you are welcome , any time 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