MarvelSK Posted May 26, 2016 Share Posted May 26, 2016 Hello I need help I have got a duty script where when admin say /duty got 999999blood and text under head Admin is on duty ...... And when I write /off duty, blood will be 12000 but Admin is on duty text is there always. 3d Texts 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 ); Blood function giveblood (thePlayer) local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("Admin,Moderator,Owner")) then end outputChatBox ("#1AFF00 Administrátor "..getPlayerName(thePlayer).."#1AFF00 pracuje - NESMRTELNOST",root,255,255,255,true) setElementData(thePlayer, "blood",999999999) end addCommandHandler("duty", giveblood) function bloodback(thePlayer) local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("Admin,Moderator,Owner")) then end outputChatBox ("#FF0000 Administrátor "..getPlayerName(thePlayer).."#FF0000 už nepracuje - SMRTELNOST",root,255,255,255,true) setElementData(thePlayer, "blood",12000) end addCommandHandler("offduty", bloodback) Text addEvent ( "onDuty", true ) function duty() if getElementData(getLocalPlayer( ),"duty") == true then timer = setTimer ( function() setElementData(getLocalPlayer( ),"onDuty",true) local x, y, z = getElementPosition( getLocalPlayer( ) ) local playerName = getPlayerName( getLocalPlayer( ) ) local theText = dxDraw3DText( "×× Admin is OnDuty ××\n[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( ),"duty",true) end end addEventHandler ( "onDuty", getRootElement(), duty) addCommandHandler("duty",duty) Link to comment
Rataj Posted May 26, 2016 Share Posted May 26, 2016 Why is there even event handler named "onDuty" when you don't call it from anywhere? Also look at your timers in the text part, you should read how timers work here. And merge your "duty" commands together, it will be more clean, than two command handlers with same command. I understand you're beginner, but you should start by reading Scripting Introduction, it can help you a lot. If you need any further help, feel free to contact me. Link to comment
MarvelSK Posted May 26, 2016 Author Share Posted May 26, 2016 Why is there even event handler named "onDuty" when you don't call it from anywhere?Also look at your timers in the text part, you should read how timers work here. And merge your "duty" commands together, it will be more clean, than two command handlers with same command. I understand you're beginner, but you should start by reading Scripting Introduction, it can help you a lot. If you need any further help, feel free to contact me. Hello, Yes I am begineer, please can you repair it ?? Very please and I study it. Thank you a lot. 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