Comments (11)
Just a minor note: Please keep in mind that support for 64 bit / DirectX 11 isn't available yet since we are working on collecting the data for it.
To the topic at hand: this error usually occured to me when attempting to access something although the library is not fully loaded / setup. In the very first version of my scanner thread I ended up using something like this:
while (true) {
var readResult = Reader.GetActors();
if (readResult != null && readResult.NewPC.Any()) {
try {
Console.WriteLine(readResult.PCEntities.FirstOrDefault().Value.CurrentUser.Name);
} catch(Exception _) {
Console.WriteLine("Fail.");
}
}
Thread.Sleep(100);
}
You error most likely occurs while doing something like this:
ActorReadResult readResult = Reader.GetActors();
return readResult.PCEntities.FirstOrDefault().Value.CurrentUser;
The readResult
will be successfully populated if the lib is fully initialized, otherwise it is null
thus the second line throws a NullPointerException
in the underlying structures. A very naive approach to possibly fix this, similiar to @viion, is to Thread.Sleep
after InitiateMemory
for ~2 seconds. To make it more robust though, add some null pointer checks then you can find out when you are starting to see proper data.
from sharlayan.
Oh thanks for letting me know about the DX11 stuff. Good to keep in mind.
As for the other issue, I'm getting this error just by running the above code snippet and not even trying to fetch any of the data. :/
Would you have any suggestions regarding that?
from sharlayan.
Can you quickly check whether there is a file called enums-x86.json
inside your output directory? The library downloads the enumerations from the API and then loads them - maybe something is wrong during this process. I am quickly setting up a test solution to try this myself, since I am no longer using the original library and wrote a lighter version for my project.
from sharlayan.
Oh i don't think there is any json files in the output directory when I built from the source or used the dll found in the distribution folder. Should i make a blank file?
from sharlayan.
How have you included the library? It has some NuGet data attached since it uses Newtonsoft.Json
for reading and parsing the files. This is my code and my project structure:
And this is the output folder (running dll and my app on x86
build config for this case):
If you don't have the DLL included in your solution, I suggested doing that instead of referencing the plain DLL just to be sure that the NuGet commands propagate to your project as well.
from sharlayan.
When you say included, does that mean adding it as a reference or using NuGet to add it? Sorry i was a little confused >.<
I've just been adding it using references before now.
from sharlayan.
Try to create a completely new solution for testing and clone the ffxivapp-memory repository. In your solution you should then have a testing application and the cloned repository added like me. This makes sure that the dependencies are registered to the solution for the build process. If you are then able to run my code from the screenshot with the same setup you're good to go to add the repository to your project as well.
from sharlayan.
Okay I think I worked out what the issue is, my code for DX11 was still being called and that code is what causes that exception to throw. When the DX9 initialisation is called it seems to work alright. 👍
On a quick side note, how would I go about fetching the current player's HP, MP and TP data? I know GetPlayerInfo() has MaxHP, MaxMP and MaxTP values but not the current values.
from sharlayan.
Alright, the DX11 part has no data anyways, thus no enums are downloaded and you get the NullPointerException
.
For reading data you shoul not use GetPlayerInfo
since this returns you data from the character sheet like Strength, Dexterity, Skill Speed etc. Refer to the code that @viion is using and that he has posted here. Remember to slightly change the getPlayer
method to check for null
like I did in my previous comments. The function will then return an ActorEntity
which stores all information about the player entity.
from sharlayan.
Awesome thank you so much. ^^
from sharlayan.
Thank you @ChristianIvicevic for following up on this. @roxaskeyheart Another thing you can do as well to ensure you don't get null reference exceptions is use https://davefancher.com/2014/08/14/c-6-0-null-propagation-operator/.
Example:
var name = readResult?.PCEntities?.FirstOrDefault()?.Value?.CurrentUser?.Name
if (!string.IsNullOrEmptyOrWhiteSpace(name)) {
// do stuff
}
With this it won't throw an error and you have access to the property
from sharlayan.
Related Issues (20)
- Broken since patch HOT 6
- Collection of 64bit Offsets, Structures and Enums for Patch 3.5 HOT 4
- Collecting Emnity Data and Creating list HOT 5
- 3.55a Offsets HOT 1
- Updated offset for ZONEINFO
- Feature Request for Data Reading bool
- PlayerEntity memory incorrect? HOT 5
- PlayerEntity does not have RDM and SAM. HOT 1
- NewNPC always contains Marketboard and Summoning Bell HOT 1
- Key name is wrong in Zones JSON HOT 1
- TargetID offset for ActorEntity
- Inventory information seems broken HOT 2
- How to get player position? HOT 1
- Read contents of crafting logs
- mousover target not working?
- Non existent JSONCacheDirectory silently fails json get from api
- Free Company chest 4 and 5 missing from enum
- A couple things broken with 6.1 patch HOT 2
- Patch 6.3, a couple offset changes HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sharlayan.