Jump to content

Stack overflow


wesleywillems17

Recommended Posts

Hi everybody,

 

I'm creating a verhicle spawner for my police job but i have a problem.

The script won't load and debug says: ERROR: SRpolice/vehicleC.lua:19 Stack overflow

vehicleC.lua:

local VehicleMarkerP = createMarker ( 1579.60, -1635.33, 12.56, "cylinder", 1, 0, 0, 255, 255 )

local cars =
{
    { 1552.50, -1606.20, 13.19 };
    { 1556.70, -1606.20, 13.19 };
    { 1560.90, -1606.20, 13.19 };
    { 1565.09, -1606.20, 13.19 };
    { 1569.29, -1606.20, 13.19 };
    { 1573.50, -1606.20, 13.19 };
    { 1577.70, -1606.20, 13.19 };
    { 1581.90, -1606.20, 13.19 };
    { 1586.09, -1606.20, 13.19 };
    { 1590.29, -1606.20, 13.19 };
    { 1594.50, -1606.20, 13.19 };
}
	
function SpawnCopCar ()
    return unpack ( cars [ math.random ( #cars ) ] )
end

giveVehicleGUI = guiCreateWindow(0.4, 0.45, 0.2, 0.1, "Want a free police car?", true)
	guiSetVisible ( giveVehicleGUI, false )
	guiWindowSetMovable ( giveVehicleGUI, false )
	guiWindowSetSizable ( giveVehicleGUI, false )
VehGUItext = guiCreateLabel(0.0, 0.0, 1.0, 1.0, "Press enter to get a free police vehicle.\nWalk out of the marker to quit this panel.", true, giveVehicleGUI)
	guiLabelSetHorizontalAlign(VehGUItext, "center", false)
	guiLabelSetVerticalAlign(VehGUItext,"center")

function createVehicle ()
    x, y, z = SpawnCopCar ()
    local CopCar = createVehicle ( 596, x, y, z, 0, 0, 180 )
	warpPedIntoVehicle ( source, CopCar )
end
addEvent("CreateVehicleCop", true)
addEventHandler ( "CreateVehicleCop", root, createVehicle )

function giveAVehicle( hitPlayer )
	guiSetVisible ( giveVehicleGUI, true )
	triggerServerEvent ( "CreateVehicleCop", hitPlayer )
end
addEventHandler ( "onClientMarkerHit", VehicleMarkerP, giveAVehicle )

function QuitVehPanel ( leavingPlayer, matchingDimension )
	guiSetVisible ( giveVehicleGUI, false )
end
addEventHandler ( "onClientMarkerLeave", VehicleMarkerP, QuitVehPanel )

I'm busy working on it so it is a little bugy but how can i fix the stack overflow and what does it mean? :)

Link to post

Thx it worked! :) Also everytime i join my server and start the debug it says: ERROR: freeroam\gui.lua:24 attempt to index local 'wnd' (a nil value)
 

GUI.lua:24:

function createWindow(wnd, rebuild)
	if wnd.element then
		if rebuild then
			destroyElement(wnd.element)
		else
			guiSetVisible(wnd.element, true)
			guiBringToFront(wnd.element)
			g_openedWindows[wnd] = true
			if wnd.oncreate then
				wnd.oncreate()
			end
			return
		end
	end
	
	_planWindow(wnd)
	_buildWindow(wnd)
end

I'm not a pro scripter but i'm still busy learning it but i have really no idea what i need to edit/remove here. :P

Link to post

" attempt to index local 'wnd' (a nil value) " means what it says, 'wnd' is a nil value and you are using it as if it was a table. Why do you even have that createWindow function? I'd say something like that is more of an unnecessary complexity. Where ever your script is calling createWindow it's not passing a table as argument 1, if you don't know how to use createWindow then you need to either stop using it and call guiCreateWIndow normally, or read the documentation about it where ever you found that code.

Link to post

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