Spc

Members
  • Content Count

    42
  • Joined

  • Last visited

Community Reputation

1 Neutral

1 Follower

About Spc

  • Rank
    Rat
  • Birthday July 24

Details

  • Location
    Poland

Recent Profile Visitors

498 profile views
  1. I am making help panel with scrollable dxText and I have a problem with calculating text height. I tried solutions from other topics but none of them works. Here's the code: Texts: https://pastebin.com/VrdBF7ap Categories data: https://pastebin.com/ZkUzUvuY Panel code: local sw, sh = guiGetScreenSize() local open = false local site local renderTarget local moveY = 0 local actualText local maxScrolled local category_font = dxCreateFont("font/Lato.ttf", 21) local subcategory_font = dxCreateFont("font/Lato.ttf", 14) local title_font = dxCreateFont("font/font.ttf", 14) local text_font = dxCreateFont("font/Lato.ttf", 15) function help_trigger() if open then open = false removeEventHandler("onClientRender", root, help_render) showChat(true) showPlayerHudComponent("all", true) showCursor(false) else if not CATEGORIES or not CATEGORIES[1] then return end open = true renderTarget = dxCreateRenderTarget(sw-270, sh-50, true) -- for text addEventHandler("onClientRender", root, help_render) showChat(false) showPlayerHudComponent("all", false) showCursor(t6rue) end end addCommandHandler("help", help_trigger, false) function help_render() dxDrawRectangle(0, 0, sw, sh, tocolor(0,0,0,210)) dxDrawRectangle(0, 30, 250, sh, tocolor(0,0,0,150)) dxDrawRectangle(0, 0, sw, 30, tocolor(0,0,0,210)) dxDrawText("Help panel", 0, 0, sw, 30, tocolor(255,255,255,255), 1, title_font, "center", "center") -- buttons local start_y = 50 local offset = 0 local button_height = 30 for j, category in pairs(CATEGORIES) do dxDrawRectangle(0, start_y+offset, 7, button_height+10, tocolor(177, 177, 177, 255)) dxDrawText(category.name, 15, start_y+offset, 250, start_y+offset+button_height+10, tocolor(177,177,177,255), 1, category_font, "left", "center") offset = offset + button_height+10 + 10 for i, v in pairs(category.subcategories) do local color = {255,255,255} if site == j..":"..i or isMouseInPosition(0, start_y+offset, 250, button_height) then dxDrawRectangle(0, start_y+offset, 5, button_height, tocolor(0, 157, 255, 255)) if isMouseInPosition(0, start_y+offset, 250, button_height) then color = {0, 157, 255} end if getKeyState("mouse1") then -- if player click button site = j..":"..i moveY = 0 actualText = getTextFromSite(site) or "" maxScrolled = (dxGetTextWidth(actualText, 1, text_font) / (sw-270)) * dxGetFontHeight(1, text_font) end end dxDrawText(v.name, 15, start_y+offset, 250, start_y+offset+button_height, tocolor(color[1], color[2], color[3], 255), 1, subcategory_font, "left", "center") offset = offset + button_height + 8 end offset = offset + 10 end -- main text if renderTarget then dxSetRenderTarget(renderTarget, true) dxDrawText(actualText or "", 0, moveY, sw-270, sh-50, tocolor(255,255,255,255), 1, text_font, "left", "top", true, true) dxSetRenderTarget() dxDrawImage(260, 40, sw-270, sh-50, renderTarget) end6 end addEventHandler("onClientKey", root, function(btn, press) if press and open and site6 then if btn == "mouse_wheel_up" then if moveY < 0 then moveY = moveY + 30 end elseif btn == "mouse_wheel_down" then if moveY > -maxScrolled then moveY = moveY - 30 end end end end) ---- function isMouseInPosition(x, y, width, height) if (not isCursorShowing()) then return false end local sx, sy = guiGetScreenSize() local cx, cy = getCursorPosition() local cx, cy = (cx * sx), (cy * sy) if (cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height) then return true else return false end end function getTextFromSite(site) local category, subcategory = unpack(split(site, ":")) if not category or not subcategory or category == "0" or subcategory == "0" then return false end return CATEGORIES[tonumber(category)].subcategories[tonumber(subcategory)].text end I need to calculate the whole text (saved in actualText) to maxScrolled variable. Is there any other ways to do this?
  2. I tried something like that local w = dxGetTextWidth(v, 1, newsFont) local rows = math.ceil(w/370) local h = rows * dxGetFontHeight(1, newsFont) (of course I tried math.floor and without) But still don't work.
  3. function darmanKardan (thePlayer, command, player) if player then local taraf = getPlayerFromName(player) setElementData(taraf,"healrequest", "pending") outputChatBox("#00ff00The doctor is willing to heal you. Do you accept?", taraf, 255, 255, 255, true) else outputChatBox("#ff0000Syntax: /heal <Name>", thePlayer, 255, 255, 255, true) end end addCommandHandler("heal", darmanKardan) function acceptHeal (thePlayer, command) local requestStatus = getElementData(thePlayer, "healrequest") if (requestStatus == "pending") then setElementData(player,"healrequest", "unpending") setElementHealth(player, 100) outputChatBox("#00ff00You have been healed by the doctor.", thePlayer, 255, 255, 255, true) else outputChatBox("#ff0000[Error]: #ffffffYou have no pending request.", thePlayer, 255, 255, 255, true) end end addCommandHandler("aheal", acceptHeal) Try it.
  4. Hey, I have problem with calculating the whole text height. local sw, sh = guiGetScreenSize() local newsFont = dxCreateFont("fonts/Lato.ttf", 8) local NEWS = {} -- example texts here function renderNews() local height = 0 for _, v in ipairs(NEWS) do local h = math.ceil((string.len(v) / 65)) * 25 dxDrawRectangle(sw-385, 95+height, 370, h, tocolor(0,0,0,155)) dxDrawText(v, sw-380, 100+height, sw-15, 100+h+height, tocolor(255,255,255,255), 1, newsFont, "left", "top", true, true) height = height + h + 10 end end I don't have any idea how to do that. I want the height to match every text.
  5. Spc

    [Question] Priv

    You added that file to meta.xml?
  6. Hey, I want to change green elements from the world (grass, trees). I want to change them so that the world looks deserted (maybe just simply darken them). Is there any way to do that? For example shader or just changing textures.
  7. I fixed it, thanks for help. All works.
  8. I used getScreenFromWorldPosition and sometimes the function returns false when i was looking at explosion position, and sometimes function returns float when i wasn't looking at explosion xyz.
  9. Hey, I'm making a flashbang and i need check, is player looking at XYZ position. For example: The explosion xyz is 0,0,0 and if player camera looks at it, something happens.
  10. Code: addEventHandler("onClientRender", getRootElement(), function() if getElementData(localPlayer, "auth:uid") then if isPlayerHudComponentVisible("radar") then -- the hiding don't work -- some DX draw end end end)
  11. Hey, I want to disable custom HUD (my own created) with command /showhud. These functions didn't work: addCommandHandler onPlayerCommand isPlayerHudComponentVisible("radar") Any sollution?
  12. Spc

    [HELP] Fake "hitbox"

    How can i detect shoot in colshape from checking if is something between two elements??
  13. Spc

    [HELP] Fake "hitbox"

    I want to check if the player has shooted in the colshape.