Jump to content

Help! Something is wrong


Mrzeerox

Recommended Posts

addEventHandler( "onClientRender", root, function ()
    plrs = getElementsByType'thePlayer'
    for i=1,#plrs do
        if getElementData(plrs[i], "OnDuty") and plrs[i] ~= localPlayer then
            dxDrawTextOnElement(plrs[i],"]-Pie clan-[",1,30,255,255,255,255,3,"default-bold")
        end
    end
end )



function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font)
    local distance = distance or 20
    local height = height or 1
    local x, y, z = getElementPosition(TheElement)
    local x2, y2, z2 = getCameraMatrix()
    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+4, sy+4, sx, sy, tocolor(0, 0, 0, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center")
            dxDrawText(text, sx, sy, 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
function giveblood ( thePlayer )
	if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ( "Admin") ) then
		if not getElementData(thePlayer, "OnDuty") then    
        outputChatBox ("#1AFF00 Admin "..getPlayerName(thePlayer).."#1AFF00IS NOW - ON DUTY",root,255,255,255,true)
    setElementData(thePlayer, "blood",999999999)
    setElementData(thePlayer, "food",95)
    setElementData(thePlayer, "thirst",95)
    setElementData(thePlayer, "temperature",36.5)
    setElementData(thePlayer, "currentweapon_1",false)
    setElementData(thePlayer, "currentweapon_2",false)
    setElementData(thePlayer, "currentweapon_3",false)
    setElementData(thePlayer, "bleeding",false)
    setElementData(thePlayer, "brokenbone",false)
    setElementData(thePlayer, "pain",false)
    setElementData(thePlayer, "cold",false)
    setElementData(thePlayer, "bandit",false)
    setElementData(thePlayer, "humanity",2500)
    setElementData(thePlayer, "skin",210)
end
addCommandHandler("duty", giveblood)
end
function bloodback(thePlayer)
local account = getAccountName ( getPlayerAccount ( thePlayer ) )
        if isObjectInACLGroup("user." .. account, aclGetGroup("Admin,Moderator,Owner")) then
 
        end
        outputChatBox ("#FF0000 Admin "..getPlayerName(thePlayer).."#FF0000IS NOW - OFF DUTY",root,255,255,255,true)
    setElementData(thePlayer, "blood",12000)
end
addCommandHandler("offduty", bloodback)
end

Can anyone tell me whats wrong and can anyone fix it and send it back?

 

Link to comment

I don't know what are you trying to do with this code below.

Spoiler

 


addEventHandler( "onClientRender", root, function ()
    plrs = getElementsByType'thePlayer'
    for i=1,#plrs do
        if getElementData(plrs[i], "OnDuty") and plrs[i] ~= localPlayer then
            dxDrawTextOnElement(plrs[i],"]-Pie clan-[",1,30,255,255,255,255,3,"default-bold")
        end
    end
end )

But if you want to draw dx on that client maybe try this code.

Client:

addEventHandler( "onClientRender", root, function ()
    local localPlayer = getLocalPlayer()
    if getElementData(localPlayer, "OnDuty")  then
        dxDrawTextOnElement(localPlayer,"]-Pie clan-[",1,30,255,255,255,255,3,"default-bold")
    end
end )

function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font)
    local distance = distance or 20
    local height = height or 1
    local x, y, z = getElementPosition(TheElement)
    local x2, y2, z2 = getCameraMatrix()
    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+4, sy+4, sx, sy, tocolor(0, 0, 0, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center")
            dxDrawText(text, sx, sy, 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

Server:

function giveblood ( thePlayer )
	if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ( "Admin") ) then
		if not getElementData(thePlayer, "OnDuty") then    
        	outputChatBox ("#1AFF00 Admin "..getPlayerName(thePlayer).."#1AFF00IS NOW - ON DUTY",root,255,255,255,true)
    		setElementData(thePlayer, "blood",999999999)
    		setElementData(thePlayer, "food",95)
    		setElementData(thePlayer, "thirst",95)
    		setElementData(thePlayer, "temperature",36.5)
    		setElementData(thePlayer, "currentweapon_1",false)
    		setElementData(thePlayer, "currentweapon_2",false)
    		setElementData(thePlayer, "currentweapon_3",false)
    		setElementData(thePlayer, "bleeding",false)
    		setElementData(thePlayer, "brokenbone",false)
    		setElementData(thePlayer, "pain",false)
    		setElementData(thePlayer, "cold",false)
    		setElementData(thePlayer, "bandit",false)
    		setElementData(thePlayer, "humanity",2500)
    		setElementData(thePlayer, "skin",210)
			setElementData(thePlayer, "OnDuty",true)
		end
	end
end
addCommandHandler("duty", giveblood)

function bloodback(thePlayer)
	local account = getAccountName ( getPlayerAccount ( thePlayer ) )
	if isObjectInACLGroup("user." .. account, aclGetGroup("Admin,Moderator,Owner")) then
 
	end
	outputChatBox ("#FF0000 Admin "..getPlayerName(thePlayer).."#FF0000IS NOW - OFF DUTY",root,255,255,255,true)
	setElementData(thePlayer, "blood",12000)
	setElementData(thePlayer, "OnDuty",false)
end
addCommandHandler("offduty", bloodback)

 

Link to comment
addEventHandler( "onClientRender", root, function ()
    plrs = getElementsByType("player")
    for i=1,#plrs do
        if getElementData(plrs[i], "OnDuty") and plrs[i] ~= localPlayer then
            dxDrawTextOnElement(plrs[i],"]-Pie clan-[",1,30,255,255,255,255,3,"default-bold")
        end
    end
end )

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...