Jump to content

BriGhtx3

Members
  • Posts

    378
  • Joined

  • Last visited

Everything posted by BriGhtx3

  1. drugtimerrest = {} function timerAnzeigen() -- when I click the OK btn guiSetVisible(Drugs_Window,false) guiSetVisible(Create_Window,true) restminuten = 20 guiSetText(Create_LBL_Timer, tonumber(restminuten).." Minuten") drugtimerrest[getLocalPlayer()] = setTimer(updateTimerZeit,1000,0,getLocalPlayer()) end function updateTimerZeit(player) restminuten = restminuten - 1 if restminuten <= 0 then killTimer(drugtimerrest[player]) drugtimerrest[player] = nil guiSetVisible(Create_Window,false) else guiSetText(Create_LBL_Timer, tonumber(restminuten).." Minuten") end end function abbrDr() -- when I click the cancel btn killTimer(drugtimerrest[source]) drugtimerrest[source] = nil end addEventHandler("onClientPlayerQuit",getRootElement(),abbrDr) My problem is that when I click the cancel btn, the gui gets invisible, but the timer seems not to get stopped. When I click the OK Btn again, the timer gets even faster, and when I repeat it, the timer counts three times faster than normal... The error after the "real" timer is finished is: [b]Bad argument at killTimer [Expected lua-timer at argument 1, got nil][/b] This is the line : killTimer(drugtimerrest[player])
  2. -.- Of course a marker should teleport someone.
  3. because he still gets teleported before destroying the marker
  4. But both are the same. In the name I use: local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 ) dxDrawText ( getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,0,textalpha), (textscale*NAMETAG_TEXTSIZE)-0.3, "default", "center", "bottom", false, false, false ) In the text I use: local sxStat,syStat = getScreenFromWorldPosition ( px, py, pz+0.85, 0.06 ) dxDrawText ( "DER STATUS", sxStat, syStat - offset, sxStat, syStat - offset, tocolor(10,10,10,255), (textscale*NAMETAG_TEXTSIZE)-0.3, "default", "center", "bottom", false, false, false ) Edit: Ok. Thank you anyways.
  5. Now it's better, but the text still moves into the name Edit: Still the same
  6. Tried it. It doesn't work. When I move away the text becomes too small and moves into my name.
  7. @Todd The startingsize is right. But when I move away the text becomes smaller. But when I move away the name does not become smaller. @Draken what do you mean?
  8. What shall I do with this? The text also should disappear when reaching a distance of 25, but the size of the text "DER STATUS" is getting too small. Just like the image.
  9. g_Root = getRootElement() g_ResRoot = getResourceRootElement(getThisResource()) g_Players = getElementsByType('player') g_Me = getLocalPlayer() nametag = {} local nametags = {} local g_screenX,g_screenY = guiGetScreenSize() local bHideNametags = false local NAMETAG_SCALE = 0.3 --Overall adjustment of the nametag, use this to resize but constrain proportions local NAMETAG_ALPHA_DISTANCE = 25 --Distance to start fading out local NAMETAG_DISTANCE = 25 --Distance until we're gone local NAMETAG_ALPHA = 120 --The overall alpha level of the nametag --The following arent actual pixel measurements, they're just proportional constraints local NAMETAG_TEXT_BAR_SPACE = 2 local NAMETAG_WIDTH = 50 local NAMETAG_HEIGHT = 5 local NAMETAG_TEXTSIZE = 0.9 local NAMETAG_OUTLINE_THICKNESS = 1.3 -- local NAMETAG_ALPHA_DIFF = NAMETAG_DISTANCE - NAMETAG_ALPHA_DISTANCE NAMETAG_SCALE = 1/NAMETAG_SCALE * 800 / g_screenY -- Ensure the name tag doesn't get too big local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} } -- Ensure the text doesn't get too small/unreadable local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} } -- Make the text a bit brighter and fade more gradually local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} } function nametag.create ( player ) nametags[player] = true end function nametag.destroy ( player ) nametags[player] = nil end addEventHandler ( "onClientRender", g_Root, function() -- Hideous quick fix -- for i,player in ipairs(g_Players) do if isElement(player) then if player ~= g_Me then setPlayerNametagShowing ( player, false ) if not nametags[player] then nametag.create ( player ) end end end end if bHideNametags then return end local x,y,z = getCameraMatrix() for player in pairs(nametags) do while true do if not isElement(player) then break end if getElementDimension(player) ~= getElementDimension(g_Me) then break end local px,py,pz = getElementPosition ( player ) if processLineOfSight(x, y, z, px, py, pz, true, false, false, true, false, true) then break end local pdistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz ) if pdistance <= NAMETAG_DISTANCE then --Get screenposition local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 ) --------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------ POSI OF STATUS ---------------------------------------------- --------------------------------------------------------------------------------------------------------------------- local sxStat,syStat = getScreenFromWorldPosition ( px, py, pz+0.85, 0.06 ) if not sx or not sy then break end if not sxStat or not syStat then break end --Calculate our components local scale = 1/(NAMETAG_SCALE * (pdistance / NAMETAG_DISTANCE)) local alpha = ((pdistance - NAMETAG_ALPHA_DISTANCE) / NAMETAG_ALPHA_DIFF) alpha = (alpha < 0) and NAMETAG_ALPHA or NAMETAG_ALPHA-(alpha*NAMETAG_ALPHA) scale = math.evalCurve(maxScaleCurve,scale) local textscale = math.evalCurve(textScaleCurve,scale) local textalpha = math.evalCurve(textAlphaCurve,alpha) local outlineThickness = NAMETAG_OUTLINE_THICKNESS*(scale) --Draw our text local health local p local r,g health = getElementHealth ( player ) health = math.max(health, 0)/100 p = -510*(health^2) r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2 --------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------ STATUS ------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------- dxDrawText ( "DER STATUS", sxStat, syStat - offset, sxStat, syStat - offset, tocolor(10,10,10,255), (textscale*NAMETAG_TEXTSIZE)-0.3, "default", "center", "bottom", false, false, false ) if health <= 0 then --------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------ IMAGE -------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------- dxDrawImage ( sx - offset, sy - offset, 20, 20, 'images/tt.png' ) dxDrawText ( getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(0,0,0,textalpha), textscale*NAMETAG_TEXTSIZE, "default", "center", "bottom", false, false, false ) else dxDrawText ( getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,0,textalpha), textscale*NAMETAG_TEXTSIZE, "default", "center", "bottom", false, false, false ) end end break end end end ) ---------------THE FOLLOWING IS THE MANAGEMENT OF NAMETAGS----------------- addEventHandler('onClientResourceStart', g_ResRoot, function() for i,player in ipairs(getElementsByType("player")) do if player ~= g_Me then nametag.create ( player ) end end end ) addEventHandler ( "onClientPlayerJoin", g_Root, function() if source == g_Me then return end setPlayerNametagShowing ( source, false ) nametag.create ( source ) end ) addEventHandler ( "onClientPlayerQuit", g_Root, function() nametag.destroy ( source ) end ) -- Math functions function math.lerp(from,to,alpha) return from + (to-from) * alpha end -- curve is { {x1, y1}, {x2, y2}, {x3, y3} ... } function math.evalCurve( curve, input ) -- First value if input[1][1] then return curve[1][2] end -- Interp value for idx=2,#curve do if input[idx][1] then local x1 = curve[idx-1][1] local y1 = curve[idx-1][2] local x2 = curve[idx][1] local y2 = curve[idx][2] -- Find pos between input points local alpha = (input - x1)/(x2 - x1); -- Map to output points return math.lerp(y1,y2,alpha) end end -- Last value return curve[#curve][2] end Hey, this is the nametag script of the race resource. Now I want to add another text called "DER STATUS" underneath the name and if the player dies, I want to show the image. Everything is shown but the text "DER STATUS" moves away or gets too small or too big. The same happens with the image. How can I fix the positions like in the name? The parts of my modifications are marked. Thanks
  10. BriGhtx3

    Nothing?

    Im not sure, but maby because you mixed relative positions with absolute position.
  11. BriGhtx3

    chat colour

    outputChatBox("TEXT",getRootElement(),255,0,0) or outputChatBox("#CD0000RED #FFA500ORANGE #FF0000GREEN",getRootElement(),0,0,0,true)
  12. This also doesn't work But thanks anyway
  13. This can't work because every 10 seconds the progress bar is set to 20% (doesn't make sense) setTimer (function() guiProgressBarSetProgress ( bar,20 ) end, 1000, 0) And why do you want to use for ?
  14. Still the same. I also tried to change it like this: addEventHandler( 'onMarkerHit', root, function( uHitElement, bMatchingDimension) if getElementType( uHitElement ) == 'vehicle' then local _markers = getElementsByType("marker") for i,marker in ipairs(_markers) do cancelEvent() end end end)
  15. Thank you but: I need to check whether he is in a vehicle or not. So this script can't work for me. And I also can't work with tables, because then I have to copy each marker to the table.
  16. If I set the element data for every marker it is the same like pasting it everywhere. But this are simply too much So I need a general function
  17. I know how to do it within the marker function. But I want a GENERAL function where I check it for every marker, because I have too much markers to paste it everywhere For example: I have MarkerXY and when I hit it, I get teleported to interior XX I have MarkerYZ and when I hit it, I get teleported to interior YY I have MarkerAA and when I hit it, I get teleported to interior ZZ Now if I am in a vehicle and hit MarkerXY or MarkerYZ or MarkerAA or any other marker and I am IN a vehicle, the event gets cancelled
  18. Doesn't work But thanks anyway
  19. I know how to cancel the event in the function, but this would be too much work since I have a lot of markers... So I want to create a general function.
×
×
  • Create New...