Korea Posted July 18 Share Posted July 18 -- example code use your own local screen addEventHandler("onClientRender", root, function() if not screen then return end dxDrawImage(0, 0, 300, 300, screen) end) -- all magic done by calling dxUpdateScreenSource(screen, true) in onClientPreRender local function screenPreRender() if isElement(screen) then destroyElement(screen); screen = nil return end local sx, sy = guiGetScreenSize() screen = dxCreateScreenSource(sx, sy) -- your choice if not isElement(screen) then return end dxUpdateScreenSource(screen, true) removeEventHandler("onClientPreRender", root, screenPreRender) end addEvent("getScreenShot", true) addEventHandler("getScreenShot", resourceRoot, function() addEventHandler("onClientPreRender", root, screenPreRender) end) triggerEvent("getScreenShot", resourceRoot) This is example code. All magic done by screenPreRender function. Link to comment
Moderators IIYAMA Posted July 18 Moderators Share Posted July 18 1 hour ago, Korea said: screen = dxCreateScreenSource(sx, sy) -- your choice The dxCreateScreenSource function creates the screenSource element. (it can fail if there is not enough video memory, which results in returning the value false instead) Important: Elements can't be directly saved inside variable, a variable can only point to an element (see userdata). Thus overriding the value of variable screen, does not delete the previous element. Which leads to a memory leak. Recommendation: The screenSource texture element should only be created ones at the top of your resource. Or you can do something like this: if not screen then screen = dxCreateScreenSource(sx, sy) end -- of not exist, attempt to create the screenSource texture if screen then dxUpdateScreenSource(screen, true) end -- if exist, update the screenSource @Korea (If you want to me to update your current example, feel free to ask below. Also this topic might be better of at scripting > tutorials, but it is your choice. ) 1 Link to comment
Korea Posted July 18 Author Share Posted July 18 1 hour ago, IIYAMA said: The dxCreateScreenSource function creates the screenSource element. (it can fail if there is not enough video memory, which results in returning the value false instead) Important: Elements can't be directly saved inside variable, a variable can only point to an element (see userdata). Thus overriding the value of variable screen, does not delete the previous element. Which leads to a memory leak. Recommendation: The screenSource texture element should only be created ones at the top of your resource. Or you can do something like this: if not screen then screen = dxCreateScreenSource(sx, sy) end -- of not exist, attempt to create the screenSource texture if screen then dxUpdateScreenSource(screen, true) end -- if exist, update the screenSource You are right, however its example code. People have to create own code because cheaters can block addEventHandler / triggerServerEvent and sent fake data. Most of the haxx are using lua injector to create debughook on triggerServerEvent and output info. There is a way to 'bypass' it. addDebugHook("preFunction", function(_, _, _, _, _, ...) triggerServerEvent(...) return "skip" end, {"setPedBleeding"}) -- use function that you wont use on your server setPedBleeding("test123", resourceRoot) Link to comment
Moderators IIYAMA Posted July 18 Moderators Share Posted July 18 On 18/07/2024 at 23:08, Korea said: There is a way to 'bypass' it. I am aware of how that function works. But how does this related to your previous code? Also example code often require some more instructions/information. The thing is, I am not sure where to put your content in this case (after your second reply). If you want to publish a resource, sure this is the right location. But just example code is not a resource. Is it a tutorial? It is misses a lot of information/instructions, but close enough. What do you want this topic to be? You can also create wiki pages for example code. Link to comment
Recommended Posts