Jump to content

[Help] what wrong with this loop?


Recommended Posts

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)

 

Link to comment
  • Moderators
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 )
	
  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...