Error trying to configure esx_addonaccount - lua

I am trying to make a fivem server and have been able to configure esx_addonaccount once before, but now that I have needed to restart my project it is not seeming to work. My database is considered fine, and I am running a completely vanilla install minus the esx framework plugins and esx_addonaccount, which is the problem. This occurs when I load into the server anytime.
Error running system event handling function for resource esx_addonaccount: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: #esx_addonaccount/server/main.lua:87: attempt to index a nil value (local 'xPlayer')
stack traceback:
#esx_addonaccount/server/main.lua:87: in upvalue 'handler'
citizen:/scripting/lua/scheduler.lua:219: in function <citizen:/scripting/lua/scheduler.lua:218>
stack traceback:
[C]: in function 'error'
citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
citizen:/scripting/lua/scheduler.lua:218: in function <citizen:/scripting/lua/scheduler.lua:182>
Please help!!

#esx_addonaccount/server/main.lua:87: attempt to index a nil value (local 'xPlayer')
Above is a line from your error. It basically says that in resource esx_addonaccount, in folder ./server/, in file main.lua, in line 87 you are trying to access xPlayer variable, but in this specific case it equals nil. This means that either you have not initialized ESX correctly or somehow xPlayer is not existing - eg. player with given ID doesn't exist.
The best bet would be to check the whole 'path' of this variable - where is it created, initialized and populated with data.
ESX resources should work out of the box, so if it doesn't, then try to follow the installation instructions in their README files or on github and see if you did everything to correctly install them on your server.

Related

PowerDNS - DNSQuestion is always nil

I have setup a PowerDNS (4.0.4-1+deb9u4) upon Debian 9 with a MySQL backend successfully and the system was resolving hosts correctly. I am attempting to add scripting to the recursor and have used the examples, Lua script examples. I have pointed the pdns-resolver's conf correctly at my lua script, and I see my log statements print correctly, but I am consistently receiving an error regarding the DNSQuestion instance being empty for all of the example lua functions.
For example:
function preresolve(dq)
pdnslog("Got question for "..dq.qname:toString().." from "..dq.remoteaddr:toString().." to "..dq.localaddr:toString())
return true;
end
Results in :
STL error (a.root-servers.net/A from 127.0.0.1): Trying to cast a lua variable from "nil" to "b" (meaning the DNSQuestion instance is null).
Clearly the lua script is running, but for some reason, all the dq instances are empty.
Is there anything that I may have misunderstood or am missing that would cause the parameter to be nil?
Have your function return true or false so it will not return nil by default.

realize parameter change after reboot in ESP wifi (Lua)

I want to change the behaviour of my ESP module if some of my parameter was changed and then was restarted. I mean something like this.
if (????) then
print ("default value") else
print ("modified value") end
First I thought of writing a flag into a file, but it causes error during boot if it is not existing yet.
Any better idea?
If you want to store values beyond reboot you have to store them in some non-volatile memory. So using a file is a good way as you already suggested.
Unfortunately you did not provide the error message you get when it is not existing yet and you did not say if the flag or the file does not exist.
What you have to do is handling the error. So if your file does not exist ask the user to create a new one or create a file with default content from your program.
Same goes with the flag. If the file does not contain a flag yet, use a default value or ask the user to give one.
It's not bad or wrong to get errors as long learn from them or handle them properly.
io.open(filename[,mode]) returns nil plus an error message in case of an error.
So simply do something like:
local fileName = "C:\\superfile.txt"
local fileHandle, errorMsg = io.open(fileName)
if not fileHandle then
print("File access error: ", errorMsg)
-- add some error handling here
end
So in case you don't have that file you'll get
File access error: C:\superfile.txt: No such file or directory

Calling back to a main file from a dofile in lua

Say i have two files:
One is called mainFile.lua:
function altDoFile(name)
dofile(debug.getinfo(1).source:sub(debug.getinfo(1).source:find(".*\\")):sub(2)..name)
end
altDoFile("libs/caller.lua")
function callBack()
print "called back"
end
doCallback()
The other called caller.lua, located in a libs folder:
function doCallback()
print "performing call back"
_G["callBack"]()
end
The output of running the first file is then:
"performing call back"
Then nothing more, i'm missing a line!
Why is callBack never getting executed? is this intended behavior, and how do i get around it?
The fact that the function is getting called from string is important, so that can't be changed.
UPDATE:
I have tested it further, and the _G["callBack"] does resolve to a function (type()) but it still does not get called
Why not just use dofile?
It seems that the purpose of altDoFile is to replace the running script's filename with the script you want to call thereby creating an absolute path. In this case the path for caller.lua is a relative path so you shouldn't need to change anything for Lua to load the file.
Refactoring your code to this:
dofile("libs/caller.lua")
function callBack()
print "called back"
end
doCallback()
Seems to give the result you are looking for:
$ lua mainFile.lua
performing call back
called back
Just as a side note, altDoFile throws an error if the path does not contain a \ character. Windows uses the backslash for path names, but other operating systems like Linux and MacOS do not.
In my case running your script on Linux throws an error because string.find returns nill instead of an index.
lua: mainFile.lua:2: bad argument #1 to 'sub' (number expected, got nil)
If you need to know the working path of the main script, why not pass it as a command line argument:
C:\LuaFiles> lua mainFile.lua C:/LuaFiles
Then in Lua:
local working_path = arg[1] or '.'
dofile(working_path..'/libs/caller.lua')
If you just want to be able to walk back up one directory, you can also modify the loader
package.path = ";../?.lua" .. package.path;
So then you could run your file by doing:
require("caller")
dofile "../Untitled/SensorLib.lua" --use backpath librarys
Best Regards
K.

