Community Forum

Error: Running LUA method 'packetReceived'.

Forum Overview >> Scripting

Created01.12.2017 08:22

Simon Fab (fabinho15000) 01.12.2017 08:22
Can someone explain to me how to remove this error :

Error: Running LUA method 'packetReceived'.
dataS/scripts/vehicles/specializations/Baler.lua(903) : attempt to index local 'bale' (a nil value)

I've this error just on verygames server not in solo. I created clover balls and gave them a path to the map with a lua script. The balers makes the balls, no problem, and they remain visible in game that's why I do not understand this error.

Here is the script i've made :

local fileName = g_currentModDirectory.."mods/FS17_LeBoutDuMonde/baleTypes/squarebales/squarebale_trefle_violet_windrow_240.i3d";
local modDir = g_currentModDirectory;
print("BaleExtension V1.0 (by FS15_mapping) registering "..fileName)

local fileNameSquarebale_trefle_violet_windrow = g_currentModDirectory.."mods/FS17_LeBoutDuMonde/baleTypes/squarebales/squarebale_trefle_violet_windrow_240.i3d";

local oldloadSharedI3DFile = Utils.loadSharedI3DFile;
function Utils.loadSharedI3DFile(filename, baseDir, ...)

local pos = string.find(filename,':/',1);
if pos ~= nil then
baseDir = "";

pos = string.find(filename,':/',3);

if pos ~= nil then
filename = string.sub(filename,pos-1)

pos = string.find(filename,'mods/FS17_LeBoutDuMonde/baleTypes/')
if pos ~= nil then
if not fileExists(Utils.getNoNil(baseDir,"")..filename) then
-- print("BaleExtension Check "..Utils.getNoNil(baseDir,"")..filename)
baseDir = "";
filename = modDir..string.sub(filename,pos+24);
-- print("suggested solution: "..filename)

local id = oldloadSharedI3DFile(filename, baseDir, ...);
if id == 0 then
-- print("ERROR CAUGHT!")
-- print("A "..baseDir)
-- print("B "..filename)
-- print("C "..Utils.getNoNil(baseDir,"")..filename)

return id

Thanks you for your reply.

Lennart Van De Velden (HFH_Lkey) 15.08.2018 16:47
Have you fixed the problem

Aden Kuenzi (akuenzi) 05.01.2019 02:15
Hi Simon Fab,

I don't know if you ever found a fix for this, but I've run into the same error on a dedicated server for FS '17. I did some testing and learned that the error will pop even when there aren't any mods activated on the server. The error only seems to pop in a very specific instance:

When the server is first started up, and I log into it for the first time following the start-up, and then I attempt to bale something where the baler already has a bale or two in it... THAT'S when the error pops. It pops multiple times as I run the baler forward picking up material, and stops popping when I cease baling. However, if I exit the server session, and rejoin, the error is now gone. If the baler was empty to start with, then I don't think the error will pop.

The error seems to have something to do with the baler starting out with a bale or two in it... and communication between server and client of that fact. But I have no idea how to fix it, in spite of having read 'baler' and 'bale' code for hours. My simple workaround when restarting the server is to simply join once, then leave, and then rejoin. And I think that eliminates the problem... for some reason.

Jos Kuijpers (Unknown) 06.01.2019 14:41
Note that with packetReceived errors the problem could be somewhere else completely:
Every part of the system that reads, says: read a string, or read a 32 bit integer, or read a 1 bit bool.
If any of this code fails or is incorrect, the reading goes out of sync with what is actually in the stream.

For example:
if the server sent something like a float32, bool, int32. and then the client reads float32, bool, bool, there are 31 unread bits (the exact position is a bit more complex due to how we compress this all). That means that the NEXT part that is read causes issues.
So with these errors the problem could have been in the code before. And it is quite hard to find the issue but it could be in a mod.

(Note that this might not be the problem here, just for general information)

No idea what you do here: filename = modDir..string.sub(filename,pos+24); but it seems super error prone. What is this 24?

Note: Log in to post. Create a new account here.