Viudes Posted August 12, 2017 Share Posted August 12, 2017 say always error "stack overflow" How i can fix this? function spawnVehicle(x,y,z,VehicleName) id = getVehicleModelFromName(VehicleName) spawnVeh = spawnVehicle (id, -2322.58496, -1622.78491, 483.70908) end addEvent("onSpawnVehicle", true) addEventHandler("onSpawnVehicle",getRootElement(),spawnVehicle) Link to comment
NeXuS™ Posted August 12, 2017 Share Posted August 12, 2017 function spawnVehicleF(x,y,z,VehicleName) id = getVehicleModelFromName(VehicleName) spawnVeh = spawnVehicle(id, -2322.58496, -1622.78491, 483.70908) end addEvent("onSpawnVehicle", true) addEventHandler("onSpawnVehicle",getRootElement(),spawnVehicleF) You can't name the function the same as you'd call the default MTA function or it'll recreate it. 1 Link to comment
Rockyz Posted August 12, 2017 Share Posted August 12, 2017 Basically you can do like this local _spawn = spawnVehicle function spawnVehicle ( x, y, z, VehicleName ) _spawn ( getVehicleModelFromName ( VehicleName ), -2322.58496, -1622.78491, 483.70908 ) end 1 Link to comment
Administrators Lpsd Posted August 12, 2017 Administrators Share Posted August 12, 2017 function mySpawnVehicle(x,y,z,VehicleName) id = getVehicleModelFromName(VehicleName) spawnVeh = spawnVehicle (id, -2322.58496, -1622.78491, 483.70908) end addEvent("onSpawnVehicle", true) addEventHandler("onSpawnVehicle",getRootElement(),mySpawnVehicle) Don't overwrite function names unless you know what you are doing. 1 Link to comment
_DrXenon Posted August 12, 2017 Share Posted August 12, 2017 Stack overflaw because you called spawnVehicle function within your re-defined spawnVehicle function, this will cause the function to be called infinite times and cause a stack overflaw. 1 Link to comment
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