Jump to content

table expected got boolean


Best-Killer

Recommended Posts

Posted

error : bad argument unpack table expected got boolean (line 11 )

 

local playerVehicles = { }
function createPlayerVehicle ( p, id, marker, warp )
	if ( isElement ( playerVehicles[p] ) ) then
		destroyElement ( playerVehicles[p] )
	end
	
	local spawncord =  getElementData ( source, "SpawnCoordinates" ) 
	local x, y, z, rz  = unpack(spawncord)
	
	local job = getElementData ( source, "SAEGVehicles:JobRestriction" ) or false
	
	playerVehicles[p] = createVehicle ( id, x, y, z, 0, 0, rz )
	exports['SAEGLogs']:outputActionLog ( getPlayerName ( p ).." spawned a(n) "..getVehicleNameFromModel ( id ) )
	--exports['SAEGJobs']:create3DText ( getPlayerName ( p ).."'s Vehicle", { 0, 0, 0.5 }, { 255, 255, 255 }, playerVehicles[p], { 7, true } )
	if ( warp and isElement ( playerVehicles[p] ) ) then
		warpPedIntoVehicle ( p, playerVehicles[p] )
	end
	
	if job then
		setElementData ( playerVehicles[p], "SAEGAntiRestart:VehicleJobRestriction", tostring ( job ) )
		addEventHandler ( "onVehicleStartEnter", playerVehicles[p], checkRestrictions )
	end

	return playerVehicles[p]
end 

 

Posted
21 minutes ago, LoPollo said:

Line 11:

yes that's blank space O.o

 

if you mean line 8 it's because the data you retrieve from the source does not exists.

i.e. getElementData ( source, "SpawnCoordinates" ) returns false

i changed it to marker and same problem 

ahahaha sory xD yes i mean line 8 

Posted
Just now, Best-Killer said:

i changed it to marker and same problem 

The arg? If the returned value is still false, then the problem is the same. Can you post the blocks where you set  SpawnCoordinate?

Posted
1 minute ago, LoPollo said:

The arg? If the returned value is still false, then the problem is the same. Can you post the blocks where you set  SpawnCoordinate?

local spawners = { 
	['Free'] = { },
	['Job'] = { }
}
local spawnedVehciles = { }
function createFreeSpawner ( x, y, z, rz, sx, sy, sz )
	local i = #spawners['Free']+1
	local z = z - 1
	local sx, sy, sz = sx or x, sy or y, sz or z+1.5
	local rz = rz or 0
	spawners['Free'][i] = createMarker ( x, y, z, 'cylinder', 2, 255, 255, 255, 120 )
	setElementData ( spawners['Free'][i], "SpawnCoordinates", { sx, sy, sz, rz } )
	setElementData ( spawners['Free'][i], "SAEGVehicles:SpawnVehicleList", JobVehicles['Free'] )
	setElementData ( spawners['Free'][i], "SAEGVehicles:JobRestriction", false )
	addEventHandler ( "onMarkerHit", spawners['Free'][i], onSpawnerHit )
	return spawners['Free'][i]
end

 

Posted

I see you don't call  createPlayerVehicle after setting the data (at least... in this block). Make sure that createFreeSpawner is called BEFORE the function createPlayerVehicle is called, so the data does exist

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