Turbe$Z Posted February 2, 2024 Posted February 2, 2024 i send datas from server side to client side then insert these datas to a table, and i want to render it, but the render does not work, cause the loop is does not working, and i dont know why, what wrong with the loop? this is my code: local playerVehicles = {} local sx, sy = guiGetScreenSize() function vehicles() for k, veh in pairs(playerVehicles) do dxDrawText(veh[k][1].." | "..veh[k][2], sx/2-370,sy/2-297,sx/2,sy/2, tocolor(255, 255, 255, 220), 3, "default-bold", "left", "top", false, false, false, true ) end end addEventHandler("onClientRender",root,vehicles) function teszt(p,id,model) table.insert(playerVehicles,{id,model}) end addEvent("test",true) addEventHandler("test",root,teszt) My Fun server: My DD server:
Moderators IIYAMA Posted February 2, 2024 Moderators Posted February 2, 2024 5 hours ago, Turbe$Z said: what wrong with the loop? You have to index the variable veh one time less. Since the pairs loop did the first index already for you. Quote dxDrawText(veh[k][1].." | "..veh[k][2], sx/2-370,sy/2-297,sx/2,sy/2, tocolor(255, 255, 255, 220), 3, "default-bold", "left", "top", false, false, false, true ) dxDrawText(veh[1].." | "..veh[2], sx/2-370,sy/2-297,sx/2,sy/2, tocolor(255, 255, 255, 220), 3, "default-bold", "left", "top", false, false, false, true ) 1 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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