TorNix~|nR

Name of player

Recommended Posts

can you help me please? how to use the acl in this

		if getPlayerTeam(v) == getTeamFromName("HassoN") then
			if v == localPlayer then return end

?

Share this post


Link to post
On 12/11/2016 at 5:47 PM, TorNix~|nR said:

hey I use this, and it doesn't work :/


 
  1.  
  1.  
  1.  
  1. 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 by shaio

Share this post


Link to post

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 by tosfera

Share this post


Link to post

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 by TorNix~|nR

Share this post


Link to post

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.

Share this post


Link to post

You're almost trying to kill the client there, seriously.. don't work like that. Better use these steps;

  1. player logs in/joins the server
  2. set their data (their acl group OR a default group), something like: 'rank'
  3. in the onClientRender, loop through the players, get their rank
  4. once you got their rank, get the correct render name (make it an array/table and read it from there for ease)
  5. you're done.

Share this post


Link to post

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)
----------------------------

 

Share this post


Link to post

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")

 

Share this post


Link to post
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 by iPrestege
Typo

Share this post


Link to post

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.

Share this post


Link to post
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 by shaio

Share this post


Link to post

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)
----------------------------

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.