Mrzeerox Posted October 16, 2016 Share Posted October 16, 2016 addEvent ( "onaduty", true ) function aduty() if getElementData(getLocalPlayer( ),"aduty") == true then timer = setTimer ( function() setElementData(getLocalPlayer( ),"onaduty",true) local x, y, z = getElementPosition( getLocalPlayer( ) ) local playerName = getPlayerName( getLocalPlayer( ) ) local theText = dxDraw3DText( "Admin On duty [DONT SHOOT]", x, y, z+1,05,"default",255,0,0,200) setTimer ( function() destroyElement(theText) end, 59, 1) end, 60, 0 ) else if isTimer(timer) then killTimer(timer) end setElementData(getLocalPlayer( ),"aduty",true) end end addEventHandler ( "onaduty", getRootElement(), aduty) addCommandHandler("duty",aduty) Text.lua Here is problem. I see the text but another players don't! goduty.lua function aduty ( player ) local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup ( "user." ..accName, aclGetGroup ( "Admin") ) then outputChatBox(" Administrator "..getPlayerName(player).." Is Now OnDuty!",getRootElement(),255,0,0) outputChatBox("",getRootElement(),255,0,0) outputServerLog(" Administrator "..getPlayerName(player).." Is Now OnDuty!") setElementData( player, "blood", 99999999999999999999999 ) heal = "9999999999999999999999999999" end end addCommandHandler("duty",aduty) function offaduty ( player ) local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup ( "user." ..accName, aclGetGroup ( "Admin") ) then outputChatBox(" Administrator "..getPlayerName(player).." Is No Longer OnDuty!",getRootElement(),255,0,0) outputChatBox("",getRootElement(),255,0,0) outputServerLog(" Administrator "..getPlayerName(player).." Is No Longer OnDuty!") setElementData( player, "blood", 12000 ) end end addCommandHandler("offaduty",offaduty) function heal_func ( player ) local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup ( "user." ..accName, aclGetGroup ( "Admin") ) then if heal == "an" then setElementData( player, "food", 250 ) setElementData( player, "thirst", 250 ) end end end setTimer(heal_func, 60000, 0) 3dtext.lua local fonts = { [ "default" ] = true, [ "default-bold" ] = true,[ "clear" ] = true,[ "arial" ] = true,[ "sans" ] = true, [ "pricedown" ] = true, [ "bankgothic" ] = true,[ "diploma" ] = true,[ "beckett" ] = true }; function dxDraw3DText( text, x, y, z, scale, font, r, g, b, maxDistance ) assert( type( text ) == "string", "Bad argument @ dxDraw3DText" ); assert( type( x ) == "number", "Bad argument @ dxDraw3DText" ); assert( type( y ) == "number", "Bad argument @ dxDraw3DText" ); assert( type( z ) == "number", "Bad argument @ dxDraw3DText" ); if not scale or type( scale ) ~= "number" or scale <= 0 then scale = 2 end if not font or type( font ) ~= "string" or not fonts[ font ] then font = "default" end if not r or type( r ) ~= "number" or r < 0 or r > 255 then r = 255 end if not g or type( g ) ~= "number" or g < 0 or g > 255 then g = 255 end if not b or type( b ) ~= "number" or b < 0 or b > 255 then b = 255 end if not maxDistance or type( maxDistance ) ~= "number" or maxDistance <= 1 then maxDistance = 12 end local textElement = createElement( "text" ); if textElement then setElementData( textElement, "text", text ); setElementData( textElement, "x", x ); setElementData( textElement, "y", y ); setElementData( textElement, "z", z ); setElementData( textElement, "scale", scale ); setElementData( textElement, "font", font ); setElementData( textElement, "rgba", { r, g, b, 255 } ); setElementData( textElement, "maxDistance", maxDistance ); return textElement end return false end addEventHandler( "onClientRender", root, function( ) local texts = getElementsByType( "text" ); if #texts > 0 then local pX, pY, pZ = getElementPosition( localPlayer ); for i = 1, #texts do local text = getElementData( texts[i], "text" ); local tX, tY, tZ = getElementData( texts[i], "x" ), getElementData( texts[i], "y" ), getElementData( texts[i], "z" ); local font = getElementData( texts[i], "font" ); local scale = getElementData( texts[i], "scale" ); local color = getElementData( texts[i], "rgba" ); local maxDistance = getElementData( texts[i], "maxDistance" ); if not text or not tX or not tY or not tZ then return end if not font then font = "default" end if not scale then scale = 2 end if not color or type( color ) ~= "table" then color = { 255, 255, 255, 255 }; end if not maxDistance then maxDistance = 12 end local distance = getDistanceBetweenPoints3D( pX, pY, pZ, tX, tY, tZ ); if distance <= maxDistance then local x, y = getScreenFromWorldPosition( tX, tY, tZ ); if x and y then dxDrawText( text, x, y, _, _, tocolor( color[1], color[2], color[3], color[4] ), scale, font, "center", "center" ); end end end end end ); NEED HELP!! Link to comment
Gravestone Posted October 17, 2016 Share Posted October 17, 2016 I guess you'll have to sync the drawing between server and client. Link to comment
iPrestege Posted October 17, 2016 Share Posted October 17, 2016 I'm not seeing a render also as @Gravestone said i suggest to make a data in the server and sync it with client side. Link to comment
Mrzeerox Posted October 17, 2016 Author Share Posted October 17, 2016 Oukey but then how i sync that? With some script? Can you help me with this? Link to comment
Gravestone Posted October 17, 2016 Share Posted October 17, 2016 triggerServerEvent, triggerClientEvent Link to comment
Mr.Loki Posted October 17, 2016 Share Posted October 17, 2016 To sync it with other players you can loop it through all the players in the server. you can try this: Client 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 ) 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 aduty ( player ) if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(player)), aclGetGroup ( "Admin") ) then if not getElementData(player, "OnDuty") then outputChatBox(" Administrator "..getPlayerName(player).." Is Now On Duty!",getRootElement(),255,0,0) outputServerLog(" Administrator "..getPlayerName(player).." Is Now On Duty!") else outputChatBox(" Administrator "..getPlayerName(player).." Is Now Off Duty!",getRootElement(),255,0,0) outputServerLog(" Administrator "..getPlayerName(player).." Is Now Off Duty!") end setElementData(player, "OnDuty", not getElementData(player, "OnDuty")) end end addCommandHandler("duty",aduty) Link to comment
Mrzeerox Posted November 17, 2016 Author Share Posted November 17, 2016 function giveblood (thePlayer) local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(player)), aclGetGroup ( "Admin") ) then if not getElementData(thePlayer, "OnDuty") then end 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 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 I have something wrong here. Can you help me? 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