Unable to Pass parameters to MSI thro Msiexec via command prompt

Hii ppl I am trying to pass parameter thro msiexec in command prompt . The problem is eventhough the parameter is passed properly the value doesnt get reflected in the OnBeforeInstallEvent. Therefore the msi doesnt get installed.
The OnBeforeInstall is written C#.net framework 2.09 (VS 2005) and the event call is given below,
string serverName=Context.Parameters["SERVERNAME"].
For example, In the custom action the parameter is properly declared as /SERVERNAME=[SERVERNAME] so as to access the server name.
There is no problem when I install thro normal UI mode when I pass the parameter thro Msiexec the value doesnt get reflected at the OnBeforeInstall event. I even tried logging the flow of installation thro MSIEXEC /Log , the value gets changed in log ( shown below)
PROPERTY CHANGE: Adding SERVERNAME property. Its value is 'machine1'.
I have given below the msiexec command which I use to pass values,
msiexec.exe /i "C:\Server.msi" /l*v "C:\Server.txt" ALLUSERS=1 REBOOT=ReallySupress TARGETDIR="C:\Program Files\Server" SERVERNAME="machine1" PORT="9090"
but on reaching ONBeforeInstall the value is empty (show below).
Error 1001. An exception occurred in the OnBeforeInstall event handler of Server.ServicesInstaller. --> Installation cannot be continued as some of the installation parameters are not given.
More Info -Server Name cannot be empty.
DEBUG: Error 2769: Custom Action _542E7AC5_7403_434A_874B_DE2872A4848D.install did not close 1 MSIHANDLEs.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2769.
Moreover, the Operating system is Win 2003 . I even tried the Msiexec in Win XP too Still no go. The SERVERNAME is the property name of one of the textboxes in the TextBox2 Dialog box of setup kit. While observing the installation log , the property change event is recognizing the value change for SERVERNAME but It becomes null while reaching the OnBeforeInstall event don kno wy.
As said earlier it works perfectly in normal UI mode. I even tried modifying the property table of Server.msi thro ORCA(as given below).
Table :Property
Row :SecureCustomProperties Property -> SecureCustomProperties Changed value from NEWERPRODUCTFOUND to NEWERPRODUCTFOUND;SERVERNAME
Still no go
Please Help.
Many thanks,
byfour
Hii PPl,
I fixed it myself I jus removed the rows like CustomTextA_SetProperty_EDIT1 from customaction table and their refferences in other tables using ORCA and it solved the issue.
Many thanks,
byfour

Windows Service Starts then Stops

I have a Windows Service that I inherited from a departed developer. The Windows Service is running just fine in the QA environment. When I install the service and run it locally, I receive this error:
Service cannot be started. System.InvalidOperationException: The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly.
Here is the code:
ExternalDataExchangeService exchangeService = new ExternalDataExchangeService();
workflowRuntime.AddService(exchangeService);
workflowRuntime.AddService(new SqlTrackingService(AppContext.SqlConnectionImportLog));
ChallengerWorkflowService challengerWorkflowService = new ChallengerWorkflowService();
challengerWorkflowService.SendDataEvent += new EventHandler<SendDataEventArgs>(challengerWorkflowService_SendDataEvent);
workflowRuntime.AddService(challengerWorkflowService);
workflowRuntime.StartRuntime(); <---- Exception is thrown here.
Check for installer code. Often you will find counters are created within an installation (which is going to of been run under admin privledges on client site) and the code then uses them as though they exist - but will not try create them because they do not expect to have the permissions.
If you just get the source and then try run it, the counters / counter classes do not exist so you fall over immediately. (Alternatively check whether the counter exists / you have local admin if they wrote the code to create it in the service.)
Seen it before so mentioned it.
Attach Debugger and break on InvalidOperationException (first-chance, i.e. when thrown)?

Resources