Jump to content

WARNING


yToPzz

Recommended Posts

[2022-10-23 16:48:42] WARNING: Painel-Som\client\gui.lua:255: Bad argument @ 'getVehicleName' [Expected vehicle at argument 1, got boolean]

 

addEvent ("tune.sync_objects", true);
addEventHandler ("tune.sync_objects", root,
	function (veh, objects)
		local g = tune.gridlist[3];
		local label_text = isPedInVehicle (localPlayer) and getVehicleName(getPedOccupiedVehicle(localPlayer)) or "none" ---- line error
		tune.label[5]:setText("Você deve estar em um veículo para usar este painel.\nVeículo atual: ".. label_text);
		guiGridListClear (g);
		if not isPedInVehicle (localPlayer) then return; end
		if not veh or not objects then return; end
		for i=#objects, 1, -1 do 
			local v = objects[i];
			if isElement (v) then
				local row = guiGridListAddRow (g);
				guiGridListSetItemText (g, row, 1, veh, false, false);
				guiGridListSetItemText (g, row, 2, getElementModel (v), false, false);
				guiGridListSetItemData (g, row, 1, v);
			end	
		end	
		guiGridListSetSelectedItem (g, 0, 1);
	end
);

 

Link to comment
addEvent ("tune.sync_objects", true);
addEventHandler ("tune.sync_objects", root,
	function (veh, objects)
		local g = tune.gridlist[3];
		local label_text = "none" ---- set it to none by default.
		if isPedInVehicle(localPlayer) then --if ped is in vehicle then set labeltext to vehname
			label_text = getVehicleName(getPedOccupiedVehicle(localPlayer))
		end
		tune.label[5]:setText("Você deve estar em um veículo para usar este painel.\nVeículo atual: "..label_text)
		if not isPedInVehicle (localPlayer) then return end
		if not veh or not objects then return end
		guiGridListClear (g);
		for i=#objects, 1, -1 do 
			local v = objects[i];
			if isElement (v) then
				local row = guiGridListAddRow (g);
				guiGridListSetItemText (g, row, 1, veh, false, false);
				guiGridListSetItemText (g, row, 2, getElementModel (v), false, false);
				guiGridListSetItemData (g, row, 1, v);
			end	
		end	
		guiGridListSetSelectedItem (g, 0, 1);
	end
);

This code should work without errors.

  • 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...