Guild icon
Ark Server Api
โ”€โ”€ ( Beginners | Topics ) โ”€โ”€ / ใ€๐Ÿ’ฌใ€‘แด…ษช๊œฑแด„แดœ๊œฑ๊œฑษชแดษด-ส™
Avatar
Hello, I'm an ARK player and a web developer so I've some basic concepts in C++. I'd like to create a plugin to notify Discord's channel about player inactivity. I'm playing from MacOS using Nvidia Geforce Now. Do I need a Windows computer with ARK installed to develop my plugin ? Is there any updated resource to start ? (edited)
Avatar
@Saxor I'm no professional, but if you have git and access to reliable C++ compiler then you are good to go. No need for Windows with ARK as long as you already have server on Windows. As for your second question it's hard to find something that is up to date. At least I had problems with it. But don't be afraid, if I sorted things out I'm more than sure you will as well.
Avatar
any ideas where i can find tutorials to learn how to create a plugin, have very basic C++ knowledge but I have no idea where to start and there seems to be no tutorials out there. Anyone know of any?
Avatar
Good the KalsCrossChat plugin works what is chat in the game and discord but the destruction notices are not working, I passed it to English and not anything else to do,? thanks. (edited)
Avatar
How do i get the name (for example "Tek Foundation") from "APrimalStructure"? ๐Ÿ˜„
Avatar
APrimalStructure::DescriptiveNameField()
Avatar
Thanks a lot ๐Ÿ˜„ i tried to use "NameField" all the time :/ this works ty โค๏ธ
Avatar
NameField returns the BP name, like the name the blueprint file has. For example "Floor_Metal_C_1" (edited)
Avatar
ya i saw that, but didnt found DescriptiveNameField() Btw this shows me the german words, prob just Server / game setting right?
Avatar
Yes, it depends on server culture (edited)
Avatar
Ok ๐Ÿ‘ Thanks alot for your quick help
Avatar
No worries, feel free to ask anything else
๐Ÿ‘ 1
Avatar
any ideas where i can find tutorials to learn how to create a plugin, have very basic C++ knowledge but I have no idea where to start and there seems to be no tutorials out there. Anyone know of any?
@Browne there's a great google doc here: https://docs.google.com/document/d/1U4kRBevkLbXxcVMzKTmsjRKFkCEjtG46bfi5TdHNluQ/edit
This guide is based on the Visual Studio Community 2019 version install Prerequisites: 1. https://visualstudio.microsoft.com/vs/ 2. https://github.com/Michidu/ARK-Server-API/archive/master.zip Step N1: Install Visual Studio by the link given on the first prerequ...
Avatar
I have it all set up however im not sure about the code itself, as I said my knowledge is very basic but its the code itself im struggling with
Avatar
@Ashington
Avatar
ah right, what are you trying to do?
Avatar
basically i have used C++ before but never for anything like this, its way beyond what i know and i want to start learning i have looked everywhere for videos, turtorials and shit like that but i cant find anything and because im completely new to it im not even sure what exactly im looking for outside of searching ark plugin tutorials, so im looking for some resources to help me learn from basics up to creating my own plugin from scratch any help would be appretiated @Ashington
Avatar
ah right, makes sense
12:26 AM
best source of information for me was the plugins out there - a lot of the functionality has been done there first so the interactions with the API can be sourced from there
12:27 AM
in terms of other management in memory/files etc that's just a standard programming problem which you'd have to tackle by designing your systems/writing tests etc
12:28 AM
I would say the first thing you should work out is what is possible using the API, and then work around that when designing the rest of your system, I did all the easy stuff first and found that it was difficult to do the actual interaction with the API (lesson learned)
12:28 AM
what are you trying to make as a plugin?
Avatar
I have nothing in mind at the moment, will probably start by recreating existing plugins, easy ones
12:32 AM
work my way to harder ones
12:32 AM
then work on developing my own
12:33 AM
however my knowledge of C++ is so limited now that its probably betterr saying i know nothing
12:33 AM
because it has been a very long time since i have used it
12:33 AM
so for me its going to be a matter of re-learning the code
12:34 AM
then learning all the plugin sort of stuff which i dont even understand yet
Avatar
Hey, iโ€™d like to create a cluster. Any advice about hosting? (edited)
Avatar
Frostยฎ 11/6/2020 4:26 PM
Hetzner serverbörse
4:29 PM
Are u thar danish guy?
Avatar
If you're talking to me, I'm not Danish, I'm a French
Avatar
Does anyone know how to get the FTribeAlliance by an AllianceID? ๐Ÿ˜„
Avatar
Try something like this
10:39 AM
int alliance_id; AShooterPlayerState* State = static_cast<AShooterPlayerState*>(shooter_pc->PlayerStateField()); FTribeAlliance* FTA = static_cast <FTribeAlliance*>(State->MyTribeDataField()->FindTribeAlliance(alliance_id));
10:39 AM
tho you need to get the shooter pc first
Avatar
good, see I have 7 servers of the 6 the plugin load perfect and in one strip 11/08/20 06:44 [KalsCrossChat][info] ServerKey ? Ragnarok CreateProcess failed (5). which means that mistake thank you.
Avatar
```cpp int alliance_id; AShooterPlayerState* State = static_cast<AShooterPlayerState*>(shooter_pc->PlayerStateField()); FTribeAlliance* FTA = static_cast <FTribeAlliance*>(State->MyTribeDataField()->FindTribeAlliance(alliance_id)); ```
@Foppa whats type is shooter_pc in that case?
(edited)
3:23 PM
Because, the alliance i want, (where i got the Id from, i got nothing except the id :/
Avatar
AShooterPlayerController* shooter_pc
8:09 PM
What do you want to have in return?
Avatar
I have the Alliance Id and what the FTribeAlliance typ of that, from that i would take the members (tribes) of the alliance
Avatar
found a way around it / found that i got something else i can work with
Avatar
ark website access error
Avatar
You don't have the pdb file installed so we can't know what crashes ๐Ÿคท
Avatar
so i need to put the pdb file of the plugin into the plugin folder?
Avatar
If you want more detailed crash logs yes
Avatar
ok, then gimme a few min
Avatar
ok, weird, i copy pasted the code into a another plugin and now it doesnt crash?!! xD
5:16 PM
Ah ik why; this: Log::GetLog()->info("tribemembersInviter: {}", alliance.MembersTribeIDField().Num()); returns me this: -623357952 and cuz its negative it doesnt go into the next step
Avatar
hello i cant compile...
11:27 AM
Avatar
You are redefining an already existing struct
Avatar
@Pelayori thanks! i did it!
Avatar
do someone here know how to use ServerRequestRemoveAllianceMember(AllianceId, MemberId) i've tried saving the AllianceId after i force created one but it's changing all the time i leave manually
Avatar
I think i tried that one, but if i remember correct, that didnt work, try using this ServerRequestRemoveAllianceMember_Implementation
Avatar
thanks that's working. next thing is that i don't get the right ID directly. I have to request leaving once (and denie it with a hook) to get the correct Alliance ID how do you get the correct one?
10:18 PM
TArray<FTribeAlliance> allys = aPlState->MyTribeDataField()->TribeAlliancesField(); if (allys.Num() > 0) { m_AllianceID = allys[0].AllianceIDField(); } that's how i get it now which is the wrong one -.-
Avatar
thats an issue i currently have, too. I am not sure, but i guess it doesnt get the FTribeAlliance correctly, sth there is broken i guess. Maybe someone else can help there ๐Ÿ˜„
Avatar
So alliances num is greater than zero but the actual FTribeAlliance is empty?
Avatar
not really empty but "wrong" the Id isnt correct and i couldnt get the tribe id´s of the tribes in that alliance with MembersTribeIDField() (edited)
Avatar
it's just little bit confusing how to retrive the correct data...
2:45 AM
But this works: AShooterPlayerState* state = static_cast<AShooterPlayerState*>(shooter_pc->PlayerStateField()); if (state) { FTribeData* mytribedata = state->MyTribeDataField(); int mytribe_id = state->TargetingTeamField(); Log::GetLog()->info("Checking For Tribe ID: {}", mytribe_id); int tribeMemberCount = mytribedata->MembersPlayerDataIDField().Num(); Log::GetLog()->info("My Member Count: {}", tribeMemberCount); // will return the count of players in your tribe if (tribeMemberCount > 0) { int alliancesCount = mytribedata->TribeAlliancesField().Num(); Log::GetLog()->info("My Alliance Count: {}", alliancesCount); // Will return the count of how many alliances you have int allyMemberCount = state->MyTribeDataField()->TribeAlliancesField().GetData()->MembersTribeIDField().Num(); Log::GetLog()->info("My Alliance Member Count: {}", allyMemberCount); // Will return the count of you and the members of the alliance (edited)
๐Ÿ‘๐Ÿผ 1
Avatar
is there a second part to this?
Avatar
`struct FTribeAlliance { FString AllianceNameField; unsigned int AllianceIDField; TArray<FString> MembersTribeNameField; TArray<unsigned int> MembersTribeIDField; TArray<unsigned int> AdminsTribeIDField; }; /* struct FTribeAlliance { FString& AllianceNameField() { return GetNativePointerField<FString>(this, "FTribeAlliance.AllianceName"); } unsigned int& AllianceIDField() { return GetNativePointerField<unsigned int>(this, "FTribeAlliance.AllianceID"); } TArray<FString>& MembersTribeNameField() { return GetNativePointerField<TArray<FString>>(this, "FTribeAlliance.MembersTribeName"); } TArray<unsigned int>& MembersTribeIDField() { return GetNativePointerField<TArray<unsigned int>>(this, "FTribeAlliance.MembersTribeID"); } TArray<unsigned int>& AdminsTribeIDField() { return GetNativePointerField<TArray<unsigned int>>(this, "FTribeAlliance.AdminsTribeID"); } // Functions FString* GetDescriptiveString(FString* result) { return NativeCall<FString, FString>(this, "FTribeAlliance.GetDescriptiveString", result); } bool operator==(FTribeAlliance* Other) { return NativeCall<bool, FTribeAlliance*>(this, "FTribeAlliance.operator==", Other); } static UScriptStruct* StaticStruct() { return NativeCall<UScriptStruct*>(nullptr, "FTribeAlliance.StaticStruct"); } }; */` found it you have to replace the Struct in Tribe.h and then it works
(edited)
Avatar
not rly tho
Avatar
@ouzo1986 i get error if i use the struct like that, prob because it doesnt have the pointers ๐Ÿค”
10:28 AM
can you maybe send me the code that worked for you? ๐Ÿ˜„
Avatar
@SorPlex that struct override and this: AShooterPlayerState* aPlState = static_cast<AShooterPlayerState*>(ps); TArray<FTribeAlliance> allys = aPlState->MyTribeDataField()->TribeAlliancesField(); if (allys.Num() > 0) m_AllianceID = allys[0].AllianceIDField; works fine for me. (edited)
Avatar
and you just used that struc without any pointers or so?
10:46 AM
cuz i get an error without these pointers https://prnt.sc/vkn0m8
10:46 AM
@ouzo1986
Avatar
yes i can. don't know why you can't
Avatar
you also use the latest api right? xDD
Avatar
was there an update in the last three days?
Avatar
idk, but then i guess we have the same
11:01 AM
weird
Avatar
I'm using Visual studio 2017 maybe that's the difference
Avatar
im using 19, but would be weird, i redownloaded the api, ill test it again
Avatar
seems to work now, updated the tribe.h and used the latest api
1:48 PM
ty
Avatar
ะ”ะธะฒะพะณะปัŽะบ 11/21/2020 6:24 PM
@staff after server starting my plugin does not respond to chat commands. If I reload plugin he start react to chat commands, but after time again not responding. how fix this problem? Plugin source - https://pastebin.com/WnWLW7LA
Avatar
You shouldn't be using precompiled headers (edited)
Avatar
Avatar
Pelayori
You shouldn't be using precompiled headers (edited)
ะ”ะธะฒะพะณะปัŽะบ 11/21/2020 6:30 PM
precompiled headers already disabled
Avatar
You are including pch.h
6:34 PM
@ะ”ะธะฒะพะณะปัŽะบ
Avatar
ะ”ะธะฒะพะณะปัŽะบ 11/21/2020 6:34 PM
yeah, thanks, I am testing your solution
Avatar
Avatar
Pelayori
You are including pch.h
ะ”ะธะฒะพะณะปัŽะบ 11/21/2020 6:38 PM
after server started chat command not working
6:39 PM
after reloading plugins started response to chat command
Avatar
By plugins.unload and plugins.load?
Avatar
ะ”ะธะฒะพะณะปัŽะบ 11/21/2020 6:39 PM
yeah
6:40 PM
but now plugin stopped response...
6:41 PM
I think after switched to other window by Alt-Tab?
Avatar
Avatar
Pelayori
By plugins.unload and plugins.load?
ะ”ะธะฒะพะณะปัŽะบ 11/21/2020 7:05 PM
where can I find log messages generated by command Log::GetLog()->debug("Testing 123, please load the project for me ;)"); ? In console window they don't show
Avatar
Then the plugin isn't loading/unloading
Avatar
ะ”ะธะฒะพะณะปัŽะบ 11/21/2020 7:06 PM
rcon console say "successfully unloaded\loaded plugin"
Avatar
Oh well, ->debug might not show if it isn't compiled with debug
7:07 PM
try ->info
Avatar
ะ”ะธะฒะพะณะปัŽะบ 11/21/2020 7:13 PM
It detach my plugin by unknown reason...
Avatar
ะ”ะธะฒะพะณะปัŽะบ 11/21/2020 7:23 PM
oh... I searched this thread by 'detach' word and founded same problem) lost break in dll attach switch... deleted thread attach\detach cases and now it's work) thanks)
7:26 PM
there is another question... why melee, speed and max is 0?
Avatar
ะ”ะธะฒะพะณะปัŽะบ 11/21/2020 7:51 PM
okay GetBaseStatusValue return stats on 1 level dino I mean. How can I get stats of dino which will be used on mating?
Avatar
does someone know how to create this type "FUniqueNetIdUInt64" as variable?
Avatar
@ouzo1986 what do you want to use it on? I can't see a use for it. I believe it's also empty on ark code, I'd stay away from that (edited)
Avatar
it's defined in GameMode: void AllowPlayerToJoinNoCheck(FUniqueNetIdUInt64* PlayerId) { NativeCall<void, FUniqueNetIdUInt64*>(this, "AShooterGameMode.AllowPlayerToJoinNoCheck", PlayerId); }
Avatar
This is the definition of FUniqueNetIdInt64: struct FUniqueNetIdUInt64 : FUniqueNetId { unsigned __int64 UniqueNetId; };
4:46 PM
Just declare a new funiquenetidUInt64, set its uniquenetid field to the id you want and pass a pointer with &your_variable
4:46 PM
@ouzo1986
Avatar
thanks
Avatar
Hello everyone! Using the Improved Commands source code, I was able to create a updated dino stats plugin (my first plugin). It is quite simple and only shows the dino the players own. I would like to be able to also show wild dino stats and I am having a hard time figuring out what is the wild dino team. I have set the setcheatplayer true and looking at few dinos, but it shows different teams ids. The wild teams ids, is it a range? Or should I go about another way to figure out if a dino is wild or not?
Avatar
I believe it is 0
Avatar
Then perhaps the team id in game is different from the dino->TargetingTeamField()!
Avatar
In fact wild team id are between 0-10000 iirc (edited)
Avatar
that would explain the many teams id i am looking at!
Avatar
You also have APrimalDinoCharacter::BPIsTamed too, will return false on wild
Avatar
Hello Pelayori! We meed again! ๐Ÿ˜ฎ
12:48 AM
thanks for the help once again!
Avatar
No worries, I hang around here to help people
Avatar
Hello, I am in need enlightenment. I am trying to make a list of all players spawn points to put on Safezones plugin, I did that on Extinction map and took a few hours, so naturally I thought I should make a plugin to record the position of the player death and safe it to a file or log. So far o got this: void outPos(AShooterPlayerController* spc, FString* cmd, bool /**/) { if (spc) { FVector pos = spc->DefaultActorLocationField(); FString aaa = pos.ToString(); Log::GetLog()->info("Player position ({})", pos.ToString()); } } When the player type /outPos it should output to the screen, but my knowledge of c++ is limited and I cant figure out how to get the FString to the Log::GetLog()->info function. I keep getting the error โ€œCannot format argument. To enable the use of ostream operator<< include fmt/ostream.h. Otherwise provide an overload of format_arg.โ€ Any tips on how to proceed, is greatly appreciated
Avatar
You must provide std::string or TCHAR array. you can pass aaa.ToString()
2:07 PM
And to get player location you might want to use spc->GetPlayerCharacter()->RootComponentField()->RelativeLocationField()
Avatar
I cant believe I was putting pos.toString() ๐Ÿ˜ฎ
Avatar
Avatar
Pelayori
You must provide std::string or TCHAR array. you can pass aaa.ToString()
it worked. many thanks!
Avatar
No worries
Avatar
Hello again, when my plugin crashes, the server stops
6:29 PM
is there anyway to prevent that from happening ?
Avatar
SublimeStyle 12/12/2020 6:39 PM
Itโ€™s hard to say without a closer look. At a basic level, thatโ€™s what exceptions are for, but the engine is complex and itโ€™s possible handling a particular exception will still cause the server to crash. I would start by figuring out where itโ€™s crashing at and you can isolate the issue. Something like trying to access a null pointer should resolve itself just fine within a try/catch; just be mindful of performance.
Avatar
in this new update, everything is crashing, i was wandering if it would be possible prevent at least the plugins from crashing
6:49 PM
thanks!
Avatar
ran out of memory allocating 1015808 bytes with alignment 0. I think that might be the problem ๐Ÿ˜…
Avatar
SublimeStyle 12/12/2020 7:03 PM
Sounds like it could be a memory leak. Something like this could happen when, for example, building a large dataset in which each item is a pointer in memory. Check to make sure youโ€™re properly de-allocating your dynamic memory/variables.
Avatar
that might be a problem. I don't know how!
7:09 PM
but i will figure out, i hope. Thanks for the help!
Avatar
SublimeStyle 12/12/2020 7:13 PM
Start with a stack trace- it should popup a huge paragraph of text/code with line numbers (when the server crashes), you should be able to see within your plugin at what line it failed. I believe there are crash logs that you can access as well but not as familiar with that. I'm pretty oldschool and not as familiar with UE4 so I would suggest looking at how UE4 allocates/de-allocates memory and what class(es) you could use to help with that. But for good ol' C++ pointers/concepts, this youtuber is amazing (got me through my degree lol): https://www.youtube.com/watch?v=Fa6S8Pz924k
Avatar
i looks nice. i will give it a try. Thanks!
๐Ÿ‘ 1
Avatar
jraServerAPI 12/30/2020 7:05 AM
Hello ๐Ÿ™‚ Is there a function in the Api that returns the current player count? (edited)
Avatar
jraServerAPI 12/30/2020 7:55 AM
hmm i think i found it... int playerCount = ArkApi::GetApiUtils().GetShooterGameMode()->GetNumPlayers(); Will this return just the online player count or all players regardless of state?
Avatar
It actually calls this function directly: int GetNumPlayers() { return NativeCall<int>(this, "AGameMode.GetNumPlayers"); } I would say yes, but best way to get answers is just to log it!
Avatar
jraServerAPI 12/31/2020 11:23 PM
Yes, it returns the online player count ๐Ÿ‘
Avatar
Good day guys, i'm new, where can I find the documentation?
Avatar
Avatar
DragoKing
Good day guys, i'm new, where can I find the documentation?
I think there is nothing really like that unfortunately
Avatar
hey guys, is there something similar to javascript's Map().join() in c++?
6:44 AM
or am i better off just using JSON
6:45 AM
i'm trying to store all tribe members in a database, sorted by their tribe id, and my plan was to store the members by their character id in either one long string or a JSON object
Avatar
I need to serialize character inventory data and send it to my webserver. But to understand the structure and understand without a description is difficult. If anyone can help, I will be grateful.
Avatar
Deleted User 1/15/2021 6:55 AM
hi i downloaded the Ark Api Hook Generator but get a error could not create ssl/tls when opening the program can leave me a message of how to get it to work
Avatar
Deleted User 1/15/2021 7:11 AM
yes me too. Probably because of the github ssl version update. You need api hook generator rebuild.
7:12 AM
I have received the source and rebuilt it and am using it
7:12 AM
Tools i have made to make stuff a heck of a lot easier. - ownprox/Tools
๐Ÿ‘ 1
Avatar
Deleted User 1/17/2021 1:46 AM
can i ask how do u rebuild the source code i am very new only messed with Jason configs
Avatar
Deleted User 1/17/2021 5:00 AM
I opened and compiled the project in the visual studio 2019 community.
5:00 AM
There is nothing special.
Avatar
Deleted User 1/19/2021 12:58 AM
ok i will give it a go thanx
Avatar
Deleted User 1/20/2021 7:06 AM
hi i still get same message even after source code rebuild
7:06 AM
Avatar
ะ”ะธะฒะพะณะปัŽะบ 1/21/2021 7:14 AM
is it possible to somehow disable configs that turn off the lighting, shadows, leafage?
Avatar
hiii (edited)
7:22 PM
i'm fully new to ark pc and linux servers
7:22 PM
is there a way i can setup multiple servers on 1 machine?
7:22 PM
but all use the same code?
Avatar
SublimeStyle 1/26/2021 7:54 PM
that's how most, if not all, hosts do it for clusters... they just run them on separate ports (edited)
Avatar
well i just figured out
8:01 PM
ARK api needs windows
8:01 PM
Rip my work for 2 days ๐Ÿ˜ญ
Avatar
Frostยฎ 1/27/2021 3:12 PM
lol
3:12 PM
just host it on windows, even the dedicated running more smooth on windows
Avatar
SolaoBajiuik 2/3/2021 11:13 PM
I'm just starting on ArkAPI Development for Plugins. I'm thumbing through the calls in VisualStudio right now, but hoping someone can assist me faster here. What's the call to get a players exact location?
Avatar
SolaoBajiuik 2/4/2021 12:11 AM
Think it is FVector Location = player->GetPlayerCharacter()->RootComponentField()->RelativeLocationField();
12:11 AM
But, how trying to figure out distance between 2 locations
Avatar
SublimeStyle 2/4/2021 12:21 AM
there might be a util function for this, but there are offsets you have to apply to get the 100x100 coordinate values
Avatar
SolaoBajiuik 2/4/2021 12:23 AM
Thanks @SublimeStyle
๐Ÿ‘ 1
Avatar
Avatar
SolaoBajiuik
But, how trying to figure out distance between 2 locations
If you want to calculate the distance between 2 points, do something like: FMath::Abs((vector1 - vector2).Size())
8:05 AM
It will get you the distance in unreal units
Avatar
SolaoBajiuik 2/4/2021 1:29 PM
I used FVector::Distance(location1, location2) to get the distance (edited)
Avatar
Ohh didn't know that was a thing (edited)
Avatar
Hello. When i use AActor* actor = primal_character->GetAimedActor and the player is dead ou on thw spawn screen it crashes the server
6:38 PM
is there anyway to check to prevent the crash?
Avatar
check if primal_character is nullptr
6:40 PM
@Uaca
Avatar
ok. im going to learn how to do~it, thank you!
Avatar
just do if (primal_character) (edited)
7:19 PM
or if (primal_character != nullptr)
Avatar
Hello, Can someone tell me how can I debug the code ? I mean, in other language, we can execute directly from the IDE or somewhere else and use breakpoints or other things like that to check objects etc... But here, I'm a little lost because I don't know how I can debug correctly ? If someone have some tips for that. Thank you in advance
Avatar
Avatar
Neka
Hello, Can someone tell me how can I debug the code ? I mean, in other language, we can execute directly from the IDE or somewhere else and use breakpoints or other things like that to check objects etc... But here, I'm a little lost because I don't know how I can debug correctly ? If someone have some tips for that. Thank you in advance
SublimeStyle 2/7/2021 9:43 PM
Discover how to attach the Visual Studio debugger to a running process on a local or remote computer.
Avatar
@SublimeStyle Thank you very much ๐Ÿ™‚
๐Ÿ‘ 1
Avatar
SolaoBajiuik 2/8/2021 10:40 PM
Is there a safe way to save FVector to a json file and use it later, or would i need to setup some conversion process ?
Avatar
You could just store X Y Z in a json array, and with that array initialize another FVector from constructor when needed
Avatar
SolaoBajiuik 2/8/2021 10:56 PM
Is there technical documentation for the API that I can read through ?
10:56 PM
Trying to find how to split the player->GetPlayerCharacter()->RootComponentField()->RelativeLocationField() nowinto XYZ
Avatar
not really however most functions in the game are from UE directly so most likely you can just google the function itself
Avatar
SolaoBajiuik 2/8/2021 10:57 PM
K.. Thanks ๐Ÿ™‚
Avatar
Nvm that was too long lol
11:00 PM
You can do FVector.X for the components
Avatar
SolaoBajiuik 2/8/2021 11:00 PM
Now to find out how to get it BACK to an fVector so I can use FVector::Distance
Avatar
FVector(float x, float y, float z)
11:00 PM
That's the constructor
Avatar
SolaoBajiuik 2/8/2021 11:00 PM
Noice.. Thanks ๐Ÿ™‚
Avatar
Well, one of them
Avatar
SolaoBajiuik 2/8/2021 11:22 PM
Sorry about all the questions. I haven't done c++ in... almost a decade..
11:22 PM
11:22 PM
I'm seeing that. Attempting to figure out why.
Avatar
You need to add a reference to the function with &funcName
Avatar
SolaoBajiuik 2/9/2021 12:18 AM
Is it possible to use cSharp instead of cpp ?
Avatar
SolaoBajiuik 2/9/2021 12:35 AM
Apparently, I'm really rusty
Avatar
SolaoBajiuik 2/9/2021 1:10 AM
Anyone see 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\xtree(1458): message : see reference to function template instantiation 'std::_Tree_find_result<std::_Tree_node<std::pair<const StringType,nlohmann::basic_json<std::map,std::vector,StringType,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>,std::_Default_allocator_traits<_Alloc>::void_pointer> *> std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::_Find_lower_bound<_Other>(const _Keyty &) const' being compiled 1> with 1> [ 1> StringType=std::string, 1> _Alloc=std::allocator<std::pair<const std::string,nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>>, 1> _Kty=std::string, 1> _Ty=nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>, 1> _Pr=nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::object_comparator_t, 1> _Other=SIZE_T, 1> _Keyty=SIZE_T 1> ] When saving from a json variable to an ofstream file ?
Avatar
SolaoBajiuik 2/9/2021 11:41 PM
Got it compiling now. But when in game, we see all of the logs, but the command doesn't actually work.
11:41 PM
Even before a reload.
11:42 PM
I started with @SublimeStyle 's template (edited)
Avatar
Hi, sorry to bother. I am pretty new to this all but am looking at plugins for an ark server. My main problem is, I am using nitrado for hosting for now and I have no idea if arkapi even works with nitrado? I will look at the guides in a bit but not sure if they're applicable because I'm not self hosting ๐Ÿ™‚
Avatar
@Azarela nitrado doesn't support the API
2:01 PM
@SolaoBajiuik hard to say without seeing your implementation of your command
Avatar
Sad times ๐Ÿ˜ฆ Thank you for that. Do you know if any of the server hosting services do support API? @WETBATMAN
Avatar
https://serverblend.com/ is ArkServerAPI's official partner
Server hosting services in Europe, USA and Canada. Start your own game server or Teamspeak 3 server with world class server hosting at an unbeatable price.
Avatar
Thank you ๐Ÿ™‚
Avatar
SolaoBajiuik 2/10/2021 8:48 PM
@WETBATMAN I am thinking it might be because I'm trying to do arguments. /mtape start /mtape stop (edited)
8:48 PM
and i'm not doing something right for the argument processing
Avatar
how do you load the command ?
Avatar
SolaoBajiuik 2/10/2021 8:58 PM
COMMANDS.AddConsoleCommand("mtape", ChatCommand); (edited)
8:59 PM
using the template he pushed up so COMMANDS is a macro for ArkApi::GetCommands()
Avatar
that's a console command
9:16 PM
it would be cheat mtape
9:16 PM
in admin console
9:17 PM
if you want a chat command
9:17 PM
you need AddChatCommand
Avatar
SolaoBajiuik 2/10/2021 10:59 PM
Ahhhh. K. Thanks :)
Avatar
Hello, What is the best way to change the value of health / torpor / etc... from a character please ? I'm using the Hook_APrimalCharacter_TakeDamage but when I try to use the function SetHealth (from _this who is APrimalCharacter), it simply doesn't work. Is there another way to set those stats ? Thank you in advance
Avatar
Avatar
Neka
Hello, What is the best way to change the value of health / torpor / etc... from a character please ? I'm using the Hook_APrimalCharacter_TakeDamage but when I try to use the function SetHealth (from _this who is APrimalCharacter), it simply doesn't work. Is there another way to set those stats ? Thank you in advance
You can get the PrimalStatusComponent, and it has functions to set hp, stam, etc...
Avatar
Avatar
Pelayori
You can get the PrimalStatusComponent, and it has functions to set hp, stam, etc...
Thank you for your answer. I'm going to test that ๐Ÿ™‚
Avatar
void GivePlayerStat(AShooterCharacter* Char, EPrimalCharacterStatusValue::Type Stat, float AmountToGive) { if (Char && Char->MyCharacterStatusComponentField() && AmountToGive > 0) { UPrimalCharacterStatusComponent* Comp = Char->MyCharacterStatusComponentField(); float CurrentStat = Comp->BPGetCurrentStatusValue(Stat); float MaxStat = Comp->BPGetMaxStatusValue(Stat); float NewStat; if (CurrentStat + AmountToGive >= MaxStat) NewStat = MaxStat; else NewStat = CurrentStat + AmountToGive; Comp->BPDirectSetCurrentStatusValue(Stat, NewStat); Comp->ServerSyncReplicatedValues(); } }
Avatar
Is there any documentation about the arkapi?
Avatar
is there any example of how to use the permission plugin from my plugin?
Avatar
Avatar
Uaca
is there any example of how to use the permission plugin from my plugin?
ok. i did not realize that the ArkShop is an example
Avatar
Is there an Ark API plugin that can force same tribe across all servers?
Avatar
Avatar
Azarela
Is there an Ark API plugin that can force same tribe across all servers?
Yes, it is called TribeEnforcer
Avatar
Ah ty โค๏ธ @Pelayori
Avatar
hello again!
4:47 PM
wild guess here, but would it be possible using plugins to make a player mount any dino?
Avatar
Hello again, i would like to make a rest call
6:51 PM
i figure it out how to use the API::Requests::Get().CreateGetRequest
6:52 PM
but does not work from the Load function while the plugin is loading
6:54 PM
any tips on how to call a request as soon as the plugin finished load is very much appreciated
Avatar
maybe, it would be the hook Hook_UEngine_IsInitialized ?
Avatar
Avatar
Uaca
maybe, it would be the hook Hook_UEngine_IsInitialized ?
If you want to get when the server is fully started, Hook AShooterGameMode::InitGame
Avatar
Avatar
Pelayori
If you want to get when the server is fully started, Hook AShooterGameMode::InitGame
thank you very much!
๐ŸคŸ 1
Avatar
the hook AShooterGameMode::InitGame does no fire when using plugins.load from rcon
1:33 AM
is there any other hook i can use from when the plug in is loaded from rcon? (edited)
Avatar
I'm looking to make a plugin that will listen for when a player kills a boss dinosaur in the standard Ark arena or via open world spawn. I figure to do this I need to find the hook for when a Dino dies and check it's name against the list of bosses. Can anyone help me find the hook I need? I'm super new to this and appreciate any help.
Avatar
Avatar
Ashton
I'm looking to make a plugin that will listen for when a player kills a boss dinosaur in the standard Ark arena or via open world spawn. I figure to do this I need to find the hook for when a Dino dies and check it's name against the list of bosses. Can anyone help me find the hook I need? I'm super new to this and appreciate any help.
Server Api Creator Tool Source Overview: this tool allows you to quickly generate hooks for in game server functions saving you a lot of time of having to lookup the argument's / structure's / class's manually. Features: Ark & Atlas Api...
1:38 PM
very nice to search the hook, also use the Michidu plugins to search for examples (edited)
Avatar
Avatar
Uaca
the hook AShooterGameMode::InitGame does no fire when using plugins.load from rcon
if (ArkApi::GetApiUtils().GetStatus() == ArkApi::ServerStatus::Ready)
1:41 PM
you can check if server is started like this
1:42 PM
so then you can do whatever you wanted to do on load
Avatar
i see, thanks!
Avatar
on the arkshop source code is has a few log for the sqlite database:
4:02 PM
Log::GetLog()->error("({} {}) Unexpected DB error {}", FILE, FUNCTION, exception.what());
4:02 PM
i cant find where this log is stored.
4:02 PM
does anyone have a clue or know where i can find this info?
Avatar
ShooterGame\Binaries\Win64\logs
4:03 PM
Everything Log::GetLog() does will be in the API logs.
Avatar
since it is not writing any messages, my code must be wrong before the sqlite function. Thanks!
Avatar
DigitalVagrant 3/9/2021 6:54 AM
quick question from a nooblet to ARK plugins; I've got an SQL server set up and finally connecting to plugins, but the default Permissions plugin is shooting me an error message that it can't add player (it's just me on my test server). Any likely causes?
Avatar
Grab the latest beta version from Lethal, and it should work
Avatar
hey guys, if I were to try to create my own plugins (not new to coding/basic c++ knowledge, but completely new to plugin stuff), where would I start? Honestly I am completely lost ๐Ÿ˜„ is there some red line to follow somewhere? A guide, do's and don'ts? Some documentation I can't find? Thanks in advance!
Avatar
take an existing project and start messing around. thats what i do lol
2:14 AM
there is a template out there somewhere too. i think one of these channels links it
Avatar
Ok yes I have been trying to do that but some stuff isn't yet making sense to me ๐Ÿ˜… guess I'll keep digging around
Avatar
Hi, I was having a look at MAGA PVP Cooldown System and ORP. Does anyone have any experience with it? And is it worth a try? I currently am using the PVPCooldowns 2.16 but we're having an issue with people popcorning.
Avatar
Avatar
Azarela
Hi, I was having a look at MAGA PVP Cooldown System and ORP. Does anyone have any experience with it? And is it worth a try? I currently am using the PVPCooldowns 2.16 but we're having an issue with people popcorning.
If you have an issue try reporting it and describe the issue as thoroughly as possible to Lethal in his discord. This is kind of the wrong forum.
Avatar
Ah thanks ๐Ÿ™‚ I will do that!
Avatar
Avatar
Azarela
Ah thanks ๐Ÿ™‚ I will do that!
Or maybe update to a version that isn't 8 months old ๐Ÿ™‚ (edited)
rooWut1 1
2:31 PM
Also popcorning (old version/config may have popcorn listed for pvp) is only for raids which you need LethalORP for detection of the Raid CD. Running the latest version of most plugins is always advised.
Avatar
Thanks for that. I am running both on new version but after I sent the message I was looking into the Lethal ORP and realised that due to people not actually using it, it wasn't proccing the raid detection (derp). So this is what i'm looking into atm ๐Ÿ™‚
๐Ÿ‘ 1
Avatar
๐ŸบLiamMcIntyre!๐Ÿฆ„ 3/14/2021 12:09 AM
I completely understand this is a noob question, but I'm just really starting to look into plugin development out of interest ๐Ÿ˜… Trying to gain an understanding from open source work . . . For this example I'm looking into how the Suicide plugin works, and how its linked to Permissions I have read through the guide in #ใ€🔶ใ€‘แด˜สŸแดœษขษชษด-แด›แดœแด›๊œฑ and my understanding was I would link it in Linker -> Additional Library Directories But no matter what I do, it cannot open source file "Permissions.h" Does anyone know why that might be? (edited)
Avatar
Avatar
๐ŸบLiamMcIntyre!๐Ÿฆ„
I completely understand this is a noob question, but I'm just really starting to look into plugin development out of interest ๐Ÿ˜… Trying to gain an understanding from open source work . . . For this example I'm looking into how the Suicide plugin works, and how its linked to Permissions I have read through the guide in #ใ€🔶ใ€‘แด˜สŸแดœษขษชษด-แด›แดœแด›๊œฑ and my understanding was I would link it in Linker -> Additional Library Directories But no matter what I do, it cannot open source file "Permissions.h" Does anyone know why that might be? (edited)
For linking permissions you need to include the permissions header, "ArkPermissions.h" (also add the header directory to C++ -> General and there additional include directories Then you will need to go to Linker-> Additional Library directories for including the directory of Permissions.lib And in your code #pragma comment(lib, "Permissions.lib")
12:14 AM
Permissions header name file has changed over time, if I recall correctly. That's why some plugins have Permissions.h, probably before Atlas came out
Avatar
๐ŸบLiamMcIntyre!๐Ÿฆ„ 3/14/2021 12:15 AM
Yeah, I noticed the open source permissions had ArkPermissions so had messed about with re-naming a little both in the code and the actual file name But I will try the other things you mentioned too and see if that clears my error, thank you ๐Ÿ˜Š
Avatar
Yeah, you need to include the header and link the lib with the pragma comment
12:16 AM
Same applies to base ark api, you need to include its header and pragma comment ArkApi.lib
12:17 AM
Otherwise you will end up with unresolved externals
Avatar
๐ŸบLiamMcIntyre!๐Ÿฆ„ 3/14/2021 12:25 AM
You are a star, thank you Pelayori ๐Ÿ’™
Avatar
๐ŸบLiamMcIntyre!๐Ÿฆ„ 3/15/2021 8:12 PM
Me again . . . with probably another daft question ๐Ÿ˜ So just trying to gain basic understanding of the process I should be following, I tried using WETBATMAN's Suicide plugin for the example below(also tried a couple others) and I keep getting this error when attempting to build, the issue doesn't seem to be with the plugin but with the api file, any ideas? 1>Suicide.cpp 1>C:\******\ARK-Server-API-master\version\Core\Public\API\UE\Templates\Tuple.h(409,121): error C2760: syntax error: unexpected token ')', expected 'expression' 1>C:\******\ARK-Server-API-master\version\Core\Public\API\UE\Templates\Tuple.h(455): message : see reference to class template instantiation 'UE4Tuple_Private::TTupleImpl<TIntegerSequence<uint32,Indices...>,Types...>' being compiled 1>C:\******\ARK-Server-API-master\version\Core\Public\API\UE\Templates\Tuple.h(419,94): error C2760: syntax error: unexpected token ')', expected 'expression' 1>Done building project "Suicide.vcxproj" -- FAILED.
Avatar
Newest visual studio release breaks compiling.
8:57 PM
Change this at the top of Tuple.h //#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) // #define USE_TUPLE_AUTO_RETURN_TYPES (PLATFORM_COMPILER_HAS_AUTO_RETURN_TYPES && USING_CODE_ANALYSIS) //#else #define USE_TUPLE_AUTO_RETURN_TYPES 1 //#endif
๐Ÿ’™ 3
Avatar
thank you so much, I'm having the same issue
Avatar
How can I start my code in C ++?
Avatar
Someone has the most up-to-date shop with new functions, whoever I have I buy.
Avatar
do you mean arkshop?
Avatar
He is talking about a ideas and suggestion that doesn't exist yet. There is some function in the Rework (Unstable version) But in the official ARK Shop these function is not yet applied, and he want to have a build with several functions. But there is no such thing yet, not even to "buy".
3:17 PM
Will update the Official ArkShop among other fixes with some soon, but not all those functions (edited)
Avatar
someone asked me the same thing, i guess everyone wants some new functions on arkshop
Avatar
Exactly, it is not just me, I have other friends who ask if there is any more updated shop, but there is only the official free, but there are some things missing in it that could go on later.
Avatar
Well the way you are expecting it to be there is quite interesting
Avatar
Yes, if I saw many things from those suggestions, I believe that shop will be even more complete.
Avatar
Yeah, we will most likely see some more functions in the future ๐Ÿ™‚ (edited)
Avatar
Let's wait
Avatar
jraServerAPI 4/5/2021 3:16 AM
I'm trying to prevent players from leaving tribe once they join join. The code below only seems to prevent a player from being kicked (via the kick button), however they can still leave on their own. (via the leave tribe button) Is there anyway to keep 'em in the tribe forever? ๐Ÿ˜‚ c++ void Hook_AShooterGameMode_RemovePlayerFromTribe(AShooterGameMode* _this, unsigned __int64 TribeID, unsigned __int64 PlayerDataID, bool bDontUpdatePlayerState) { bool bCanNeverLeaveTribe = config["General"].value("LifetimeTribeMembership", false); if (bCanNeverLeaveTribe) { Log::GetLog()->info("CannotRemovePlayerFromTribe"); return; } AShooterGameMode_RemovePlayerFromTribe_original(_this, TribeID, PlayerDataID, bDontUpdatePlayerState); }
Avatar
substitute 4/5/2021 4:08 AM
@jraServerAPI there is one way I can think
4:08 AM
with debugger
4:08 AM
when you leave tribe, your targeting team id is changed (edited)
4:09 AM
you can use Cheat Engine and find your targeting team address (I would log this value with a plugin) and attach the debugger
4:09 AM
and select break-point on write
4:10 AM
then when that changes, you will have the call stack at that instant and you can backtrace to see what function you need to hook.
4:10 AM
There's also a function from the player side to request to leave a tribe....so you could just hook that and block it ๐Ÿ˜‰
4:10 AM
both options should work.
Avatar
void Hook_AShooterPlayerState_ServerRequestLeaveTribe_Implementation(AShooterPlayerState* _this) { AShooterPlayerState_ServerRequestLeaveTribe_Implementation_original(_this); }
4:11 AM
Sadly it's a void ๐Ÿ˜›
Avatar
Avatar
Foppa
void Hook_AShooterPlayerState_ServerRequestLeaveTribe_Implementation(AShooterPlayerState* _this) { AShooterPlayerState_ServerRequestLeaveTribe_Implementation_original(_this); }
substitute 4/5/2021 4:20 AM
void doesn't cause a problem
4:20 AM
just return without calling the original
4:21 AM
void Hook_AShooterPlayerState_ServerRequestLeaveTribe_Implementation(AShooterPlayerState* _this) { return; }
Avatar
jraServerAPI 4/5/2021 4:38 AM
hmm I see there are two versions of the Hooks and I've been using the version without the "implementation" at the end... What is the difference? It looks like I may be doing it wrong ๐Ÿคฆโ€โ™‚๏ธ
4:40 AM
(i noticed because you both posted Implementation responses lol) (edited)
Avatar
jraServerAPI 4/5/2021 4:57 AM
๐Ÿคฆโ€โ™‚๏ธ
4:58 AM
thank you guys ๐Ÿ™‚ it's working now, using the Implementation hook instead. (edited)
4:58 AM
So what is the golden rule? Always use the implementation hook? or is it hit or miss?
Avatar
Fake it until you make it?
๐Ÿ˜‚ 2
12:55 PM
๐Ÿ˜„
Avatar
Avatar
jraServerAPI
So what is the golden rule? Always use the implementation hook? or is it hit or miss?
hooks that have implementation in their name specify that that function has a client and server variant
๐Ÿ‘ 1
1:25 PM
most of the time the hook that doesn't have implementation is the server one
1:25 PM
however in some cases it's reverse
1:32 PM
if you look at the function name it has ServerRequest, which means it gets called from the client first, then you can logically deduce that the function with Implementation is the one that gets called on the server and it's the function you need to hook ๐Ÿ˜„
Avatar
jraServerAPI 4/5/2021 3:46 PM
Thank you all!
Avatar
Anyone knows how to get the current region name from Atlas ?
4:38 PM
I manage to get the grid's server name from FSeamlessServerInfo
Avatar
But haven't found yet a solution on getting the region without making a function from grid x/y
Avatar
Avatar
Foppa
But haven't found yet a solution on getting the region without making a function from grid x/y
I do ๐Ÿ™‚ hmu
Avatar
i made a function of it instead ๐Ÿ˜› (edited)
๐Ÿ‘ 1
Avatar
@Foppa
9:57 PM
Current grid is two shorts packed as an int
9:58 PM
Under something like aws id in query info
Avatar
DigitalVagrant 4/24/2021 12:56 AM
Still having difficulty with Permissions plugin throwing the "can't add player" error. Any advice?
Avatar
Avatar
DigitalVagrant
Still having difficulty with Permissions plugin throwing the "can't add player" error. Any advice?
jraServerAPI 4/24/2021 5:16 PM
are you using mysql?
Avatar
DigitalVagrant 4/24/2021 5:17 PM
Mariadb atm.
5:17 PM
...I'm not the one who chose that one. Please tell me it's not incompatible.
Avatar
jraServerAPI 4/24/2021 5:18 PM
5:19 PM
only 2 db's are supported.. sqlite requires nothing for you to do.. but Permissions will be map based only (edited)
5:19 PM
install mysql community server (free) on your machine and you can use mysql and have Permissions cluster wide (edited)
5:21 PM
you would need to setup mysql properly also..
Avatar
DigitalVagrant 4/24/2021 5:22 PM
Faaaaaaark
5:22 PM
That'd be it then
5:23 PM
A lot of other plugins are compatible with mariadb
5:23 PM
But if permissions isn't, then fair enough
Avatar
maria is mysql just not the official version
Avatar
DigitalVagrant 4/24/2021 9:33 PM
@Lethal oh, so it should be alright then?
Avatar
Foppa uses MariaDB
Avatar
MariaDB is to recommend imao
Avatar
I have someplug in source code which is hard-coded with !player->bIsAdmin - preventing blocks running for non-admin users (who have permissions to run the cheat <command>), if I remove the references to these blocks does it mean that non-admins will be able to run these code blocks as a result if they have cheat.command permissions ?
Avatar
A New Home 5/5/2021 2:57 PM
I'm trying to rebuild the mutes plugin - I've solved most of the issues install and what not - but trying to compile it - I'm hit by one error - any clues how to fix this, so I can get the original source code to finish compiling in my enviroment?
Avatar
Avatar
A New Home
I'm trying to rebuild the mutes plugin - I've solved most of the issues install and what not - but trying to compile it - I'm hit by one error - any clues how to fix this, so I can get the original source code to finish compiling in my enviroment?
Try casting szitem["Word"] to std::string
Avatar
A New Home 5/5/2021 3:05 PM
Thank you that worked.
Avatar
you can also just do .get<std::string>()
3:36 PM
instead of casting
Avatar
A New Home 5/5/2021 3:57 PM
Well.. I've managed to fix the Mutes plugin so that it can run certain commands now without doing the admin check so it integrates with the admins permissions plugin, so I would say that its been a very successful day so far and I now have a DLL which works and I dont need to give my Moderators full admin permissions. Thank you all for your help.
Avatar
NeO_Anderson 5/5/2021 8:43 PM
hi guys, im new to plugin development and haven't used C++ in many years. I'm hoping to try to fix the ArkHomes plugin to not crash the server as it's currently doing. how might I send a console message? that would be logged in the ark servers loggs?
8:46 PM
o nvm may have figured that out XD
Avatar
Avatar
NeO_Anderson
hi guys, im new to plugin development and haven't used C++ in many years. I'm hoping to try to fix the ArkHomes plugin to not crash the server as it's currently doing. how might I send a console message? that would be logged in the ark servers loggs?
If you want API-style logs (those that print like [PluginName][info] This is my message), then use Log::GetLog()->info, but make sure to init it first. Init can be done on plugin's Load() function `Log::Get().Init("PluginName"); Other way is using the ark's integrated logs, that you can use from AShooterGameMode::PrintToServerGameLog or PrintToGameplayLog (both of these need -servergamelog in the server launch args)
Avatar
NeO_Anderson 5/5/2021 10:57 PM
ok thanks, I saw another mention of the Log:: inside the ArkHomes plugin so I assumed that was the way to do it. its loading now so we see what happens
10:58 PM
really sad this plugin crashes, its very useful
Avatar
A New Home 5/6/2021 3:13 AM
Does anyone know of a simple method I can get all tribes and last login dates for that tribe - so I can export it to the logs?
Avatar
Avatar
A New Home
Does anyone know of a simple method I can get all tribes and last login dates for that tribe - so I can export it to the logs?
you're barking up a tree of insanity
10:22 AM
that information isn't loaded if the tribe is offline
Avatar
Avatar
A New Home
Does anyone know of a simple method I can get all tribes and last login dates for that tribe - so I can export it to the logs?
if you know the tribeID you can use GetOrLoadTribeData
2:05 PM
FTribeData* CreatedTribeData = static_cast<FTribeData*>(FMemory::Malloc(0x200)); RtlSecureZeroMemory(CreatedTribeData, 0x200); ArkApi::GetApiUtils().GetShooterGameMode()->GetOrLoadTribeData(CreatedTribeID, CreatedTribeData); FMemory::Free(CreatedTribeData);
2:05 PM
replace CreatedTribeID with the tribe id of your choice
2:06 PM
cache the results, because this function leaks memory, don't call it alot
2:08 PM
and ofc call FMemory::Free after you're extracted the info you need not immediately after GetOrLoadTribeData ๐Ÿ˜„
Avatar
A New Home 5/6/2021 2:10 PM
Thank you that makes sense, I'm assuming that you can only get the online tribeIds rather than find all tribeIDs with a plugin?
Avatar
there should be a way to get all tribes online and offline
Avatar
Avatar
WETBATMAN
cache the results, because this function leaks memory, don't call it alot
substitute 5/6/2021 7:05 PM
You know what, I might attach Valgrind or something to the API
7:05 PM
I want to know why that function leaks memory and if it can hotpatched to NOT leak
๐Ÿ’ฏ 2
Avatar
jraServerAPI 5/7/2021 4:12 AM
Using Hook_APrimalDinoCharacter_Die what is the best method to determine if the dino that just died was an alpha? a titan, or a boss? c++ bool Hook_APrimalDinoCharacter_Die(APrimalDinoCharacter* _this, float KillingDamage, FDamageEvent* DamageEvent, AController* Killer, AActor* DamageCauser) { return APrimalDinoCharacter_Die_original(_this, KillingDamage, DamageEvent, Killer, DamageCauser); } thank you in advance
Avatar
jraServerAPI 5/7/2021 9:15 AM
Answer c++ FString myDescriptiveName = _this->DescriptiveNameField(); (edited)
Avatar
@Lethal @WETBATMAN I think I know what the memory leak for that function is
10:20 AM
it's a different function it calls when the data isn't already loaded.
10:20 AM
10:20 AM
this v233 pointer is constructed but is never free'ed before returning
Avatar
a similar function that reads user data returns the pointer created from NewObject while LoadTribeData only returns true/false since you pass in a buffer.
Avatar
Ya, that is part of the code where it reads the physical tribe data file from disk.
Avatar
Avatar
Lethal
Ya, that is part of the code where it reads the physical tribe data file from disk.
substitute 5/7/2021 4:36 PM
I sent my findings to Wildcard so hopefully theyโ€™ll add a free
4:37 PM
The heap object is used for the deserialization but they only copy a field from that into the passed in buffer
4:37 PM
The object can safety be deleted after you get a copy of this buffer
Avatar
Ah, nice. I'd be interested if they actually confirm they fix it back to you.
Avatar
NeO_Anderson 5/7/2021 4:53 PM
?map
4:53 PM
>map
4:54 PM
whats the command for that interactive map again please?
4:54 PM
oh nvm, wrong discord haha xD
Avatar
maps.google.com
Avatar
A New Home 5/7/2021 8:09 PM
Thank you for investigating that memory leak
Avatar
I'm trying to post a resource to the API site - I'm only getting the ability to post to Atlas instead of ARK , any ideas on how to fix this?
Avatar
Avatar
A New Home
I'm trying to post a resource to the API site - I'm only getting the ability to post to Atlas instead of ARK , any ideas on how to fix this?
You need to be approved as a developer first.
Avatar
Oh I see - I have prob 20 years coding experience across a number of different languages, my first language was pascal ๐Ÿ˜„
Avatar
hey guys, I have a couple of questions regarding the server API plugin. 1. I am trying to make my own ark plugin, but i can't seem to find what extentions i should use for the plugin to be compatible with the ark server API. 2. I am using visual studio code for the plugin. are there any specific settings that i should do before i start making my plugin? 3. I also am a bit of a newbie in coding. So i am wondering one more thing before i can start. How can i get information out of ark. For example the amount of experienced gained in game to use the number for a points system. Thank you for reading this and even more thanks for any possible response ๐Ÿ™‚ Ps: Please don't mind my bad english xD
Avatar
Avatar
kevinvanb
hey guys, I have a couple of questions regarding the server API plugin. 1. I am trying to make my own ark plugin, but i can't seem to find what extentions i should use for the plugin to be compatible with the ark server API. 2. I am using visual studio code for the plugin. are there any specific settings that i should do before i start making my plugin? 3. I also am a bit of a newbie in coding. So i am wondering one more thing before i can start. How can i get information out of ark. For example the amount of experienced gained in game to use the number for a points system. Thank you for reading this and even more thanks for any possible response ๐Ÿ™‚ Ps: Please don't mind my bad english xD
GSH | MrOwlSky 5/24/2021 7:14 PM
This guide is based on the Visual Studio Community 2019 version install Prerequisites: 1. https://visualstudio.microsoft.com/vs/ 2. https://github.com/Michidu/ARK-Server-API/archive/master.zip Step N1: Install Visual Studio by the link given on the first prerequisite. When the inst...
Avatar
โค๏ธ
7:21 PM
@GSH | MrOwlSky
Avatar
uint64 playerTribeId = player->TargetingTeamField(); const int dinoTribeId = dino->TargetingTeamField(); if (playerTribeId != dinoTribeId) <--- this line is crashing return;
2:09 AM
Hello, in the code above the if is crashing the server
2:09 AM
i cant figure out why would this crash when comparing values
Avatar
substitute 6/1/2021 2:30 AM
Really depends on a lot of things
2:30 AM
Whatโ€™s the whole function look like
Avatar
void Imprint(AShooterPlayerController* player, FString* message, EChatSendMode::Type /*unused*/) { if (!player || !player->PlayerStateField() || ArkApi::IApiUtils::IsPlayerDead(player)) return; const uint64 steamid = ArkApi::IApiUtils::GetSteamIdFromController(player); uint64 playerTribeId = player->TargetingTeamField(); AActor* Actor = player->GetPlayerCharacter()->GetAimedActor(ECC_GameTraceChannel2, nullptr, 0.0, 0.0, nullptr, nullptr, false, false, false); if (Actor && Actor->IsA(APrimalDinoCharacter::GetPrivateStaticClass()) == false) { ArkApi::GetApiUtils().SendChatMessage(player, GetText("Sender"), *GetText("Invalid")); return; } APrimalDinoCharacter* dino = static_cast<APrimalDinoCharacter*>(Actor); const int dinoTribeId = dino->TargetingTeamField(); if (playerTribeId != dinoTribeId) { ArkApi::GetApiUtils().SendChatMessage(player, GetText("Sender"), *GetText("NotInTribe")); return; } .... } (edited)
3:13 AM
after that is just dino->UpdateImprintingQuality(1.0);
3:14 AM
maybe APrimalDinoCharacter* dino = static_cast<APrimalDinoCharacter*>(Actor); is not working as expected ?
Avatar
Atomicskullz 6/5/2021 7:42 PM
Anyone know why AShooterPlayerController_OnAddItemFinished isnt triggering? Other hooks work fine (edited)
7:42 PM
DECLARE_HOOK(AShooterPlayerController_OnAddItemFinished, void, AShooterCharacter*, bool, TArray<unsigned __int64>, unsigned __int64); void Hook_AShooterPlayerController_OnAddItemFinished(AShooterCharacter* _this, bool bSuccess, TArray<unsigned __int64> SteamItemUserIds, unsigned __int64 SteamID) { const FLinearColor color{ 255, 255, 255, 255 }; ArkApi::GetApiUtils().SendServerMessageToAll(color, "[TEST]Player added item!"); } (edited)
7:43 PM
ArkApi::GetHooks().SetHook("AShooterPlayerController.OnAddItemFinished", &Hook_AShooterPlayerController_OnAddItemFinished, &AShooterPlayerController_OnAddItemFinished_original);
Avatar
Might never be called from the game
Avatar
Atomicskullz 6/6/2021 8:27 PM
ah ok
8:28 PM
btw is there anyway to print to the console?
Avatar
Avatar
Atomicskullz
btw is there anyway to print to the console?
Log::GetLog()->Info()
Avatar
Atomicskullz 6/6/2021 8:45 PM
epic, thanks
Avatar
Atomicskullz 6/6/2021 9:39 PM
unsure why this isnt functioning
9:39 PM
void CC_RunString(APlayerController* player_controller, FString* cmd, bool /*unused*/) { ArkApi::GetApiUtils().SendServerMessageToAll(FColorList::Blue, "Testing!"); if (cmd != nullptr && cmd->Len() > 0) luaL_dostring(CGELuaHandle::GetSingleton()->GetState(), cmd->ToString().c_str()); } void RegisterLuaConCommands() { auto& commands = ArkApi::GetCommands(); commands.AddConsoleCommand("lua_run", &CC_RunString); }
9:40 PM
when i run the console command the server message does not get sent
9:40 PM
and yes, RegisterLuaConCommands() is called elsewhere
Avatar
what are you typing in chat?
9:41 PM
oh nvm it's a console command
Avatar
Is that a LUA wrapper? :p
Avatar
Avatar
Atomicskullz
when i run the console command the server message does not get sent
Are you running it with cheat lua_run? (edited)
Avatar
Atomicskullz 6/6/2021 9:42 PM
no
9:42 PM
do i have to?
Avatar
You need cheat prefix in console always, otherwise they don't execute
Avatar
yes it's a console command
Avatar
Atomicskullz 6/6/2021 9:43 PM
oh damn
9:43 PM
there's no way around it?
Avatar
why'd you want a way around it?
9:43 PM
if you want a command for all players you can just add a chat command instead
Avatar
Atomicskullz 6/6/2021 9:43 PM
so you dont have to type "cheat"
9:43 PM
idm but i was just curious
Avatar
Avatar
Pelayori
Is that a LUA wrapper? :p
Atomicskullz 6/6/2021 9:44 PM
and yes, its my own lol
Avatar
Interesting, I used lua for fivem a few years ago (edited)
Avatar
only used lua to make some plugin for a csgo cheat ๐Ÿ˜„
Avatar
Avatar
Atomicskullz
so you dont have to type "cheat"
well whatever you type into the console is supposed to be a console command and i don't think it's gonna be sent to the server unless it's prefixed with cheat
Avatar
Avatar
WETBATMAN
Log::GetLog()->Info()
Atomicskullz 6/6/2021 11:11 PM
doesnt appear to be printing anything into the console
Avatar
Avatar
Atomicskullz
doesnt appear to be printing anything into the console
Did you Init the log? You need to add Log::Get().Init("PluginName"); at the plugin load function
Avatar
Atomicskullz 6/6/2021 11:12 PM
yep
Avatar
Atomicskullz 6/7/2021 2:26 PM
could someone tell me which one I should use if im inserting, removing, and accessing elements frequently? A or B?c++ // A typedef unordered_map<string, int> Sub; // possibly 30+ entries typedef unordered_map<string, Sub> Main; // possibly 30 or fewer // B typedef vector<tuple<string, int>> Sub; // possibly 30+ entries typedef unordered_map<string, Sub> Main; // possibly 30 or fewer (edited)
Avatar
Atomicskullz 6/10/2021 10:42 PM
would this be the correct way to add experience when given an AShooterCharacter* ?
10:42 PM
// m_pInstance is AShooterCharacter* auto ctrl = m_pInstance->GetCharacterController(); auto shooter_ctrl = static_cast<AShooterPlayerController*>(ctrl); shooter_ctrl->AddExperience(100, false, false);
10:44 PM
and how do i get the total experience a player has?
Avatar
jraServerAPI 6/11/2021 2:00 AM
That looks like it will work, although you may want to have the last argument true, otherwise I believe it will share the experience with the tribe mates in the area if you leave it false. (edited)
Avatar
Avatar
Atomicskullz
would this be the correct way to add experience when given an AShooterCharacter* ?
I would use the API, or take a look at the function: AShooterPlayerController* aspc = ArkApi::GetApiUtils().FindControllerFromCharacter(character); (edited)
Avatar
Avatar
Foppa
I would use the API, or take a look at the function: AShooterPlayerController* aspc = ArkApi::GetApiUtils().FindControllerFromCharacter(character); (edited)
that function takes O(n) time AShooterPlayerController* FindControllerFromCharacter(AShooterCharacter* character) const { AShooterPlayerController* result = nullptr; const auto& player_controllers = GetWorld()->PlayerControllerListField(); for (TWeakObjectPtr<APlayerController> player_controller : player_controllers) { auto* shooter_pc = static_cast<AShooterPlayerController*>(player_controller.Get()); if (shooter_pc->GetPlayerCharacter() == character) { result = shooter_pc; break; } } return result; } while that field should always have the player controller
10:13 AM
honestly we should probably update FindControllerFromCharacter to use the field if the field is non-null
Avatar
There's a few other issues in the helpers class
10:17 AM
FindControllerFromCharacter has null checks but GetSteamName does not for example
10:17 AM
nothing too horrible but def. inconsistent
10:17 AM
maybe this weekend I can spend some time to update the header
Avatar
@substitute I had updated it, but from tests it seemed to be unreliable
11:39 AM
AShooterPlayerController* FindControllerFromCharacter(AShooterCharacter* character) const { if (character) { AShooterPlayerController* result = (character->GetOwnerController() != nullptr) ? static_cast<AShooterPlayerController*>(character->GetOwnerController()) : static_cast<AShooterPlayerController*>(character->GetInstigatorController()); return result; } return nullptr; }
11:40 AM
Not sure if you have any idea on how to improve it, because it was crashing at GetOwnerController
Avatar
Avatar
Pelayori
Not sure if you have any idea on how to improve it, because it was crashing at GetOwnerController
had the very same issue actually
12:59 PM
GetOwnerController was working perfectly fine on my end but it crashed on someone else's server
Avatar
even tried the exact same server config on both machines
12:59 PM
mine always worked, the other always crashed idk why ๐Ÿ˜„
Avatar
I had pushed a PR with those changes but ended up closing it because of that unreliability to reproduce the crash
Avatar
Avatar
Pelayori
I had pushed a PR with those changes but ended up closing it because of that unreliability to reproduce the crash
Did we ever get the specific crash logs?
3:55 PM
Iโ€™m curious why that would happen
Avatar
No, but I can dig up for them
Avatar
Thanks
3:55 PM
Maybe itโ€™s something with a mod
3:55 PM
Very curious
3:56 PM
That's the one I remember having
3:56 PM
It was from when I compiled permissions with that function I sent
3:57 PM
At the bottom when equipping an item, at the front one right after startup
3:57 PM
Quite old though
3:58 PM
@substitute
Avatar
Hm, yeah. Only thing I can think of off the top of my head is a race condition
Avatar
It had null check, but I can also remember some things I worked on where even though null check they were still passing and failing on getting something of said pointer
4:01 PM
So they weren't really null
10:53 PM
Super noob man here
10:53 PM
I wanna make it so that Argy's get the imprint speed buff like other dinos do
10:53 PM
This doable?
Avatar
Avatar
Pelayori
Click to see attachment ๐Ÿ–ผ๏ธ
The compress2 error is fixed with DumpAll i'm pretty sure which is why we need to just release the API with it enabled. I have been providing it that way in my early releases on my discord.
Avatar
Avatar
Lethal
The compress2 error is fixed with DumpAll i'm pretty sure which is why we need to just release the API with it enabled. I have been providing it that way in my early releases on my discord.
Itโ€™s like 3 extra seconds of start up for worlds more compatibility
4:54 AM
Dump all should be default
4:55 AM
(3 seconds of start up is nothing when the server takes 5 minutes to boot clowntrophy )
Avatar
Avatar
Lethal
The compress2 error is fixed with DumpAll i'm pretty sure which is why we need to just release the API with it enabled. I have been providing it that way in my early releases on my discord.
Ah great then. I guess APawn is not dumped by default then?
Avatar
Avatar
Pelayori
Ah great then. I guess APawn is not dumped by default then?
Ya, it's not in the default config.json.
Avatar
That would explain everything. Thank you very much. By that time I didn't have dumpall true. However I'll still ship pdbconfig files since even though official api will have it I'm sure someone will skip the new config.json
Avatar
actually API does dump APawn without DumpAll
2:21 PM
this is because when you specify a class/struct for pdbreader it dumps it and it's children
2:21 PM
APawn is child of AActor (which is dumped by default)
Avatar
But then why would it crash without dump all and then work with it enabled
Avatar
Atomicskullz 6/12/2021 3:16 PM
typedef std::tuple<const char*, int> CCEntry_t; typedef std::unique_ptr<CCEntry_t> CCEntryptr_t; typedef std::vector<CCEntryptr_t> CCVec_t; // contains the console commands along with their luareg index (edited)
3:16 PM
is this too complex for what I need to be done?
3:16 PM
i was thinking of doing an unordered_map with const char* as key and int as value
3:17 PM
but i was thinking of performance
3:17 PM
and the problem is that const char* isnt hashable, therefore it wont work correctly in a map (edited)
3:18 PM
so im unsure what to use (edited)
Avatar
Avatar
Atomicskullz
and the problem is that const char* isnt hashable, therefore it wont work correctly in a map (edited)
Std string
Avatar
Atomicskullz 6/12/2021 7:17 PM
yes ik
7:17 PM
but the performance
Avatar
Standard library strings are absolutely hashable (edited)
Avatar
Atomicskullz 6/12/2021 7:55 PM
i know that...
7:55 PM
im asking if its feasible for this
7:56 PM
compared to using find_if with strcmp if it were a vector (edited)
Avatar
Atomicskullz 6/13/2021 11:16 AM
Can anyone explain the difference between static_cast and dynamic_cast? Did research but i cant wrap my head around it. All i know is that static_cast occurs during compile time, while dynamic_cast occurs during runtime. I dont really understand
Avatar
Can't really say myself, but I'd guess static cast is on compile time, faster and used for pointers while dynamic is at runtime, slower and for references?
11:39 AM
I mostly use either static/reinterpret casts
Avatar
Atomicskullz 6/15/2021 2:46 PM
How do i add new blueprints using the API?
Avatar
Atomicskullz 6/15/2021 2:57 PM
If anyone could just tell me a function name
2:58 PM
I could just look it up on github and find examples
Avatar
you mean like add an additional item?
Avatar
Atomicskullz 6/15/2021 3:10 PM
Yeah
3:10 PM
Like making my own
Avatar
i don't think this is doable with a plugin, since it would have to be replicated to the client
Avatar
Atomicskullz 6/15/2021 3:12 PM
Damn thats right
3:12 PM
Didnt think of that
Avatar
Atomicskullz 6/16/2021 12:22 PM
Any1 know if thereโ€™s a macro for determining if the server is using ark or atlas?
Avatar
hm?
12:24 PM
you have to compile with AtlasAPI for atlas and ArkApi for ark
Avatar
Atomicskullz 6/16/2021 4:32 PM
is there anyway to manipulate weapon damage or other stats?
Avatar
Avatar
Atomicskullz
is there anyway to manipulate weapon damage or other stats?
jraServerAPI 6/16/2021 5:23 PM
Avatar
Atomicskullz 6/16/2021 5:38 PM
uh that doesnt really answer the question
5:38 PM
oh wait wtf
5:38 PM
nvm
5:38 PM
scroll was bugged
5:38 PM
thanks
Avatar
Atomicskullz 6/18/2021 12:27 AM
Does the EngramBlueprintClassesField() function in Gamemode.h actually contain all the current engram entries available?
Avatar
Yes
12:27 AM
Well, wait
12:28 AM
I know EngramBlueprints from UPrimalGameData does have all engrams
Avatar
Atomicskullz 6/18/2021 12:45 AM
Ah ok, interesting. Which ever one is best performing for a simple iteration that retrieves the names and levels of them ill use (edited)
12:46 AM
Will have to do some experimenting
Avatar
Avatar
Atomicskullz
Will have to do some experimenting
auto Singleton = (UPrimalGlobals*)Globals::GEngine()()->GameSingletonField(); auto GameData = Singleton->PrimalGameDataOverrideField() ? Singleton->PrimalGameDataOverrideField() : Singleton->PrimalGameDataField(); auto EngramClasses = GameData->EngramBlueprintEntriesField(); (edited)
Avatar
Atomicskullz 6/18/2021 12:50 AM
Ok cool, thanks
Avatar
Atomicskullz 6/19/2021 1:52 PM
is there anyway to get the stored weapons? like a list of them with their damages and stuff
Avatar
Atomicskullz 6/19/2021 2:20 PM
or just a list of all the items with their stats. because im not sure if i can get the template damages from a UPrimalEngramEntry (edited)
Avatar
Atomicskullz 6/19/2021 2:49 PM
yeah unsure. i found out a way but it looks a little dirty
2:49 PM
auto Singleton = (UPrimalGlobals*)Globals::GEngine()()->GameSingletonField(); auto GameData = Singleton->PrimalGameDataOverrideField() ? Singleton->PrimalGameDataOverrideField() : Singleton->PrimalGameDataField(); auto EngramClasses = GameData->EngramBlueprintEntriesField(); for (auto x : EngramClasses) { auto sub = x->BluePrintEntryField().uClass->GetDefaultObject(); auto casted = static_cast<UPrimalItem*>(sub); float damage = casted->GetWeaponTemplateMeleeDamageAmount(); }
2:49 PM
mind the var names, just tempoary
Avatar
That's probably one of the best ways if you need all craftable weapons
2:53 PM
There is no such singleton with all weapons
Avatar
Deleted User 6/19/2021 3:19 PM
Are there any very basic plugins I could have a look at as an example to get an understanding of what plug-in development is like?
3:19 PM
I'm very new to C++
Avatar
Atomicskullz 6/19/2021 6:10 PM
Sorry if this sounds blunt, but you shouldnโ€™t really be doing this kind of stuff if youโ€™re โ€œvery new.โ€ Thereโ€™s a lot of stuff you have to learn in order to make efficient code.
Avatar
Avatar
Atomicskullz
Sorry if this sounds blunt, but you shouldnโ€™t really be doing this kind of stuff if youโ€™re โ€œvery new.โ€ Thereโ€™s a lot of stuff you have to learn in order to make efficient code.
I disagree. If the person has previous experience in other languages, picking up C++ is usually straight forward.
๐Ÿ‘ 1
Avatar
Atomicskullz 6/19/2021 9:35 PM
C++ is a totally different beast wtf are you saying waitwhat
Avatar
Avatar
Atomicskullz
C++ is a totally different beast wtf are you saying waitwhat
I had no issues picking up C++
Avatar
Atomicskullz 6/19/2021 9:36 PM
Cool
Avatar
If you understand the concepts, itโ€™s a straight forward language.
Avatar
Atomicskullz 6/19/2021 9:37 PM
People who say they are โ€œvery newโ€ usually tend to not understand it, otherwise they wouldnt say it
9:38 PM
I see it all the time in another server (edited)
9:41 PM
I dont mind if someone is new to c++, but trying to explain something to someone like that is uh (edited)
9:42 PM
idk its prolly just me and my past experiences
Avatar
Atomicskullz 6/20/2021 1:22 AM
so uh why am i getting an error when using FString as a key for a map?
1:22 AM
struct EngramEntry { FString name; TSubclassOf<UPrimalItem>* engram; int level{}; }; extern TMap<FString, EngramEntry> g_EngramMap;
1:22 AM
could have sworn FString was hashable
1:22 AM
on compile it throws "TMap must have a hashable KeyType unless a custom key func is provided."
Avatar
Avatar
Atomicskullz
could have sworn FString was hashable
Easy work around, use the c string value
7:07 AM
Thereโ€™s a function to get the underlying string from FString
Avatar
Atomicskullz 6/20/2021 11:54 AM
Ok thanks
Avatar
Atomicskullz 6/20/2021 2:27 PM
yeah, but thing is that FString is the key used for some of the functions/fields in the API, like in AShooterGamemode Struct (edited)
2:27 PM
TMap<FString, FString, FDefaultSetAllocator, TDefaultMapKeyFuncs<FString, FString, 0> >
2:28 PM
yet the compiler doesnt complain when it goes through that
2:28 PM
only thing i can try is setting the KeyFuncs
2:28 PM
but by default it should have worked
Avatar
Atomicskullz 6/20/2021 2:37 PM
found something that may work
2:37 PM
struct FMyStruct { // String which identifies our key FString UniqueID; // Some state which doesn't affect struct identity float SomeFloat; explicit FMyStruct(float InFloat) :UniqueID (FGuid::NewGuid().ToString()) , SomeFloat(InFloat) { } }; template <typename ValueType> struct TMyStructMapKeyFuncs : BaseKeyFuncs< TPair<FMyStruct, ValueType>, FString > { private: typedef BaseKeyFuncs< TPair<FMyStruct, ValueType>, FString > Super; public: typedef typename Super::ElementInitType ElementInitType; typedef typename Super::KeyInitType KeyInitType; static KeyInitType GetSetKey(ElementInitType Element) { return Element.Key.UniqueID; } static bool Matches(KeyInitType A, KeyInitType B) { return A.Compare(B, ESearchCase::CaseSensitive) == 0; } static uint32 GetKeyHash(KeyInitType Key) { return FCrc::StrCrc32(*Key); } };
2:37 PM
[UE4] Use of TMap, Programmer Sought, the best programmer technical posts sharing site.
2:38 PM
but still, i dont know why the compiler doesnt complain about maps using fstring in the api
Avatar
Just use the TMap
4:01 PM
TMap is the UE4 map type
Avatar
Atomicskullz 6/20/2021 4:45 PM
Yes thats what ive been using
Avatar
Atomicskullz 6/20/2021 5:41 PM
struct FStringStruct { // String which identifies our key FString UniqueID; // Some state which doesn't affect struct identity float SomeFloat; explicit FStringStruct(float InFloat) :UniqueID(FGuid::NewGuid().ToString()) , SomeFloat(InFloat) { } };
5:41 PM
it says NewGuid() is missing (edited)
5:41 PM
any alternative?
Avatar
Atomicskullz 6/20/2021 10:46 PM
ya even Crc::MemCrc32 isnt there
10:46 PM
so its impossible to make a hashable struct
Avatar
Avatar
Atomicskullz
ya even Crc::MemCrc32 isnt there
You can always add the missing references if any are missing
Avatar
Atomicskullz 6/20/2021 11:20 PM
ye thats what im doing rn
Avatar
In IDA you can find CRC Mem32
11:21 PM
and then construct a header similar to the FMemory header
Avatar
Atomicskullz 6/20/2021 11:21 PM
oh im just using the UE4 source lol
Avatar
That will cause you a lot of problems
Avatar
Atomicskullz 6/20/2021 11:21 PM
all im doing is getting the MemCrc32 function
11:22 PM
which has nothing to do with the game
11:22 PM
if you know what i mean
Avatar
Yes, don't reference it from the UE4 source, reference the one built into the game.
Avatar
Atomicskullz 6/20/2021 11:22 PM
its poco stuff
11:22 PM
yeah but i dont know how to ida pro lol
Avatar
You just open the game in IDA pro
11:22 PM
there it will have a function list
11:22 PM
you can ctrl+f
11:23 PM
example with FMemory
11:23 PM
it uses the function pointer from the game via the PDB
11:24 PM
@Atomicskullz anyways, if you are just wanting to store a map based on the value of the string
11:24 PM
map<std::string, FString>
11:25 PM
if you want the FString to also map to a complex object just make a wrapping struct struct MyStruct { FString a; void* whateveryouwant; } map<std::string, MyStruct> myMap
Avatar
Atomicskullz 6/20/2021 11:27 PM
so i shouldnt use TMap then?
11:29 PM
Crc.h and Crc.cpp fit into the project perfectly
11:29 PM
all the required headers were already there
11:29 PM
i might need to make a new fork
Avatar
jraServerAPI 6/23/2021 5:48 AM
Does anybody know where the Additional Harvesting levels are stored on a dino? (eg, the Additional Delicate/Power harvesting values on a Therizinosaur) I'm searching the UPrimalCharacterStatusComponent but not coming up with much yet... Thanks in advance!
Avatar
Avatar
jraServerAPI
Does anybody know where the Additional Harvesting levels are stored on a dino? (eg, the Additional Delicate/Power harvesting values on a Therizinosaur) I'm searching the UPrimalCharacterStatusComponent but not coming up with much yet... Thanks in advance!
It is a BP function on the dino.
Avatar
Atomicskullz 6/23/2021 11:34 PM
what class/struct is an item that's pick-up-able by the player? (for example, a weapon that a player dropped)
Avatar
ADroppedItem
Avatar
Atomicskullz 6/23/2021 11:50 PM
thanks
Avatar
Atomicskullz 6/26/2021 3:04 PM
are all engram entries prefixed with EngramEntry_ ? (edited)
Avatar
Avatar
Atomicskullz
are all engram entries prefixed with EngramEntry_ ? (edited)
Most likely. I'd check parent class too, or maybe an IsChildOf to be 100% sure
Avatar
I tried to compile a basic Plugin following the tutorial in the plugins-tutorial channel. When I include "API/ARK/Ark.h" and want to build my solution, I get the following errors:
4:11 PM
What should I do?
Avatar
Avatar
KraxKrokat
I tried to compile a basic Plugin following the tutorial in the plugins-tutorial channel. When I include "API/ARK/Ark.h" and want to build my solution, I get the following errors:
Atomicskullz 6/26/2021 4:24 PM
change the content located at the top of the Tuple.h header. You just need to comment-out some lines, like so://#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) // #define USE_TUPLE_AUTO_RETURN_TYPES (PLATFORM_COMPILER_HAS_AUTO_RETURN_TYPES && USING_CODE_ANALYSIS) //#else #define USE_TUPLE_AUTO_RETURN_TYPES 1 //#endif (edited)
Avatar
Thanks - I'll give that a shot ๐Ÿ™‚ By the way, shouldn't that be a step in the beginner tutorial maybe?
Avatar
Atomicskullz 6/26/2021 4:25 PM
outdated tutorial. visual studio had some updates that broke it
๐Ÿ‘ 1
Avatar
@Atomicskullz those lines were already commented out for me? ๐Ÿ˜•
Avatar
Atomicskullz 6/26/2021 4:36 PM
oh
4:36 PM
which version of visual studio you using?
Avatar
2019
Avatar
Atomicskullz 6/26/2021 4:36 PM
idk then
4:36 PM
atm im using preview but i doubt thats the case
Avatar
Just checking: are those the only 4 lines I should comment out?
4:38 PM
Or should I also comment #define TUPLES_USE_DEFAULTED_FUNCTIONS 1 ?
4:39 PM
Oke, I found the issue I think, the only error thats left is the TSharedPtr one
Avatar
Avatar
KraxKrokat
2019
Fixes are on the github as a PR from me.
5:35 PM
Avatar
Ty Lethal ๐Ÿ™‚
Avatar
Atomicskullz 6/27/2021 1:56 PM
so i need some help with when I should use dynamic_cast. Previously, I always used static_cast when downcasting, and according to research I conducted its more safer than dynamic_cast. I know that dynamic_cast occurs during run-time, but I dont know the significance behind it.
Avatar
So im really new to this stuff, anyone know how i would go about placing lets say a metal foundation with the plugin?
Avatar
Avatar
Axenari
So im really new to this stuff, anyone know how i would go about placing lets say a metal foundation with the plugin?
You would need to load the BP path of the foundation, to get the UClass* of the foundation. to load it use UVictoryCore::BPLoadClass() Then you can use ArkApi::GetApiUtils().GetWorld()->SpawnActor() (edited)
Avatar
Atomicskullz 6/30/2021 11:30 AM
Does ark api have the full reflection system from UE? Basically i need to inject base class functions without class derivation (since lua doesnt support it)
Avatar
Avatar
Atomicskullz
Does ark api have the full reflection system from UE? Basically i need to inject base class functions without class derivation (since lua doesnt support it)
It should
Avatar
jraServerAPI 7/5/2021 9:56 PM
no worries
Avatar
I don't need the whole code though, just the section where the steamid issue is
Avatar
Avatar
Pelayori
I don't need the whole code though, just the section where the steamid issue is
thats the problem everywhere
9:57 PM
where getsteamidfromcontroller is used
9:57 PM
from the arkapiutils
Avatar
Did you try using the official repo's headers?
Avatar
what are the official repos headers? i got mine out of herer https://github.com/WETBATMAN/ARK-Server-API
Server plugins support for ARK. Contribute to WETBATMAN/ARK-Server-API development by creating an account on GitHub.
Avatar
Server plugins support for ARK. Contribute to Michidu/ARK-Server-API development by creating an account on GitHub.
Avatar
i tried those before that
Avatar
Hmm, not sure then
9:59 PM
I have no clue
Avatar
xD your not the only one
Avatar
Hey! Is there a place that has a collection of premade JSON files I can build off of for my servers for the Shop,Currency, and Kits plugin? โ˜บ๏ธ
Avatar
Nick ๐ŸŒ 7/11/2021 12:00 AM
Hey, I am getting a ton of errors similiar to this: version\Core\Public\API\UE\Containers\../Windows/MicrosoftPlatformString.h(24): error C2664: 'errno_t strcpy_s(char *,rsize_t,const char *)': cannot convert argument 1 from 'WIDECHAR *' to 'char *' version\Core\Public\API\UE\Containers\../Windows/MicrosoftPlatformString.h(24): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\string.h(32): note: see declaration of 'strcpy_s' It seems UE/BasicTypes is including headers that, at least on my system, contradicts each other. Has anyone encountered this before?
12:01 AM
Oh, yeah, I am using CMake in CLion; not sure if anyone has managed to get that working? Slowly warming up to the idea of welcoming VS back on my system. ๐Ÿ˜› (edited)
Avatar
Nick ๐ŸŒ 7/11/2021 12:24 AM
Got it all figured out. ๐Ÿ˜„
Avatar
Has anyone stumbled across a variable that can tell if a player is controlling a Noglin? For reference, I currently use OwnProx's Teleport Plugin and allow players to use the /tpr and /tpa functions. However, the plugin doesn't (and had no reason to until now) check to see if the player is controlling a Noglin and will actually put the player who is teleporting where the Noglin is and not the actual location of the player. So, my basic idea was to prevent accepting a request if the player is controlling a Noglin. Hopefully that all makes sense.
Avatar
Probably the controller of said noglin is now a player controller
Avatar
Yeah, that is my assumption based on the way it is functioning.
Avatar
Im trying to give an item to a player by command, i need this item to have a custom name. ive not been able to find how id do something like that tho. Last try was this: item->DescriptiveNameBaseField() = "Trophy"; item->UpdatedItem(false); Log::GetLog()->warn(item->DescriptiveNameBaseField().ToString()); AttackerShooterController->GetPlayerInventory()->AddItemObject(item); This gives the actual item i want to, the log shows the name ive given it but the client doesnt see it
Avatar
And won't see it either
9:05 PM
Name is not replicated
Avatar
So theres no way to do this?
9:07 PM
Not sure if there's anything like custom item name that is replicated
9:07 PM
but I know you can change description (edited)
Avatar
Maybe that would work then, how would i do that?
Avatar
Tbf, I don't remember ๐Ÿ˜‚
9:08 PM
Custom Item description I believe
9:08 PM
then multicast it
9:08 PM
and replicate
Avatar
oh god ive got no clue how to do that xD
Avatar
or replicate at the end might not be necessary (edited)
Avatar
multicasting is smthing ive never done (or know what it means)
Avatar
multicasting means sending the updated value of a replicated variable over to clients when multicasted
9:10 PM
you do actor->MulticastProperty(FName(L"varNameWithoutField", EFindName::FName_Add, false));
Avatar
Cool ty!
Avatar
I don't 100% remember it was that way though
9:12 PM
Just keep in mind multicasting just works for variables that are replicated (wouldn't work for example with descriptive item name)
Avatar
While im asking.. ive got 1 more issue. I want to use a hook when an item gets taken from an inventory (not hard at all) but heres the catch, i want to see who takes it and from where so i can check if their from the same tribe
9:13 PM
Makes sense, ty!
Avatar
Avatar
Pelayori
Not sure if there's anything like custom item name that is replicated
I think you can do a custom name
Avatar
On items?
Avatar
Im listening xD
Avatar
๐ŸจDream Doctor๐Ÿฆ˜ 7/25/2021 3:23 AM
@Foppa Any chance you could add that github source code link to #ใ€💌ใ€‘สœแด‡สŸแด˜๊œฐแดœสŸ-สŸษชษดแด‹๊œฑ ? (edited)
Avatar
Avatar
๐ŸจDream Doctor๐Ÿฆ˜
@Foppa Any chance you could add that github source code link to #ใ€💌ใ€‘สœแด‡สŸแด˜๊œฐแดœสŸ-สŸษชษดแด‹๊œฑ ? (edited)
GSH | MrOwlSky 7/25/2021 3:45 AM
Done
Avatar
Avatar
GSH | MrOwlSky
Done
๐ŸจDream Doctor๐Ÿฆ˜ 7/25/2021 3:45 AM
Thank you! ๐Ÿ™‚
GOGCHECK 1
Avatar
Did anyone get increasing of memory using by servers after the updating to 3.51?
10:11 AM
Like gen2 now uses about ~16 gb of memory (edited)
Avatar
Avatar
Nice
Did anyone get increasing of memory using by servers after the updating to 3.51?
Yes, issue has been identified and a new patch is soon to arrive
Avatar
Anyone know how i would delete an item? Tried this but first makes me crash and second times out the player and freezes real bad item->BeginDestroy(); item->RemoveItemFromInventory(true, true); (edited)
Avatar
Remove it from the inventory reference
8:18 PM
UPrimalInventoryComponent::RemoveItem
Avatar
So i wont be able to remove the item from any inventory by deleting an item?
Avatar
No, you need to loop trough every inventory and delete it, or loop trough all item references if you have a list already, get owner inventory and then remove item
Avatar
Alright! That makes me wonder something. Ill give a quick explenaition, im trying to create a custom spoil system
8:22 PM
If they drop the item i think that will bypass right?
Avatar
Most likely
Avatar
Mhh, ive been told every class has a destroy function that will get rid of it entirely
8:24 PM
its not the case for UPrimalItem i guess?
8:24 PM
Sorry if im being dumb, trying to figure out whats my best bet for deleting this item
Avatar
There is DestroyAll command, but it does not work for child classes s you'd need to loop each dropped item class either way
Avatar
Okay let me ask different, if you were to make a spoil system, You already have a working timer, and a pointer to the actual item How would you make the item get removed?
Avatar
Avatar
Axenari
Okay let me ask different, if you were to make a spoil system, You already have a working timer, and a pointer to the actual item How would you make the item get removed?
item->OwnerInventoryField()->RemoveItem(&item->ItemIDField(), false, false, true, true);
Avatar
epic! i didnt know you could reverse get an inv from an item ๐Ÿ˜ฎ
8:35 PM
ty
Avatar
Yeah, items hold a reference to the owner inventory
8:36 PM
And from the owner inventory, you could get OwnerField, that can be character, structure, etc...
Avatar
Very interesting!
8:42 PM
im still struggling with me timing out the entire time because of my plugin first before i can test xD
Avatar
oof! that crashed my server
8:53 PM
(yes i copied the plugin of WetBatman to create my private plugin)
Avatar
Might be worth to check if the inventory is valid
Avatar
Its literally my own inventory tho
8:57 PM
Ill add it for just future cases
8:57 PM
Its a spawned in item, unmoved and in my personal inventory
Avatar
@Axenari Is it for resources that could stack more than 1 actually?
9:13 PM
If that's the case you can use this
9:13 PM
item->OwnerInventoryField()->IncrementItemTemplateQuantity(item->ClassField(), -1, true, false, nullptr, nullptr, false, false, false, false, true, false, true);
Avatar
It wont stack
9:21 PM
Its a survivers trophy w custom name
Avatar
Hmm, then don't use the increment function, it will choose any item of that class and remove
Avatar
Avatar
Pelayori
item->OwnerInventoryField()->RemoveItem(&item->ItemIDField(), false, false, true, true);
try this but instead print the ids from itemidfield
9:22 PM
to see what it outputs (edited)
Avatar
Willdo when i get home
9:22 PM
Tf
9:22 PM
Ty*
Avatar
Avatar
Axenari
Ty*
Either way, the removeItem just calls the UPrimalItem::RemoveItemFromInventory though
Avatar
Problem seems to be finding the item
9:42 PM
Oddly
Avatar
How are you storing the pointer? (edited)
Avatar
UPrimalItem* alphatrophyitem;
10:36 PM
and then when i want to spawn it i do this
10:36 PM
FCustomItemData cdata; cdata.CustomDataName = FName("Alpha Trophy1", EFindName::FNAME_Add); alphatrophyitem->CustomItemNameField() = L"Alpha Trophy"; alphatrophyitem->SetCustomItemData(&cdata); alphatrophyitem->UpdatedItem(false); static_cast<APrimalStructureItemContainer*>(Stand)->MyInventoryComponentField()->AddItemObject(alphatrophyitem);
10:36 PM
theres only 1 instance of the item at a time so i think i dont need a fancy system
Avatar
๐ŸจDream Doctor๐Ÿฆ˜ 7/28/2021 5:22 AM
Hey @substitute , did you ever hear back from WC about this? Do you know if they have fixed it?
Avatar
Does anyone know how i can ensure a structure stays unlocked?
Avatar
ArkApi::Tools::ConvertToWideStr is deprecated? Is there a replacement?
Avatar
@Uaca ArkApi::Tools::Utf8Decode(config["Messages"].value(str, "No message")).c_str());
Avatar
@Pelayori any chance you know how to lock and unlock a structure
7:58 PM
Tried to check w ida but i cant find it (kinda dont know how to use it fully either tbh)
Avatar
Avatar
Axenari
Tried to check w ida but i cant find it (kinda dont know how to use it fully either tbh)
substitute 8/1/2021 4:21 AM
Do you mean pin code or engram?
Avatar
Literally the lock and unlock on lets say a storage box
Avatar
Avatar
Axenari
Literally the lock and unlock on lets say a storage box
you need to set the pin code
10:20 AM
to unlock simply set the pin code to nothing
Avatar
oh wow, that easy? xD testing it soon
Avatar
Can anyone help me with attaching a debugger? it either crashes the server or freezes the server, no clue what im doing wrong
Avatar
@Axenari to unlock just set bUnlocked() to false/true, bIsPinCoded() to true/false and if setting pin lock set the pin code (think there's a function for it)
Avatar
Thanks! just found that out ๐Ÿ˜„
Avatar
Hi, does anybody know where the Survival Quotient (killed bosses) is stored? I looked using ark-tools into .arkprofile and .ark save and didn't find anything
Avatar
Avatar
Fenix
@Uaca ArkApi::Tools::Utf8Decode(config["Messages"].value(str, "No message")).c_str());
ThankS!
Avatar
Does anyone know if theres a hook for items that spoil? or how to detect it via another hook?
Avatar
Avatar
Axenari
Does anyone know if theres a hook for items that spoil? or how to detect it via another hook?
Maybe not directly, but you could look at UPrimalItem_GetSpoilingTime and when time is 0 or 1, (small time), you could trigger your logic
Avatar
@Pelayori Do you know a hook i should use for checking when any item gets destroyed? Ive got this item of which there at any point should only be 1. this item spoils too. So im thinking how i should track this item dissapearing. and ive got no clue
7:02 PM
Right now im trying the hook BeginDestroy However this triggers at really weird moments (My IDA is fucked too, cant check there) ๐Ÿ˜ฆ
Avatar
@Axenari There is a hook I found in the Server API hook Creator App. I'm not sure if it actually works though. c++ DECLARE_HOOK(UPrimalItem_BeginDestroy, void, UPrimalItem*); void Hook_UPrimalItem_BeginDestroy(UPrimalItem* _this) { UPrimalItem_BeginDestroy_original(_this); } ArkApi::GetHooks().SetHook("UPrimalItem.BeginDestroy", &Hook_UPrimalItem_BeginDestroy, &UPrimalItem_BeginDestroy_original); ArkApi::GetHooks().DisableHook("UPrimalItem.BeginDestroy", &Hook_UPrimalItem_BeginDestroy); (edited)
Avatar
Thats the thing @DizzyDwarf i use this, but it fires at random situations where nothing happens to the item
Avatar
Avatar
Axenari
Thats the thing @DizzyDwarf i use this, but it fires at random situations where nothing happens to the item
This is when the engine destroys the actor
8:19 PM
Not when the item breaks
Avatar
It doesnt seem to be the case tho
9:18 PM
it triggers when i spawn in an item
Avatar
and it somehow triggers multiple times without even doing anything
Avatar
Avatar
Axenari
It doesnt seem to be the case tho
Called before destroying the object.
10:07 PM
Destroy in this instance means to clean up a garbage object from memory.
10:09 PM
An object can be moved around in memory to different instances as required, which would leave the previous instance as garbage. One example is dropping an item from your inventory. The item no longer exists and is instead the dropped item instance. Now whether or not WC moves the object reference or creates a new one on the dropped item, I donโ€™t know, this is just an example where it could do a copy construct
Avatar
Right so that doesnt really mean the item is gone..
Avatar
Correct
Avatar
Maybe i should take it another way, as theres always only 1 of the items i have a pointer to it. Is there a way to see if the item is still in the server?
Avatar
Check if pointer is nullptr
2:34 PM
You might want to use weak object ptrs when storing them somewhere where the pointer persists. TWeakObjectPtr<UPrimalItem> item_ptr = GetWeakReference(item);
2:35 PM
That will store the pointer safely and retrieve it if it's still valid, if not then it will return a plain nullptr
2:35 PM
To get the pointer back you can do item_ptr.Get()
2:36 PM
Anyways let me search deeper for spoil
Avatar
To check if its still a thing if(item_ptr != nullptr)
2:36 PM
Right?
Avatar
if (item_ptr.Get() != nullptr)
Avatar
Spoil isnt needed per se, i just need to know if its still there
Avatar
Well, if the pointer is valid means the item is somewhere in the world
2:37 PM
Might be on a dropped item, might be on an inventory, etc...
Avatar
I first took it with the approach to check when it despawns and when it spoils, thats why i wanted to know a spoil hook
2:37 PM
The only info i need is if its anywhere or nowhere so i know enough :)
2:39 PM
One thing i am still struggling with however is spawning in a structure, i got a code from someone where i can spawn in an actor. But i can walk thru it, it doesnt have an owner and it doesnt have an inventory. I would check IDA but its literally broken for me
Avatar
How are you spawning the actor?
Avatar
Let me find it
2:41 PM
inline AActor* BPSpawnActor(UWorld* uworld, FString blueprint, FVector* location, FRotator* rotation, bool do_begin_play) { //auto* world = ArkApi::GetApiUtils().GetWorld(); if (!uworld) { return nullptr; } UClass* object_class = UVictoryCore::BPLoadClass(&blueprint); if (!object_class) { return nullptr; } FActorSpawnParameters new_actor_spawn_params; new_actor_spawn_params.bDeferBeginPlay = true; auto* actor = uworld->SpawnActor(object_class, location, rotation, &new_actor_spawn_params); if (actor) { if (do_begin_play) { actor->BeginPlay(); actor->ForceReplicateNow(false, false); } return actor; } return nullptr; } auto* world = ArkApi::GetApiUtils().GetWorld(); auto character = player_controller->GetPlayerCharacter(); auto location = character->RootComponentField()->RelativeLocationField(); FString blueprint = "Blueprint'/Game/PrimalEarth/Structures/StorageBox_Small.StorageBox_Small'"; auto* actor = BPSpawnActor(uworld, blueprint, &location,
2:42 PM
Accidentally removed too much from the end part here, the last line is normally intact
2:43 PM
I know how to set the health, but not to add an inventory etc
Avatar
UWorld* world = ArkApi::GetApiUtils().GetWorld(); FString tek_path = FString("Blueprint'/Game/PrimalEarth/Structures/StorageBox_TekShield.StorageBox_TekShield'"); UClass* structure_class = UVictoryCore::BPLoadClass(&tek_path); if (!structure_class) Log::GetLog()->critical("There was an error while processing new structures"); AActor* new_actor = world->SpawnActor(structure_class, &loc, &rot, &params); if (new_actor && new_actor->IsA(APrimalStructureItemContainer::GetPrivateStaticClass()))
2:45 PM
This works for me
2:46 PM
loc, rot are on another place outside there, and params is just empty FActorSpawnParameters
Avatar
Oh damn nice
7:43 PM
will test that very soon
Avatar
@Pelayori I tried the TWeakObjectPtr thing, the weird thing is it comes thru as a nullpointer at random times. Whenever i throw it on the ground like 15 seconds before it spoils it had a nullpointer
Avatar
Avatar
Axenari
@Pelayori I tried the TWeakObjectPtr thing, the weird thing is it comes thru as a nullpointer at random times. Whenever i throw it on the ground like 15 seconds before it spoils it had a nullpointer
Then dropped items re create the item
9:43 AM
Probably not the best idea to store the pointer since items get created and destroyed a lot
Avatar
But it stays on the ground just fine for 1 minute 40 seconds
9:51 AM
thats the weird part
Avatar
The item gets destroyed and a clone is created most likely
10:06 AM
So the original ptr is not valid anymore
Avatar
Any way you can think of doing this?
10:11 AM
To be clear, ive got a custom item of which there should only be 1, I can have a pointer to the item as theres only 1 Whenever it cannot detect the item it should fire a function
Avatar
Im kind of out of options ๐Ÿ˜„
Avatar
Avatar
Axenari
Im kind of out of options ๐Ÿ˜„
Did you try get spoling time hook?
2:15 PM
Check if it's your item, and if spoiling time is due to something
2:15 PM
Spoiling time might be world seconds, if so then you just do spoling_time - GetWorld()->GetTimeSeconds()
Avatar
I did get that part
4:29 PM
Ive got an idea that ima test out, thanks for the tip
4:29 PM
It indeed is the time second thing brw
Avatar
So, rn im having this issue. this is a spawned in structure by command
9:19 PM
9:19 PM
it has the servers tribe id, its unlocked and yet i cannot access it
Avatar
It may not have an inventory component @Axenari
Avatar
If i make this my own tribe id it does actually have it
9:21 PM
Found this: AllowStructureAccess();
9:22 PM
but its used to set for 1 player
9:22 PM
i bet its something i need to set it to where everyone can access it
Avatar
Thatโ€™s now how access checks work
Avatar
im confused to how i can access it when its my own tribe tho?
Avatar
Maybe you need to replicate the bUnlocked field
Avatar
Isnt it replicated as it tells in the yellow text unlocked?
Avatar
It might just be the server knowing it's unlocked and setting the box name field to (Unlocked)
9:24 PM
Try force replicate or multicast property
Avatar
(how do i do that?)
Avatar
Try either: Structure->ForceReplicateNow(false, false); or Structure->MulticastProperty(FName("bIsLocked", EFindName::FNAME_Add)); (edited)
9:29 PM
If you can access it when it's your own tribe it might be client not aware of it
Avatar
Which will be fixed w a replicate?
Avatar
That you can access if unlocked
9:29 PM
It's just a guess, I don't know any of your setup
Avatar
Its a simple SpawnActor w a few things added to it
9:31 PM
sidenote
Avatar
Yeah, I can't find anything in the trophy base that prevents inventory access out of the usual checks (edited)
Avatar
whenever i reload my plugin my MySql functions crash my server
9:32 PM
am i missing something with unloading or smthing?
Avatar
It depends, mysql shouldn't crash on unload normally. But without knowing something of your setup it's hard to tell
Avatar
nvm i think i know why.. my mysql is loaded on Init, i guess after reload it doesnt init anymore?
Avatar
On Init game hook?
Avatar
Yeah, could be an issue
9:34 PM
You can add a check on Load() and init if server is ready
Avatar
Its safe to load at any other point right?
9:35 PM
or does it need to be at init
Avatar
if (ArkApi::GetApiUtils().GetStatus() == ArkApi::ServerStatus::Ready) { // code... }
9:35 PM
Yeah, should be safe
Avatar
Alr ty ๐Ÿ˜„
9:36 PM
Ill try the other thing asap
Avatar
Update, no difference
9:43 PM
9:43 PM
here->bForceNoPinLocking(); here->bIsLocked() = false; here->bIsPinLocked() = false; primal_structure->bBPOverrideAllowStructureAccess() = true; here->ForceReplicateNow(false, false); here->MulticastProperty(FName("bIsLocked", EFindName::FNAME_Add));
Avatar
Try replicating the team id
Avatar
here being the very vague naming of the inventory
Avatar
It shouldnโ€™t be yellow if it is your team
Avatar
Its not supposed to be my team
9:44 PM
this is supposed to be an server spawned structure everyone should be able to open
Avatar
Why are you enabling bp override allow access?
Avatar
Avatar
Axenari
this is supposed to be an server spawned structure everyone should be able to open
Use an obi
9:44 PM
Or a drop
9:45 PM
Both would be more obvious too
Avatar
That makes a custom function run to check if the player is allowed and it's likely returning no always
Avatar
And should work without anything special
Avatar
ive got no idea Pelayori
9:45 PM
ill delete it but i dont think itl make a change?
9:45 PM
substitute, its going to be an trophy inside of it, a custom one that lights up
9:45 PM
so it makes sense to have it in there ๐Ÿ˜„
Avatar
You are enabling a function, which the structure does not implement, and it's likely preventing access always
Avatar
Oh, on my way to test it ๐Ÿ˜„
9:47 PM
Removed it, no success yet D:
Avatar
and what is "here"?
Avatar
auto actor = world->SpawnActor(structure_class, &location, rotation, &params); auto* primal_structure = static_cast<APrimalStructure*>(actor); primal_structure->HealthField() = primal_structure->MaxHealthField(); primal_structure->StructureIDField() = 10 + 1; primal_structure->TargetingTeamField() = database->getServerTribeID(); if (primal_structure->IsA(APrimalStructureItemContainer::GetPrivateStaticClass())) { APrimalStructureItemContainer* here = static_cast<APrimalStructureItemContainer*>(primal_structure); here->bForceNoPinLocking(); here->bIsLocked() = false; here->bIsPinLocked() = false; here->ForceReplicateNow(false, false); here->MulticastProperty(FName("bIsLocked", EFindName::FNAME_Add)); }
9:49 PM
Here is the context ๐Ÿ˜„
9:49 PM
& yes im aware i should name things more clear, im an idiot
Avatar
Hmm that structure id I don't know if that is entirely correct
Avatar
ill try and delete that one, see if it changes anything
9:50 PM
Still nope
Avatar
No idea then
Avatar
My ida is broken, any chance you can look me up which things get added normally? so i can replicate the process of a normal placement as much as possible?
Avatar
Spawning is fine, but there's something else we are not seeing for the unlockt (edited)
10:00 PM
what if you just keep the bis locked = false and replicate / multicast (edited)
Avatar
I can try that soon
Avatar
Still doesnt work D:
Avatar
Hello, Sometimes my code enters the if condition bellow, and sometimes it does not: std::wstring blueprint = L"/Game/PrimalEarth/CoreBlueprints/Weapons/PrimalItem_WeaponMetalHatchet.PrimalItem_WeaponMetalHatchet_C"; UObject* object = Globals::StaticLoadObject(UObject::StaticClass(), nullptr, blueprint.c_str(), nullptr, 0, 0, true); if (!object) // Error It seems like I need to wait for the garbage collector or something in the background to happen before I can call this code again. If I call it two times in a row without waiting a little the second call returns NULL. I don't know what is happening exactly and I'm searching a way to always be able to load the blueprint object. Any help appreciated thank you.
Avatar
You might be better off calling UVictoryCore::BPLoadObject or BPLoadClass
Avatar
alright I don't know this namespace, I'm going to look at it thank you (edited)
6:58 PM
also I was trying to reach the ArkModding discord and you helped me on the other Discord server ^^
Avatar
Oh, true
Avatar
but I'm actually using ARK Server API, so I guess it's useless for me to go there, I'm better here right?
6:59 PM
they use Unreal dev kits and so on on the other Discord I suppose
Avatar
It isn't useless, I find some examples of stuff I don't get the idea to do, but in bp code which can be easily translated into cpp
6:59 PM
Or ark quirks they know about and we don't
7:00 PM
It's a good resource with discord search
Avatar
ok
Avatar
Avatar
OSubMarin
Hello, Sometimes my code enters the if condition bellow, and sometimes it does not: std::wstring blueprint = L"/Game/PrimalEarth/CoreBlueprints/Weapons/PrimalItem_WeaponMetalHatchet.PrimalItem_WeaponMetalHatchet_C"; UObject* object = Globals::StaticLoadObject(UObject::StaticClass(), nullptr, blueprint.c_str(), nullptr, 0, 0, true); if (!object) // Error It seems like I need to wait for the garbage collector or something in the background to happen before I can call this code again. If I call it two times in a row without waiting a little the second call returns NULL. I don't know what is happening exactly and I'm searching a way to always be able to load the blueprint object. Any help appreciated thank you.
But this I'd use bp load object/class. only time I needed to use static load object was to load icon objects to use in notifications/chat
Avatar
I used this based on the old Michidu repos ^^
Avatar
Do you need the class or an object itself? Because you could load class and then get the default object, cast to the specific object type and get vars from there
Avatar
it's actually working almost perfectly, just sometimes the function randomly returns NULL for some reason
7:02 PM
I'm just trying to instantiate a new item in game and then make a player drops this new item in front of him
Avatar
You also have StringReferenceToClass which works similarly to BPloadClass
Avatar
Avatar
OSubMarin
I'm just trying to instantiate a new item in game and then make a player drops this new item in front of him
Then you'd want to load the class
7:02 PM
not the object itself
๐Ÿ‘Œ 1
Avatar
static bool MySpawnDrop(unsigned long long steamId, const wchar_t* blueprint, int amount, float item_quality, bool force_blueprint, float min_random_quality, float life_span, float offsetX, float offsetY) { ArkApi::IApiUtils& utils = ArkApi::GetApiUtils(); AShooterPlayerController* aShooterPC = utils.FindPlayerFromSteamId(steamId); if (!aShooterPC) return false; FVector pos = utils.GetPosition(aShooterPC); pos.X += offsetX; pos.Y += offsetY; UObject* object = Globals::StaticLoadObject(UObject::StaticClass(), nullptr, blueprint, nullptr, 0, 0, true); if (object == nullptr) return false; TSubclassOf<UPrimalItem> archetype; archetype.uClass = reinterpret_cast<UClass*>(object); UPrimalItem* item = UPrimalItem::AddNewItem(archetype, nullptr, false, false, item_quality, false, amount, force_blueprint, 0.0F, false, nullptr, min_random_quality); if (!item) return false; FItemNetInfo* info = static_cast<FItemNetInfo*>(FMemory::Malloc(0x400)); RtlSecureZeroMemory(info, 0x400); item->GetItemNetInfo(info, false); TSubclassOf<ADroppedItem> archetype_dropped; archetype_dropped.uClass = reinterpret_cast<UClass*>(object); FVector zero_vector{ 0.0F, 0.0F, 0.0F }; FRotator rot{ 0.0F, 0.0F, 0.0F }; ADroppedItem* dropped = UPrimalInventoryComponent::StaticDropItem(aShooterPC, info, archetype_dropped, &rot, true, &pos, &rot, true, false, false, true, nullptr, &zero_vector, nullptr, life_span); FMemory::Free(info); if (!dropped) return false; return true; }
Avatar
Hmm, there's an api utils function for spawning and dropping an item
Avatar
haha
7:04 PM
complete function above, but I will have to look what you told me about
Avatar
Well yeah, the class is an object technically so that isn't wrong either
Avatar
yes it's mostly copy pasted from API utils
Avatar
Never used said function so can't say if it works or not
Avatar
I randomly enter the if (object == nullptr) return false; sometimes
Avatar
Yeah, shouldn't happen if the class is there
7:05 PM
Try using bpload class
Avatar
yep
Avatar
And just set archetype to that class
Avatar
thanks
Avatar
I'm doing some custom mods for the cluster I'm hosting, but later on I might be able to extract some features from it for a public mod. Actually the only thing that could be interesting is the additional rcon command "zipsavegame" that creates a zip archive of all the .ark/.arkprofile/.arktribe files asynchronously using std::thread.
7:18 PM
I use it because I don't host on my machine so I need to get these data from FTP
7:18 PM
Not really worth to release a mod just for that, it would fit better in ExtendedRCON mod and it's still for a specific usage. (edited)
Avatar
jraServerAPI 8/21/2021 8:17 PM
that's cool
Avatar
Im trying to create an FItemNetID, If found: FItemNetID item_id; item_id.ItemID1 = id1; item_id.ItemID2 = id2; but couldnt find what id1 and id2 are supposed to be. can anyone help me out?
Avatar
The item ids
12:47 PM
FItemNetId has 2 ints, id1 and id2
Avatar
Randomizing them is fine when making an item
๐Ÿคž 1
Avatar
so there's no function to get a new one that does not exist? (edited)
7:36 PM
indeed iterating over every items just to make sure the ids are not taken is probably not worth unless very well optimised
Avatar
To create a new item just use UPrimalItem::AddNewItem with nullptr inventory if you don't want to add it to the inventory yet. Then you could add it with inventory->AddItemObject(item)
Avatar
yep that's what I'm doing, I was just reacting to FItemNetID problem above ^^
7:38 PM
I switched to BPLoadClass as you suggested
Avatar
Results?
Avatar
it removed the unpredictable aspect
7:40 PM
I still have one weird error and I have to run one portion of the code a second time so still not perfect but now it's working, I just need a little more tests to solve the remaining problem
Avatar
Which error?
Avatar
I have one function for spawning an item into a player's inventory and another to spawn and drop an item at the feet of a player. The error only happens with the spawn drop function. I modified a little (but not tested yet), I have this at the moment: static bool MySpawnDrop(unsigned long long steamId, FString* blueprint, int amount, float item_quality, bool force_blueprint, float min_random_quality, float life_span) { ArkApi::IApiUtils& utils = ArkApi::GetApiUtils(); AShooterPlayerController* aShooterPC = utils.FindPlayerFromSteamId(steamId); if (!aShooterPC) return false; UClass* bpUClass = UVictoryCore::BPLoadClass(blueprint); if (!bpUClass) return false; TSubclassOf<UPrimalItem> archetype = TSubclassOf<UPrimalItem>(bpUClass); UPrimalItem* item = UPrimalItem::AddNewItem(archetype, nullptr, false, false, item_quality, false, amount, force_blueprint, 0.0F, false, nullptr, min_random_quality); if (!item) return false; ADroppedItem* dropped = NULL; FVector zero_vector{ 0.0F, 0.0F, 0.0F }; FRotator rot{ 0.0F, 0.0F, 0.0F }; FVector pos = utils.GetPosition(aShooterPC); FItemNetInfo* info = static_cast<FItemNetInfo*>(FMemory::Malloc(0x400)); if (!info) return MyRemoveItem(&item); try { RtlSecureZeroMemory(info, 0x400); item->GetItemNetInfo(info, false); TSubclassOf<ADroppedItem> archetype_dropped = TSubclassOf<ADroppedItem>(bpUClass); dropped = UPrimalInventoryComponent::StaticDropNewItemWithInfo(aShooterPC, info, archetype_dropped, &rot, true, &pos, &rot, true, false, false, true, nullptr, zero_vector, nullptr, life_span); } catch (...) {} FMemory::Free(info); if (dropped == NULL) return MyRemoveItem(&item); return true; } (edited)
7:50 PM
and this one is working without errors: static FORCEINLINE bool MySpawnInInventory(unsigned long long steamId, FString* blueprint, int amount, float item_quality, bool force_blueprint, float min_random_quality) { UClass* bpUClass = UVictoryCore::BPLoadClass(blueprint); if (!bpUClass) return false; AShooterPlayerController* aShooterPC = ArkApi::GetApiUtils().FindPlayerFromSteamId(steamId); if (!aShooterPC) return false; AShooterCharacter* aShooterCharacter = static_cast<AShooterCharacter*>(aShooterPC->CharacterField()); if (!aShooterCharacter) return false; UPrimalInventoryComponent* inventoryComponent = aShooterCharacter->MyInventoryComponentField(); if (!inventoryComponent) return false; // Probably some cleaner way to check if item is stackable here: UPrimalItem* tmp = (UPrimalItem*)(bpUClass); UPrimalItem* tmpB = (UPrimalItem*)(bpUClass); int quantityOverride = 2; bool canStack = (inventoryComponent->bAllowItemStacking()() && tmp && tmpB && tmp->CanStackWithItem(tmpB, &quantityOverride)); TSubclassOf<UPrimalItem> archetype = TSubclassOf<UPrimalItem>(bpUClass); UPrimalItem* item = UPrimalItem::AddNewItem(archetype, nullptr, false, !canStack, item_quality, false, amount, force_blueprint, 0.0F, false, nullptr, min_random_quality); if (!item) return false; bool isUsableConsumable = item->IsUsableConsumable(); try { UPrimalItem* item2 = inventoryComponent->AddItemObjectEx(item, false, false, !canStack, true, !isUsableConsumable, false, aShooterCharacter, false, nullptr, false); if (item2 == NULL) return MyRemoveItem(&item); } catch (...) { return MyRemoveItem(&item); } return true; }
7:52 PM
so yeah my problem is only on the MySpawnDrop() function. On the first call I enter the if (dropped == NULL) return MyRemoveItem(&item); but on second call it works
7:53 PM
I will test this version cause it changed a bit but I will let you know ^^
7:53 PM
ho and : static FORCEINLINE bool MyRemoveItem(UPrimalItem** item) { // Probably some cleaner way to make sure item has been removed from game here: try { if ((*item)->bAddedToWorldItemMap()()) (*item)->RemoveFromWorldItemMap(); (*item)->ConditionalBeginDestroy(); (*item) = NULL; } catch (...) {} return false; }
7:54 PM
I'm kinda going ham to get rid of previous item haha, probably some cleaner way
Avatar
UPrimalItem* tmp = (UPrimalItem*)(bpUClass); UPrimalItem* tmpB = (UPrimalItem*)(bpUClass); I'd use (UPrimalItem*)(bpUClass->GetDefaultObject(true));
Avatar
ah right
Avatar
AShooterCharacter* aShooterCharacter = static_cast<AShooterCharacter*>(aShooterPC->CharacterField()); Also this will get the dino pawn (and thus cast is null) if riding dino. You can use aShooterPc->GetPlayerCharacter() as a more reliable way to get the player character
๐Ÿ‘Œ 1
๐Ÿ‘ 1
Avatar
I want real instances not just class
Avatar
You could also try other static drop functions, there's 3 of them. There's Static Drop Item which will take an existing's FItemNetInfo*, and Static Drop New Item which takes class and just creates a new item then drop it
๐Ÿ‘Œ 1
7:57 PM
For remove, there's inventory functions for it, which have return bools for safety
7:58 PM
bool RemoveItem(FItemNetID * itemID, bool bDoDrop, bool bSecondryAction, bool bForceRemoval, bool showHUDMessage)
Avatar
yes but I want to clean item in case of drop error
7:58 PM
so the item is not in any inventory
Avatar
ah well
Avatar
(I created it with nullptr) (edited)
7:59 PM
so yeah I tried the dirty hack above and cross finger so that it doesn't mess up ^^ (edited)
Avatar
I'm not confident about that way
8:00 PM
If it's not dropped nor in any inventory you could just leave it there and if it's not referenced or taken care of eventually it'll get cleaned by GC
Avatar
yeah basically I'm just telling GC I'm done with it, so that eliminates a possible memory leak (unused memory), but I take the risk of a pointer still pointing at it somewhere in the game's logic (edited)
8:01 PM
(*item)->ConditionalBeginDestroy(); (*item) = NULL; This tells GC I'm done with it, if I'm correct (edited)
8:02 PM
and I saw there was these two functions bAddedToWorldItemMap() RemoveFromWorldItemMap() so I added them too
8:02 PM
so far no Segmentation Fault ๐Ÿคž ^^ (it would be safer to just remove the MyRemoveItem call I agree) (edited)
Avatar
UPrimalItem::RemoveFromWorldItemMap() this call could be a bad thing or the thing saving me from segfault, I don't know what it does actually (edited)
8:14 PM
based on function name I just assumed it has to do with the list of UPrimalItem in the world (maybe it's not even called I didn't check if I enter this if condition yet). (edited)
Avatar
there's no way of getting the inner logics of game functions except by testing them or IDA I suppose? (this discord and repositories is already very good sources of knowledge, also I want to get into the other arkmodding discord but still getting a 404) (edited)
9:27 PM
I kinda miss managed code for that ^^ (edited)
Avatar
Avatar
OSubMarin
there's no way of getting the inner logics of game functions except by testing them or IDA I suppose? (this discord and repositories is already very good sources of knowledge, also I want to get into the other arkmodding discord but still getting a 404) (edited)
if it's a function made strictly for ARK, the only way you can find info about it is via IDA or maybe devkit documentation
9:49 PM
if it's a function from Unreal imported into the game, then you can just google it and unreal docs will have all the info about it
Avatar
true, I've already read a little* Unreal documentation already (edited)
9:52 PM
and sorry for the edits, searching my words sometimes, english is not my primary language
Avatar
Avatar
OSubMarin
indeed iterating over every items just to make sure the ids are not taken is probably not worth unless very well optimised
Thereโ€™s no concern with two randomized ids
3:17 AM
Itโ€™s a large numbers birthday problem
3:17 AM
Both random id 1&2 are large numbers, so the odds A or B are the same are very small
3:17 AM
For an item to be a duplicate both A & B must be the same
3:17 AM
Not just A or B
3:18 AM
But itโ€™s already unlikely two items will have A or B be the same, significantly less A and B
3:18 AM
I think it is an unsigned short, so you have 1/2^16 for A or B being the same
3:18 AM
And what like 1/2^32 both are?
Avatar
perhaps larger odds, it's been a hot minute since I've had to figure probability out
3:26 AM
tldr; two random ids for A and B are essentially always unique
Avatar
yeah, except they're not and you can still end up with duplicate if unlucky (or very unlucky if you prefer) ^^ (edited)
9:45 AM
but I get your point, it seems safe enough for sure (edited)
Avatar
Avatar
OSubMarin
yeah, except they're not and you can still end up with duplicate if unlucky (or very unlucky if you prefer) ^^ (edited)
Randomization is literally how the game engine generates them
9:52 AM
The chances that you generate two of the same random Id sets is so significantly low itโ€™s less than a rounding error on a rounding error
Avatar
you're not taking into account the number of already generated IDs tho
Avatar
You do know how significant figures works right?
Avatar
no but I know about probabilities
Avatar
Even if you had 100 million items active you still have less than a 3% chance of a duplicate (actual value) (edited)
Avatar
alright, seems safe enough for sure
Avatar
Item ids are also often discarded/regenerated
9:55 AM
It really is a really insignificant chance of a duplicate
๐Ÿ‘Œ 1
๐Ÿ‘ 1
9:55 AM
If you manage to get one, buy a lottery ticket
Avatar
ok haha ^^
9:57 AM
I guess the AddNewItem() function is responsible for generating these IDs
Avatar
Probably, Iโ€™m not at my pc atm
Avatar
seems a bit like a waste of time to generate random IDs when you could just use a static float somewhere
10:01 AM
I guess it has to do with networks constraints, or maybe security so that you cannot guess IDs easily (edited)
Avatar
Hey! im still struggling with the same things, this is like a duo issue im dealing with right now
4:15 PM
4:16 PM
4:17 PM
Picture 1: Trophy stand that i spawned in with code, this doesnt look right to me but i generally dont care it looks weird. but it might cause the issues in pic two
4:17 PM
Picture 2: this is the trophy i spawn in with code. this normally has a spoil timer of 1 hour. when i spawn it in on the trophy stand it 1. does not switch to the trophy slot, 2. doesnt have a spoil timer (i did not test to spawn in any other inventory yet) (edited)
4:18 PM
my goal: structure is from the server, this is accessable by everyone. i want to be able to respawn the trophy with a function. it should be with a full spoil timer (the stand makes it never spoil as the multiplier is very high) and in the trophy slot.
4:19 PM
code 1: spawning of the base. auto actor = world->SpawnActor(structure_class, &location, rotation, &params); auto* primal_structure = static_cast<APrimalStructure*>(actor); primal_structure->HealthField() = primal_structure->MaxHealthField(); primal_structure->TargetingTeamField() = database.get()->getServerTribeID(); if (primal_structure->IsA(APrimalStructureItemContainer::GetPrivateStaticClass())) { APrimalStructureItemContainer* here = static_cast<APrimalStructureItemContainer*>(primal_structure); here->BeginPlay(); here->bIsLocked() = false; here->ForceReplicateNow(false, false); here->MulticastProperty(FName("bIsLocked", EFindName::FNAME_Add)); }
4:19 PM
code 2: spawning of the trophy: FString classname = FString(TrophyBPPath); UObject* trophyclass = UVictoryCore::BPLoadClass(&classname)->GetDefaultObject(true); UPrimalItem* alphatrophyitem = static_cast<UPrimalItem*>(trophyclass); if (alphatrophyitem) { alphatrophyitem->NextSpoilingTimeField() = ArkApi::GetApiUtils().GetWorld()->TimeSecondsField() + 3600; alphatrophyitem->UpdatedItem(false); static_cast<APrimalStructureItemContainer*>(Stand)->MyInventoryComponentField()->AddItemObject(alphatrophyitem); alphatrophyitem->AddToSlot(-1, true);
Avatar
I am not sure adding an item class default object to an inventory can bring anything good
4:20 PM
Since all items get their settings fro CDO instance (edited)
4:20 PM
You can use UPrimalItem::AddNewItem and set inventory to nullptr, then you can use the add item object func
4:21 PM
About the structure, what is the issue exactly?
Avatar
The structure does not really have an issue, i thought it might be the cause of the issue
4:25 PM
im going to try your method and update ๐Ÿ˜„
4:28 PM
How do i get TSubClassOf
4:28 PM
@Pelayori
Avatar
You can just input UClass
Avatar
& how do i get that xD
Avatar
You get it from bp load class
Avatar
Mhh ive got a line for that in my previous code but it made an UObject tho
Avatar
because you are getting the class default object
4:30 PM
Either way, UClass is an UObject too
4:30 PM
The return type of bp load class is UClass pointer
Avatar
ah sorry, i get confused w these terms sometimes
4:30 PM
thanks!
4:33 PM
it works!
4:33 PM
except that it doesnt switch to the equip slot
4:34 PM
alphatrophyitem->AddToSlot(-1, true);
Avatar
I don't know the indexes for the slots
4:34 PM
But is -1 one of them?
Avatar
if i index the slot for equip it says its -1
Avatar
Try using the functions to add to slot in the inventory
Avatar
only function i could find that might work is: ServerEquipItem
Avatar
ServerAddItemToSlot or ServerAddItemToSlot_Implementation might do the trick
4:38 PM
Maybe try using 0 for the index
Avatar
no result
Avatar
try equpping it manually, and loop trough the items, and log the slot index to console
Avatar
tried this on an additem hook: Log::GetLog()->warn(item->SlotIndexField());
4:52 PM
it always returns -1 tho, even if it enters normal inv
Avatar
that might be too early
Avatar
interesting, ill try it another way!
5:00 PM
very weird
5:00 PM
5:00 PM
5:00 PM
in a fabricator?
Avatar
That's why I think -1 is not the right index to equip on the slot
5:01 PM
-1 is likely used when no slot is used
5:01 PM
I'd try 0, 1 indexes as those seem logical, but this is ark lol (edited)
Avatar
it depends on the inventory
5:02 PM
but each inventory has 2 arrays
5:02 PM
for items to hold
5:02 PM
one is for equipped items and the second array is for just regular inventory slots
Avatar
Whatever i try it doesnt work, inventory->CanEquipItem(item) returns true
6:29 PM
but: item->EquippedItem();
6:29 PM
and item->AddToInventory(static_cast<APrimalStructureItemContainer*>(Stand)->MyInventoryComponentField(), true, false, nullptr, false, false, false);
6:29 PM
do not do anything
Avatar
none of those are to add to the slot
6:30 PM
to add the item to the inventory call inventory->AddItemObject
6:31 PM
equippedItem() is just an event that runs when an item is equipped
6:31 PM
doesn't actually equip it
Avatar
Adding to a slot simply does not work for me, tried it all
6:32 PM
if i add it w a line and manually equip it it works
6:32 PM
now im looking for a way to make it equip, as slots dont work at all
Avatar
Did you try adding it to slot 0?
6:38 PM
I've seen examples without the force bool
Avatar
I did
6:38 PM
Ive not tried without force bool
6:39 PM
I cannot try it rn sadly but i guess ill try that next
6:39 PM
Im fairly sure the trophy stand itself has flaws too tho, it isnt registered in all structures (i cannot find it by id for example)
6:40 PM
Now i dont mind it as it shows and it works fine but it might be a cause
Avatar
You could use AddItemObjectEx with bEquipItem true. That's what cryopods use to add + equip saddle (edited)
Avatar
Hmm, i fixed that issue
12:36 PM
now, how do i loop all inventories?
12:37 PM
tried to modify this: UGameplayStatics::GetAllActorsOfClass(ArkApi::GetApiUtils().GetWorld(), APrimalStructure::GetPrivateStaticClass(), &FoundActors);
12:37 PM
but it works different
12:38 PM
actually i try to loop every item on the server on startup
Avatar
You can change the class to APrimalStructureItemContainer
1:23 PM
So then you will only get structures with inventory, on each loop cast the AActor* pointer of the array to primal structure item container
Avatar
But what about player invs, item bags etc?
Avatar
You have various options which can use together 1) Primal Characters (players/dinos) 2) ShooterCharacters (only players) 3) Primal Dino Characters (only dinos) 4) Primal Structure Item Container (all structures, bags too)
1:34 PM
players/dinos will get also dead ones, so if you need to do anything other than checking inventory make sure they aren't dead
Avatar
I'm trying to use the CheatManager to give an item to a player but I'm not able to make it work. static bool MyGiveItemNum(unsigned long long steamId, int itemNumId, int quantity, float quality, bool forceBlueprint) { ArkApi::IApiUtils& utils = ArkApi::GetApiUtils(); AShooterPlayerController* aShooterPC = utils.FindPlayerFromSteamId(steamId); if (!aShooterPC) return false; UShooterCheatManager* cheatManager = utils.GetCheatManager(); // I tried with "GetCheatManagerByPC(aShooterPC);" it doesn't work either if (!cheatManager) return false; cheatManager->GiveItemNumToPlayer(aShooterPC->GetLinkedPlayerID(), itemNumId, quantity, quality, forceBlueprint); return true; } It works as expected on first call, but on subsequent calls nothing happens. If I drop the item obtained with first call and call my function again it is now working, but item I receive is the same item that I just dropped (if I pick the dropped item it vanishes as it is already in my inventory).
1:43 PM
Look like some item regeneration is not happening as I keep getting the same item over and over.
Avatar
why all this hassle lol
1:44 PM
PC->GiveItem(&SpawnedItems, &fBlueprint, Amount, Quality, IsBlueprint, false, 0);
1:44 PM
PC is PlayerController
Avatar
I tried this too
1:44 PM
same result
Avatar
this works 100%, it's used in every single plugin
Avatar
hmmm, I was almost sure to have tried this tho, let me give it another try
Avatar
is your PlayerController null?
Avatar
no the PlayerController is alright
1:46 PM
at least it seems OK (I don't enter the !aShooterPC condition)
Avatar
then this function will work (as long as you're not on the re spawn screen) ๐Ÿ˜„
Avatar
the function I copy pasted above ?
Avatar
no, the function i sent
Avatar
ah ok
1:46 PM
thanks
Avatar
I get the same result with PC->GiveItem() ๐Ÿ˜ข @WETBATMAN
2:16 PM
static bool MyGiveItemNum(unsigned long long steamId, FString* blueprint, int quantity, float quality, bool forceBlueprint) { ArkApi::IApiUtils& utils = ArkApi::GetApiUtils(); AShooterPlayerController* aShooterPC = utils.FindPlayerFromSteamId(steamId); if (!aShooterPC) return false; TArray<UPrimalItem*> spawnedItems; if (!aShooterPC->GiveItem(&spawnedItems, blueprint, quantity, quality, forceBlueprint, false, 0)) return false; return true; } First call works but subsequent call nothing happens (well actually I think I know what happens, it gives me the same item but the anti-dupe check is preventing the same item from getting added again) (edited)
2:18 PM
And I have the exact same problem with UPrimalItem::AddNewItem() which every times returns the same item to me instead of creating a new one. (edited)
2:20 PM
actually I enter the !aShooterPC->GiveItem( False condition on the 2nd call (edited)
Avatar
Avatar
OSubMarin
static bool MyGiveItemNum(unsigned long long steamId, FString* blueprint, int quantity, float quality, bool forceBlueprint) { ArkApi::IApiUtils& utils = ArkApi::GetApiUtils(); AShooterPlayerController* aShooterPC = utils.FindPlayerFromSteamId(steamId); if (!aShooterPC) return false; TArray<UPrimalItem*> spawnedItems; if (!aShooterPC->GiveItem(&spawnedItems, blueprint, quantity, quality, forceBlueprint, false, 0)) return false; return true; } First call works but subsequent call nothing happens (well actually I think I know what happens, it gives me the same item but the anti-dupe check is preventing the same item from getting added again) (edited)
do you get the anti dupe error in server console? (edited)
Avatar
ah no that's just a supposition
2:25 PM
I don't even check in game console
Avatar
if the server removes something for anti dupe, it always appears in server console
2:25 PM
i never had issues with this function
2:25 PM
what's the quantity you're spawning
2:26 PM
with quality 2
2:26 PM
force bp false (edited)
Avatar
are you sure the bp path is correct?
Avatar
yes
2:26 PM
Blueprint'/Game/PrimalEarth/CoreBlueprints/Weapons/PrimalItem_WeaponMetalHatchet.PrimalItem_WeaponMetalHatchet'
2:26 PM
otherwise it would not work I guess
Avatar
so you get the item added?
Avatar
yes on first call the item is added with proper quality, but on second call I enter the second if condition, and what is weird now if I call it a third time it works again
2:28 PM
but now I will enter two times the second if condition before next call is working
2:28 PM
then three times,
2:28 PM
etc
2:28 PM
so weird xD
Avatar
checking the function it seems to return false if the character or the inventory are null
2:29 PM
how do you call the function?
Avatar
I call it from a seperate thread that I create with std::thread
Avatar
ah
2:30 PM
you can't multi thread in this game
2:30 PM
๐Ÿ˜„
Avatar
lmao xD
Avatar
yeah that will crash 99% of the time
2:30 PM
maybe you'll get lucky that 1% ๐Ÿ˜„
2:30 PM
you can probably get away with multi threading if you lock the game tick
2:30 PM
but that's not really multi threading at that point ๐Ÿ˜„
2:30 PM
since you pause the game
Avatar
ok I will have another try on current thread next time
2:31 PM
is it safe to call it upons ChatMessage trigger from ArkApi ?
Avatar
in main thread?
2:32 PM
everything is safe in main thread
Avatar
in this function : bool ChatMessageCallback(AShooterPlayerController* _AShooterPlayerController, FString* Message, EChatSendMode::Type Mode, bool spam_check, bool command_executed) { // here }
Avatar
just nullptr check the variables you're using
2:32 PM
you can add your own chat message
2:32 PM
ArkApi::GetCommands().AddChatCommand("/bp", &GetIP);
2:32 PM
like this
2:32 PM
first param is the chat message it will intercept
2:33 PM
second param is the function invoked for that command
Avatar
ah ok I didn't know I was just parsing Message for /bp
Avatar
I guess it's doing same thing anyway x)
Avatar
API has callback binders for console commands, RCON commands and chat commands
Avatar
good
Avatar
Avatar
OSubMarin
I guess it's doing same thing anyway x)
yes but it's kinda unclean to hook it this way when the API can just manage it all for you ๐Ÿ˜„
Avatar
true I will make use of it
2:36 PM
can you pass arguments to the chat command?
Avatar
it has predefined params
2:37 PM
void GetIP(AShooterPlayerController* PC, FString* message, int mode)
Avatar
thanks
Avatar
It works way better without std::thread thanks again WETBATMAN
4:42 PM
it seems the item quality is always random w/e float value I set, but that's another problem ^^ (edited)
Avatar
Any game stuff don't multi thread it. I use threading quite a bit on MySQL caching for example. There's an example on that on the permissions plugin source
Avatar
Well my ZipSavegame RCON command was working nicely in a separate thread so I thought I could also manipulate the game from there
4:45 PM
my bad
4:46 PM
What are you multithreading? calls to MySQL or calls to game code?
Avatar
Calls to Mysql, doing queries to fetch the data
Avatar
ah ok that's why it works
Avatar
Then if I need to do anything I do it on the main thread
Avatar
ok
4:50 PM
regarding the item quality that seems random, I guess I will have to use one the method that expose the "min_random_quality" parameter
4:50 PM
correct?
Avatar
Avatar
OSubMarin
it seems the item quality is always random w/e float value I set, but that's another problem ^^ (edited)
you can set exact quality with the function i posted in examples
Avatar
thanks
Avatar
oh actually it's not posted in examples
Avatar
are you sure you posted it in exemples?
Avatar
my bad
Avatar
yeah ^^
4:52 PM
no problem
Avatar
void SetItemStatValue(UPrimalItem* item, EPrimalItemStat::Type item_stat_type, const float new_value) { float newStat = 0.f; if (item_stat_type == EPrimalItemStat::Armor || item_stat_type == EPrimalItemStat::MaxDurability) { item->ItemStatValuesField()()[item_stat_type] = 0; float old_stat_modifier = item->GetItemStatModifier(item_stat_type); item->ItemStatValuesField()()[item_stat_type] = 1; newStat = (new_value - old_stat_modifier) / (item->GetItemStatModifier(item_stat_type) - old_stat_modifier); } else if (item_stat_type == EPrimalItemStat::WeaponDamagePercent) { item->ItemStatValuesField()()[item_stat_type] = 0; float min_damage = item->GetItemStatModifier(item_stat_type); item->ItemStatValuesField()()[item_stat_type] = 65535; float max_damage = item->GetItemStatModifier(item_stat_type); float diff = max_damage - min_damage; float multiplier = 65535 / diff; newStat = new_value / 100.f - min_damage; newStat *= multiplier; newStat += 1.f; } if (newStat >= 65536.f) newStat = 65535; item->ItemStatValuesField()()[item_stat_type] = newStat; if (item_stat_type == EPrimalItemStat::MaxDurability) { if (item->bUseItemDurability()()) item->ItemDurabilityField() = item->GetItemStatModifier(item_stat_type); } #ifdef Ark item->UpdatedItem(false); #endif #ifdef Atlas item->UpdatedItem(); #endif }
4:52 PM
here
Avatar
ah, that's seems a bit big for my need (I don't need to set the exact stat) (edited)
4:53 PM
I'm fine with the random aspect, I just want to always have a Rare item if I set quality to 2, but you can get common and unusual item it seems
4:53 PM
I think the min_random_quality is supposed to prevent having common/unusual
4:56 PM
I will do some tests and fallback to set an exact value with your method if I don't succeed with the min_random_quality
Avatar
You can always try with UPrimalItem::AddNewItem or some other funcs (edited)
4:56 PM
Add new item has more properties to init the item (edited)
Avatar
yep that's what I wanted to do, because last time I tried them I was still in another thread and I was not understanding why everything was acting so weird (unpredictable function returns)
Avatar
Just threads ๐Ÿ˜„
Avatar
Avatar
OSubMarin
I call it from a seperate thread that I create with std::thread
As Batman said you canโ€™t multithread
6:04 PM
A large amount of functions will throw an assert if they are not run on the game thread
Avatar
not when you do catch (...) { /*doNothing*/ } like me ^^ (edited)
6:07 PM
well, maybe it throws but I didn't deal with ๐Ÿ˜„
Avatar
Catch(...) is dangerous. We had some crash prevention in the base API and we ended up removing it because Michidu said it was very dangerous to catch exceptions like that
Avatar
yes I know it's bad
6:08 PM
it's just for quick tests purposes
6:08 PM
generally ^^
Avatar
Well then it's fine, just don't use for production
๐Ÿ‘Œ 1
Avatar
handling errors with exceptions is generally bad, not only the catch (...) { /*doNothing*/ } (but this one is the worst) (edited)
6:13 PM
it uses a lot of resources
Avatar
It works perfectly without std::thread, beautiful. (edited)
7:31 PM
You've done a great work on this API congrats.
๐ŸคŸ 1
Avatar
static bool MyGiveItem(uint64 targetSteamId, FString* blueprintPath, int quantity, float quality, bool forceBlueprint, float minRandomQuality) { // Get target player AShooterPlayerController* target = ArkApi::GetApiUtils().FindPlayerFromSteamId(targetSteamId); if (!target) return false; // Get target player's inventory UPrimalInventoryComponent* targetInventory = target->GetPlayerInventoryComponent(); if (!targetInventory) return false; // Get target player character AShooterCharacter* targetCharacter = target->GetPlayerCharacter(); if (!targetCharacter) return false; // Get item class UClass* bpUClass = UVictoryCore::BPLoadClass(blueprintPath); if (!bpUClass) return false; // Is item stackable? UPrimalItem* defaultItem = (UPrimalItem*)(bpUClass->GetDefaultObject(true)); int quantityOverride = 2; bool canStack = (targetInventory->bAllowItemStacking()() && defaultItem && defaultItem->CanStackWithItem(defaultItem, &quantityOverride)); // Create the item UPrimalItem* item = UPrimalItem::AddNewItem(TSubclassOf<UPrimalItem>(bpUClass), nullptr, false, !canStack, quality, false, quantity, forceBlueprint, 0.0F, false, nullptr, minRandomQuality); if (!item) return false; // Add the item to target's inventory if (!targetInventory->AddItemObjectEx(item, false, false, !canStack, true, !item->IsUsableConsumable(), false, targetCharacter, false, nullptr, false)) return false; // Return success return true; } (edited)
7:48 PM
I use this template now as it gives a lot of control on the spawned item (I didn't try all parameters yet, like the ClampStats boolean and MaxDifficultyClamp float value).
7:49 PM
But I tried the minRandomQuality and it works, I'm able to always get a Rare item by setting it to 2 (and still getting a random rare quality). (edited)
๐Ÿ‘ 2
Avatar
You could probably do this to reduce your temporary variables // Is item stackable? UPrimalItem* cdo = (UPrimalItem*)(bpUClass->GetDefaultObject(true)); //(UPrimalItem*)(bpUClass); int quantityOverride = 2; bool canStack = (targetInventory->bAllowItemStacking()() && cdo && cdo->CanStackWithItem(cdo, &quantityOverride));
8:00 PM
bpUClass->GetDefaultObject(true) should be returning the same pointer anyways for tmp and tmpB (edited)
Avatar
yep I was planning on checking pointers values
8:01 PM
but if you're confident enough I'll directly switch to that
Avatar
CDO is the class default object
8:01 PM
it should never change
๐Ÿ‘ 1
Avatar