TorNix~|nR Posted December 11, 2016 Share Posted December 11, 2016 hello everyone, how can I made a one like this? I try and I failed help please? Link to comment
iPrestege Posted December 11, 2016 Share Posted December 11, 2016 Hi you can use : dxDrawTextOnElement Link to comment
TorNix~|nR Posted December 11, 2016 Author Share Posted December 11, 2016 can you help me please? how to use the acl in this if getPlayerTeam(v) == getTeamFromName("HassoN") then if v == localPlayer then return end ? Link to comment
TorNix~|nR Posted December 11, 2016 Author Share Posted December 11, 2016 hey I use this, and it doesn't work addEventHandler("onClientRender", getRootElement(), function () for k,v in ipairs(getElementsByType("player")) do if getPlayerTeam(v) == getTeamFromName("HassoN") then if v == localPlayer then return end dxDrawTextOnElement(v,"HassoN",1,20,0,0,255,255,1,"arial") end end end) Link to comment
ViRuZGamiing Posted December 12, 2016 Share Posted December 12, 2016 (edited) Remove if getPlayerTeam(v) == getTeamFromName("HassoN") then Edited December 12, 2016 by ViRuZGamiing Link to comment
TorNix~|nR Posted December 12, 2016 Author Share Posted December 12, 2016 I need it for some teams, and acls, not for all Link to comment
ViRuZGamiing Posted December 12, 2016 Share Posted December 12, 2016 1 hour ago, TorNix~|nR said: I need it for some teams, and acls, not for all then make sure the team name is indeed HassoN or change that Link to comment
EmBaby85 Posted December 12, 2016 Share Posted December 12, 2016 (edited) Use getElementPosition Edited December 12, 2016 by Rands Link to comment
itHyperoX Posted December 12, 2016 Share Posted December 12, 2016 u mean the "VIP" image? Link to comment
shaio Posted December 13, 2016 Share Posted December 13, 2016 (edited) On 12/11/2016 at 5:47 PM, TorNix~|nR said: hey I use this, and it doesn't work addEventHandler("onClientRender", getRootElement(), function ()for k,v in ipairs(getElementsByType("player")) do if getPlayerTeam(v) == getTeamFromName("HassoN") then if v == localPlayer then return end dxDrawTextOnElement(v,"HassoN",1,20,0,0,255,255,1,"arial") end endend) This is very bad, you're running a loop for every pixel that is rendered.. That would cause major lag issues especially if you have quite a bit of players on the server. This is a solution however it may not work, run this clientside. local root = getRootElement() local localPlayer = getLocalPlayer() local players = getElementsByType("player") -- Configuration local teams = true -- if you change this to false or anything else then you will use acl groups local moderator = "Mod" local superModerator = "SMod" -- These are just display names, you can change these to whatever you want. local admin = "OP" local console = "Owner" -- setTimer(function() for _,p in pairs(players) do local teamName = getTeamName(getPlayerTeam(p)) setElementData(p,"team",teamName) end end,1000,0) addEventHandler("onClientRender",root,function() if teams == true then local team = getElementData(localPlayer,"team") dxDrawTextOnElement(localPlayer,team,1,20,0,0,255,255,1,"arial") else local acc = getAccountName(getPlayerAccount(localPlayer)) if not isGuestAccount(getPlayerAccount(localPlayer)) then if (isObjectInACLGroup("user."..acc,aclGetGroup("Moderator"))) then dxDrawTextOnElement(localPlayer,moderator,1,20,0,0,255,255,1,"arial") elseif (isObjectInACLGroup("user."..acc,aclGetGroup("SuperModerator"))) then dxDrawTextOnElement(localPlayer,superModerator,1,20,0,0,255,255,1,"arial") elseif (isObjectInACLGroup("user."..acc,aclGetGroup("Admin"))) then dxDrawTextOnElement(localPlayer,admin,1,20,0,0,255,255,1,"arial") elseif (isObjectInACLGroup("user."..acc,aclGetGroup("Console"))) then dxDrawTextOnElement(localPlayer,console,1,20,0,0,255,255,1,"arial") end end end end) Edited December 13, 2016 by shaio Link to comment
TorNix~|nR Posted December 13, 2016 Author Share Posted December 13, 2016 not work any solutions please? attempt to call global 'dxDrawTextOnElement' (a nil value) @MilOG yes I mean that VIP, is not image, is a font Link to comment
tosfera Posted December 13, 2016 Share Posted December 13, 2016 (edited) Without reading anything in this topic, are you sure you're running the latest client and server version? Is the file set as a client sided file in your meta? (reading the post now) The function you're using is a useful function, which means you have to include the function from the wiki in your file. function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font,checkBuildings,checkVehicles,checkPeds,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getElementPosition(localPlayer) local distance = distance or 20 local height = height or 1 local checkBuildings = checkBuildings or true local checkVehicles = checkVehicles or false local checkPeds = checkPeds or false local checkObjects = checkObjects or true local checkDummies = checkDummies or true local seeThroughStuff = seeThroughStuff or false local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false local ignoredElement = ignoredElement or nil if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end end add that at the bottom or top from your file, I would go for top. Edited December 13, 2016 by tosfera Link to comment
TorNix~|nR Posted December 13, 2016 Author Share Posted December 13, 2016 (edited) working thanks! but this have much bugs, and the acl doesn't work, only the team (but with much bugs) can anyone help please? -- Configuration local teams = true -- if you change this to false or anything else then you will use acl groups local moderator = "Mod" local superModerator = "SMod" -- These are just display names, you can change these to whatever you want. local admin = "OP" local console = "Owner" -- setTimer(function() for _,p in pairs(players) do local teamName = getTeamName(getPlayerTeam(p)) setElementData(p,"team",teamName) end end,1000,0) addEventHandler("onClientRender",root,function() if teams == true then local team = getElementData(localPlayer,"team") dxDrawTextOnElement(localPlayer,team,1,20,0,0,255,255,1,"arial") else local acc = getAccountName(getPlayerAccount(localPlayer)) if not isGuestAccount(getPlayerAccount(localPlayer)) then if (isObjectInACLGroup("user."..acc,aclGetGroup("Moderator"))) then dxDrawTextOnElement(localPlayer,moderator,1,20,0,0,255,255,1,"arial") elseif (isObjectInACLGroup("user."..acc,aclGetGroup("SuperModerator"))) then dxDrawTextOnElement(localPlayer,superModerator,1,20,0,0,255,255,1,"arial") elseif (isObjectInACLGroup("user."..acc,aclGetGroup("Admin"))) then dxDrawTextOnElement(localPlayer,admin,1,20,0,0,255,255,1,"arial") elseif (isObjectInACLGroup("user."..acc,aclGetGroup("Console"))) then dxDrawTextOnElement(localPlayer,console,1,20,0,0,255,255,1,"arial") end end end end) I need just that, for acls no need teams, for example for VIP ACL: a VIP tag, like that photo I try so much, but I can not help? Edited December 13, 2016 by TorNix~|nR Link to comment
iPrestege Posted December 13, 2016 Share Posted December 13, 2016 You are running both client and server functions in the server i guess? or in client? isObjectInACLGroup is a server side function dxDraw is a client so make a data. Link to comment
tosfera Posted December 13, 2016 Share Posted December 13, 2016 You're almost trying to kill the client there, seriously.. don't work like that. Better use these steps; player logs in/joins the server set their data (their acl group OR a default group), something like: 'rank' in the onClientRender, loop through the players, get their rank once you got their rank, get the correct render name (make it an array/table and read it from there for ease) you're done. Link to comment
shaio Posted December 14, 2016 Share Posted December 14, 2016 Try this instead, less buggy, uses less ram, and uses element data. Figured it would be just what you're looking for. -------- Serverside -------- local root = getRootElement() -- Configuration teams = true -- if you change this to false or anything else then you will use acl groups ranks = { {name = "VIP"} } -- addEventHandler("onPlayerLogin",root,function() local teamName = getTeamName(getPlayerTeam(source)) setAccountData(getPlayerAccount(source),"team",teamName) local acc = getAccountName(getPlayerAccount(source)) for _,rank in pairs(ranks) do if not isGuestAccount(getPlayerAccount(source)) then if (isObjectInACLGroup("user."..acc,aclGetGroup(rank.name))) then setAccountData(getPlayerAccount(source),"acl",rank.name) end end end end) ---------------------------- -------- Clientside -------- local root = getRootElement() addEventHandler("onClientRender",root,function() if teams == true then local team = getElementData(localPlayer,"team") if team then dxDrawTextOnElement(localPlayer,team,1,20,0,0,255,255,1,"arial") end else local acc = getAccountName(getPlayerAccount(localPlayer)) local rank = getAccountData(getPlayerAccount(localPlayer),"acl") if not isGuestAccount(getPlayerAccount(localPlayer)) then if rank then if (isObjectInACLGroup("user."..acc,aclGetGroup(rank)) then dxDrawTextOnElement(localPlayer,rank,1,20,0,0,255,255,1,"arial") end end end end end) ---------------------------- Link to comment
shaio Posted December 14, 2016 Share Posted December 14, 2016 This is if u want to use team colors instead of custom ones. local r,g,b = getTeamColor(getTeamFromName(team)) if team then dxDrawTextOnElement(localPlayer,team,1,20,r,g,b,255,1,"arial") Link to comment
iPrestege Posted December 14, 2016 Share Posted December 14, 2016 @shaio You still using server functions in the client side that isn't going to work. Use set get element data instead of account data. Link to comment
TorNix~|nR Posted December 14, 2016 Author Share Posted December 14, 2016 @shaio sorry, but your code doesn't work Link to comment
iPrestege Posted December 14, 2016 Share Posted December 14, 2016 (edited) aMyGroups = { 'Console','Admin','Moderator' }; addEventHandler ( 'onPlayerLogin',root, function ( _,aMyAccount ) if isGuestAccount ( aMyAccount ) then return end; for _,aGroup in next,aMyGroups do if isObjectInACLGroup ( 'user.'..getAccountName ( aMyAccount ),aclGetGroup ( aGroup ) ) then setElementData ( source,'aDrawMyText',true ); end break end end ); -- On Client Side dxDrawTextOnElement = function (TheElement,text,height,distance,R,G,B,alpha,size,font,checkBuildings,checkVehicles,checkPeds,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getElementPosition(localPlayer) local distance = distance or 20 local height = height or 1 local checkBuildings = checkBuildings or true local checkVehicles = checkVehicles or false local checkPeds = checkPeds or false local checkObjects = checkObjects or true local checkDummies = checkDummies or true local seeThroughStuff = seeThroughStuff or false local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false local ignoredElement = ignoredElement or nil if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end end addEventHandler ( 'onClientRender',root, function ( ) if getElementData ( localPlayer,'aDrawMyText' ) or getPlayerTeam ( localPlayer ) == getTeamFromName ( 'aMyTeamName' ) then dxDrawTextOnElement ( localPlayer,'Staff Member',1,10,255,0,0,255,1 ) end end ) -- PS. You have to login again also change the team name in line 3 in render function.GL. PS. First code with orange functions is in server side! @shaio Edited December 14, 2016 by iPrestege Typo Link to comment
TorNix~|nR Posted December 14, 2016 Author Share Posted December 14, 2016 is working, but everyone get that tag, not only that acls Link to comment
shaio Posted December 15, 2016 Share Posted December 15, 2016 I know my script doesn't work, I've been working on it, I have never tested it so I didn't expect it to work. The next code I upload will be fully customizable and it will work. Thank you for your patience. Link to comment
TorNix~|nR Posted December 15, 2016 Author Share Posted December 15, 2016 Okey, will wait, and thanks too much ^^ Link to comment
shaio Posted December 15, 2016 Share Posted December 15, 2016 (edited) 7 hours ago, TorNix~|nR said: Okey, will wait, and thanks too much ^^ Okay this script is tested and fully functional, almost fully customizable as well. Your tag will not display for you, but it will for other players. Best of luck to you. I hope this is what you were looking for. If there is anything else you want added, let me know. server.lua - -------- Serverside -------- local root = getRootElement() -- Configuration teams = false -- Turning this to false will make the text acl group names. Turning it to true will use team names. teamColor = true --[[ If teams are on and this is false the tags will be black. If teams are off and this is off, you will use acl colors in the ranks table. If this is on and teams are off, you will use the players team color but with the acl tag.]] ranks = { -- Do not add a console rank it might screw things up.. {id = "Everyone",r = 255,g = 255,b = 255}, -- < You need this rank or else the tag will display as false. I've made it display "Player". {id = "Moderator",r = 0,g = 255,b = 0}, {id = "SuperModerator",r = 0,g = 255,b = 255}, {id = "Admin",r = 0,g = 0,b = 255} } -- addEventHandler("onResourceStart",root,function() for _,plr in pairs(getElementsByType("player")) do if teams == true then local team = getTeamName(getPlayerTeam(plr)) local r,g,b = getTeamColor(getPlayerTeam(plr)) if team then setElementData(plr,"text",team) if teamColor == true then setElementData(plr,"r",r) setElementData(plr,"g",g) setElementData(plr,"b",b) else setElementData(plr,"r",0) setElementData(plr,"g",0) setElementData(plr,"b",0) end end else local acc = getAccountName(getPlayerAccount(plr)) if not isGuestAccount(getPlayerAccount(plr)) then for _,rank in pairs(ranks) do if (isObjectInACLGroup("user."..acc,aclGetGroup(rank.id))) then if teamColor == true then local r,g,b = getTeamColor(getPlayerTeam(plr)) setElementData(plr,"r",r) setElementData(plr,"g",g) setElementData(plr,"b",b) else setElementData(plr,"r",rank.r) setElementData(plr,"g",rank.g) setElementData(plr,"b",rank.b) end if rank.id == "Everyone" then setElementData(plr,"text","Player") else setElementData(plr,"text",rank.id) end end end end end end end) addEventHandler("onPlayerLogin",root,function() if teams == true then local team = getTeamName(getPlayerTeam(source)) local r,g,b = getTeamColor(getPlayerTeam(source)) if team then setElementData(source,"text",team) if teamColor == true then setElementData(source,"r",r) setElementData(source,"g",g) setElementData(source,"b",b) else setElementData(source,"r",0) setElementData(source,"g",0) setElementData(source,"b",0) end end else local acc = getAccountName(getPlayerAccount(source)) if not isGuestAccount(getPlayerAccount(source)) then for _,rank in pairs(ranks) do if (isObjectInACLGroup("user."..acc,aclGetGroup(rank.id))) then if teamColor == true then local r,g,b = getTeamColor(getPlayerTeam(source)) setElementData(source,"r",r) setElementData(source,"g",g) setElementData(source,"b",b) else setElementData(source,"r",rank.r) setElementData(source,"g",rank.g) setElementData(source,"b",rank.b) end if rank.id == "Everyone" then setElementData(source,"text","Player") else setElementData(source,"text",rank.id) end end end end end end) ---------------------------- client.lua - -------- Clientside -------- local root = getRootElement() local localPlayer = getLocalPlayer() local height = 1.2 -- You can change this to say how high you want it above the player. function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font,checkBuildings,checkVehicles,checkPeds,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getElementPosition(localPlayer) local distance = distance or 20 local height = height or 1 local checkBuildings = checkBuildings or true local checkVehicles = checkVehicles or false local checkPeds = checkPeds or false local checkObjects = checkObjects or true local checkDummies = checkDummies or true local seeThroughStuff = seeThroughStuff or false local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false local ignoredElement = ignoredElement or nil if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end end addEventHandler("onClientRender",root,function() for _,plr in pairs(getElementsByType("player")) do if plr ~= localPlayer then local r,g,b = getElementData(plr,"r"),getElementData(plr,"g"),getElementData(plr,"b") dxDrawTextOnElement(plr,tostring(getElementData(plr,"text")),height,30,r,g,b,255,1.5,"arial") end end end) ---------------------------- Edited December 15, 2016 by shaio Link to comment
shaio Posted December 16, 2016 Share Posted December 16, 2016 Use this server.lua instead, it's less code. -------- Serverside -------- local root = getRootElement() -- Configuration teams = true -- Turning this to false will make the text acl group names. Turning it to true will use team names. teamColor = true --[[ If teams are on and this is false the tags will be black. If teams are off and this is off, you will use acl colors in the ranks table. If this is on and teams are off, you will use the players team color but with the acl tag.]] ranks = { -- Do not add a console rank it might screw things up.. {id = "Everyone",r = 255,g = 255,b = 255}, -- < You need this rank or else the tag will display as false. I've made it display "Player". {id = "Moderator",r = 0,g = 255,b = 0}, {id = "SuperModerator",r = 0,g = 255,b = 255}, {id = "Admin",r = 0,g = 0,b = 255} } -- setTimer(function() for _,plr in pairs(getElementsByType("player")) do if teams == true then local team = getTeamName(getPlayerTeam(plr)) local r,g,b = getTeamColor(getPlayerTeam(plr)) if team then setElementData(plr,"text",team) if teamColor == true then setElementData(plr,"r",r) setElementData(plr,"g",g) setElementData(plr,"b",b) else setElementData(plr,"r",0) setElementData(plr,"g",0) setElementData(plr,"b",0) end end else local acc = getAccountName(getPlayerAccount(plr)) if not isGuestAccount(getPlayerAccount(plr)) then for _,rank in pairs(ranks) do if (isObjectInACLGroup("user."..acc,aclGetGroup(rank.id))) then if teamColor == true then local r,g,b = getTeamColor(getPlayerTeam(plr)) setElementData(plr,"r",r) setElementData(plr,"g",g) setElementData(plr,"b",b) else setElementData(plr,"r",rank.r) setElementData(plr,"g",rank.g) setElementData(plr,"b",rank.b) end if rank.id == "Everyone" then setElementData(plr,"text","Player") else setElementData(plr,"text",rank.id) end end end end end end end,1000,0) ---------------------------- 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