dex. Posted October 24, 2017 Share Posted October 24, 2017 So. i have little problem with client side. Console and debugmonitor3 dosen't say anything. Server Side: local onDuty = {} addCommandHandler('duty',function(player,cmd) local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup('user.'..accName,aclGetGroup('Admin')) then if not onDuty[player] or onDuty[player] == false then onDuty[player] = true outputChatBox("#F10404[ADMINISTRATOR] #FF8B00 "..getPlayerName(player)..' #04F42Cis now on duty!', getRootElement(), 255, 255, 255, true) triggerClientEvent(player,"onDuty",getRootElement()) timer1 = setTimer(function() setElementAlpha(player, 0) setElementData(player,'brokenbone',false) setElementData(player,'bleeding',false) setElementData(player,'pain',false) setElementData(player,'cold',false) setElementData(player,'temperature',36.5) setElementData(player,'blood',12000) setElementData(player,'food',100) setElementData(player,'thirst',75) end,50,0) else onDuty[player] = false setElementAlpha(player, 255) outputChatBox("#F10404[ADMINISTRATOR] #FF8B00 "..getPlayerName(player)..' #3600FF is now off duty!', getRootElement(), 255, 255, 255, true) if isTimer(timer1) then killTimer(timer1) end end end end) Client Side: addEvent ( "onDuty", true ) function duty() if getElementData(source,"duty") == true then timer = setTimer ( function() setElementData(source,"onDuty",true) local x, y, z = getElementPosition(source ) local playerName = getPlayerName(source ) local theText = dxDraw3DText( "Admin On Duty [NO DM]", 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(source,"duty",true) end end addEventHandler ( "onDuty", root, duty) Do anyone have solution? Link to comment
ShayF2 Posted October 25, 2017 Share Posted October 25, 2017 nothing is outputted to chatbox? or what? Link to comment
dex. Posted October 25, 2017 Author Share Posted October 25, 2017 I wanna draw text on my head, if im on duty, but this does nofting. Link to comment
Rockyz Posted October 25, 2017 Share Posted October 25, 2017 -- #Client Side local showToSelf = true -- if you want to show the text to your self put it to 'true' and if you dont put it to 'false' or remove it 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 _, players in pairs ( getElementsByType 'player' ) do if not ( showToSelf ) then if ( players ~= localPlayer ) then if ( getElementData ( players, 'playerOnDuty' ) ) then dxDrawTextOnElement ( players, 'Admin On Duty [NO DM]' ) end end else if ( getElementData ( players, 'playerOnDuty' ) ) then dxDrawTextOnElement ( players, 'Admin On Duty [NO DM]' ) end end end end ) -- #Server Side addCommandHandler('duty',function(player,cmd) local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup('user.'..accName,aclGetGroup('Admin')) then setElementData(player,'playerOnDuty',not getElementData(player,'playerOnDuty')) outputChatBox('#F10404[ADMINISTRATOR] #FF8B00 '..getPlayerName(player)..' #04F42Cis now '..(getElementData(player, 'playerOnDuty') and 'on' or 'off')..' duty!', getRootElement(), 255, 255, 255, true) setElementAlpha(player,getElementData(player,'playerOnDuty') and 0 or 255) end end ) local theTable = { [ 'brokenbone' ] = { false }, [ 'bleeding' ] = { false }, [ 'pain' ] = { false }, [ 'cold' ] = { false }, [ 'temperature' ] = { 36.5 }, [ 'blood' ] = { 12000 }, [ 'food' ] = { 100 }, [ 'thirst' ] = { 75 } }; addDebugHook ( 'preFunction', function ( sourceResource, functionName, isAllowedByACL, luaFilename, luaLineNumber, ... ) local args = { ... }; if ( #args >= 3 and getElementData ( args [ 1 ], 'playerOnDuty' ) and theTable [ args [ 2 ] ] and getElementData ( args [ 1 ], args [ 2 ] ) ~= args [ 3 ] ) then return setElementData ( args [ 1 ], args [ 2 ], theTable [ args [ 2 ] ] [ 1 ] ) end end, { 'setElementData' } ) addDebugHook ( 'preFunction', function ( sourceResource, functionName, isAllowedByACL, luaFilename, luaLineNumber, ... ) local args = { ... }; if ( #args >= 2 and getElementData ( args [ 1 ], 'playerOnDuty' ) ) then return setElementAlpha ( args [ 1 ], 0 ) end end, { 'setElementAlpha' } ) 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