marcineg Posted August 5, 2017 Share Posted August 5, 2017 Hello, i'm have a question. How to use onClientElementStreamIn and onClientElementStreamOut? I must optimize my code with this events, now i have loop in onClientPreRender so this events will useful me. Sorry for my english Link to comment
NeXuS™ Posted August 5, 2017 Share Posted August 5, 2017 These 2 events happen when an element is streamed in/out on the client. (Like the visible distance) Link to comment
marcineg Posted August 5, 2017 Author Share Posted August 5, 2017 An example of how to display dxDrawMaterialLine3D for players in this stream? Link to comment
NeXuS™ Posted August 5, 2017 Share Posted August 5, 2017 (edited) Try to debug if the dxDrawMaterialLine3D is an element, or not. Edited August 5, 2017 by NeXuS™ Link to comment
marcineg Posted August 5, 2017 Author Share Posted August 5, 2017 (edited) I know, I mean dxDrawMaterialLine3D rendering for players in the stream. Edited August 5, 2017 by marcineg Link to comment
NeXuS™ Posted August 5, 2017 Share Posted August 5, 2017 Do you know what "stream" means in this case? Link to comment
NeXuS™ Posted August 5, 2017 Share Posted August 5, 2017 Streaming in happens when an object gets loaded in, because you get close to it, streaming out happens when an object gets loaded out, because you went to far away from it. Link to comment
marcineg Posted August 5, 2017 Author Share Posted August 5, 2017 So I have to create a dxDrawMaterialLine3D element? With createElement ("line3D") and for that use streaming? Because I want dxDrawMaterialLine3D to see each and loop in the onClientPreRender on players is aggravating. Link to comment
NeXuS™ Posted August 5, 2017 Share Posted August 5, 2017 Dude, you should really post this in your own language section, because I don't understand a word you are trying to say with the translator. Link to comment
marcineg Posted August 5, 2017 Author Share Posted August 5, 2017 I'm want to everyone see dxDrawMaterialLine3D, but i do not want to use loop on players in onClientPreRender. addEventHandler("onClientPreRender",root,function() for _,k in pairs(Element.getAllByType("player")) do local pts = k:getData("points") for i=1, #pts do dxDrawMaterialLine3D(pts[i][1],pts[i][2],pts[i][3],pts[i+1][1],pts[i+1][2],pts[i+1][3],texture,0.1) end end end) how to optimize this code? Link to comment
Discord Moderators Pirulax Posted August 5, 2017 Discord Moderators Share Posted August 5, 2017 triggerClientEvent triggerServerEvent Tables. This is what you need.I have one script like you need, here it is: --clienet local lines = {} addEventHandler("onClientResourceStart",resourceRoot,function() setElementData(localPlayer, "endpos",Vector3(getElementPosition(localPlayer))) lines[localPlayer] = {} lines[localPlayer][1] = {Vector3(getElementPosition(localPlayer)),Vector3(getElementPosition(localPlayer))} local x,y = getScreenFromWorldPosition(2796.6591796875 ,-695.8740234375 ,57.99556350708) local browser = guiCreateBrowser(x,y,1000,1000,true,false,false) addEventHandler("onClientPreRender",root,function() local x,y,z = getElementPosition(localPlayer) for kk,vv in pairs(lines) do for k,v in pairs(vv) do if v[2] == 1 then v[2] = Vector3(getElementPosition(kk)) end if not v[2] or not v[1] then break end if not texture then break end if not getElementData(localPlayer,"showlines") then return end dxDrawLine3D(v[1],v[2],tocolor(170,170,170,255),1500) end end end) for k,v in pairs({"w","a","s","d"}) do bindKey(v,"down",function() setElementData(localPlayer, "startpos",Vector3(getElementPosition(localPlayer))) local index = #lines[localPlayer]+1 lines[localPlayer][index] = {getElementData(localPlayer, "endpos"),1} setElementData(localPlayer, "lastindex",index) if getElementData(localPlayer, "syncLINE") then local x,y,z = getElementData(localPlayer, "endpos"):getX(),getElementData(localPlayer, "endpos"):getY(),getElementData(localPlayer, "endpos"):getZ() local trigged = triggerServerEvent("syncLinesS",resourceRoot,localPlayer,index,x,y,z,1) end end) bindKey(v,"up",function() setElementData(localPlayer, "endpos",Vector3(getElementPosition(localPlayer))) local index = getElementData(localPlayer, "lastindex") lines[localPlayer][index] = { lines[localPlayer][index][1], Vector3(getElementPosition(localPlayer))} if getElementData(localPlayer, "syncLINE") then local x,y,z = getElementPosition(localPlayer) local x1,y1,z1 = lines[localPlayer][index][1]:getX(),lines[localPlayer][index][1]:getY(),lines[localPlayer][index][1]:getZ() local trigged = triggerServerEvent("syncLinesS",resourceRoot,localPlayer,index,x,y,z,x1,y1,z1) end end) end end) addCommandHandler("showlines",function() setElementData(localPlayer,"showlines",not getElementData(localPlayer,"showlines")) outputChatBox(" Vonalak mutatása " .. tostring(getElementData(localPlayer,"showlines"))) end,false) addCommandHandler("lines",function() setElementData(localPlayer,"syncLINE",not getElementData(localPlayer,"syncLINE")) outputChatBox(" sync state " .. tostring(getElementData(localPlayer,"syncLINE"))) end,false) addEvent("snycLinesCC",true) addEventHandler("snycLinesCC",getLocalPlayer(),function(p,index,x,y,z,xx,yy,zz) if p == localPlayer then return end if not lines[p] then lines[p] = {} end if xx == 1 and not yy and not zz then nd = 1 else nd = Vector3(xx,yy,zz) end lines[p][index] = {Vector3(x,y,z),nd} end) --server addEvent("syncLinesS",true) addEventHandler("syncLinesS",resourceRoot,function(p,index,x,y,z,xx,yy,zz) triggerClientEvent(root,"snycLinesCC",root,p,index,x,y,z,xx,yy,zz) end) when you start-up the script use /showlinesto enable drawing of the lines, and use / lines to enalbe syncing to other players. Link to comment
NeXuS™ Posted August 5, 2017 Share Posted August 5, 2017 addEventHandler("onClientPreRender",root,function() for _,k in pairs(Element.getAllByType("player", true)) do local pts = k:getData("points") for i=1, #pts do dxDrawMaterialLine3D(pts[i][1],pts[i][2],pts[i][3],pts[i+1][1],pts[i+1][2],pts[i+1][3],texture,0.1) end end end) This'll only render lines towards the players who are streamed in for the localPlayer. 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