-
Posts
46 -
Joined
-
Last visited
Everything posted by Spc
-
The problem stopped occuring. It seems that this did the trick. Thank you for help.
-
Remote access is disabled. I'll add addEvents to the resources and i'll reply if it changed something or not. However it is still strange for me, because i've never seen this happen before.
-
Yes, i'm using addDebugHook for detecting and blocking client-side functions as a form of anti-cheat, for example: addDebugHook("preFunction", ac_checkFunction, DISALLOWED_FUNCTIONS) function ac_checkFunction(sourceRes, funcName, _, _, _, ...) if DISALLOWED_FUNCTIONS[funcName] then triggerServerEvent("onACDetection", localPlayer) return "skip" end end Do you mean adding multiple addEvent functions with same event name? I use this event in multiple resources.
-
Hello, I have basic custom event that triggers when player logins: triggerEvent("onPlayerHasLogged", client) And it's handled in another resource on global level: addEventHandler("onPlayerHasLogged", root, function() iprint("trigger", source) end) Everything is working just fine but after a random amount of time (sometimes few hours, sometimes less and sometimes a lot more) eventHandler stops triggering completely. triggerEvent still returns true. When i restart the resource with eventHandler, everything works properly again. Handlers of other event triggers that have "client" as base element stop working as well. Does anybody know what may be wrong?
-
How can I make slothbot enemy guards spawned by server?
Spc replied to bencskrisz's topic in Scripting
Show us your code and meta. -
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?
-
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.
-
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.
-
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.
-
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.
-
I fixed it, thanks for help. All works.
-
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.
-
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.
-
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)
-
Hey, I want to disable custom HUD (my own created) with command /showhud. These functions didn't work: addCommandHandler onPlayerCommand isPlayerHudComponentVisible("radar") Any sollution?
-
How can i detect shoot in colshape from checking if is something between two elements??
-
I want to check if the player has shooted in the colshape.
-
I have a large skin with bugged hitbox, so I wanted to make a "fake hitbox". In onClientPlayerWeaponFire is a parameter "hitElement" but it doesn't work on colshape. Any sollution?
-
Maybe this? ship = createObject(8493, -5704.3999023438, 3755.1000976563, 15.60000038147,0,0, 261.49658203125) moveObject (ship,20000, -5195.1303710938, 3695.7001953125, 15.60000038147) setTimer(function() moveObject (ship,30000, -5195.1303710938, 3695.7001953125, 199.60000038147) end, time*1000, 1) in the place "time" enter the time in seconds for how long the timer function should be performed
-
local sound local time = 0 function playBackgroundSound() local hour,minutes = getTime( ) if hour >= 6 and hour < 12 then if time == 0 or (time ~= 1 and isElement(sound)) then stopSound(sound) sound = playSound ( "day.mp3",true ) end time = 1 elseif ( hour >= 12 ) and ( hour < 15 ) then if time == 0 or (time ~= 1 and isElement(sound)) then stopSound(sound) sound = playSound ( "day.mp3",true ) end time = 1 elseif ( hour >= 15 ) and ( hour < 20 ) then if time == 0 or (time ~= 2 and isElement(sound)) then stopSound(sound) sound = playSound ( "night.mp3",true ) end time = 2 elseif ( hour >= 20 ) and ( hour < 24 ) then if time == 0 or (time ~= 2 and isElement(sound)) then stopSound(sound) sound = playSound ( "night.mp3",true ) end time = 2 end end setTimer(playBackgroundSound, 600000, 0) setTimer(playBackgroundSound, 500, 1) Try it.
-
I solved it myself. Thank you all for help.
-
The sound is added to the meta? Maybe file is broken or you pasting this code to the server-side. The script must be on client-side.
-
The ped will not have weapon (only fist). I want to make him running to the player and attacks him.