Guild icon
Ark Server Api
── ( Advanced | Topics ) ── / 【💬】ᴅɪꜱᴄᴜꜱꜱɪᴏɴ-ᴀ
Avatar
Are here a german Plugin Dev.?
Avatar
How would i go about getting the Inventory of a structure? for context, trying to adjust inventory slot count on structure placement using Hook_APrimalStructure_BPPlacedStructure(APrimalStructure* _this, APlayerController* ForPC)
7:06 PM
cant seem to find any relevant methods
Avatar
Nevermind, found it
Avatar
You need to have the Plugin role on the site. Write a pm on the site to me if you like to get the role
Avatar
Avatar
Foppa
You need to have the Plugin role on the site. Write a pm on the site to me if you like to get the role
Nguyễn Đình Huy 3/11/2021 3:49 PM
I have sent you a message GOGCHECK
fgc_check 1
Avatar
Is there another way to do this to get more information as to what callback failed? This code prevents a server crash when something happens in a timer that fails but doesn't provide any information besides it prevented a crash. void Commands::CheckOnTickCallbacks(float delta_seconds) { __try { for (const auto& data : on_tick_callbacks_) { if (data) { data->callback(delta_seconds); } } } __except (EXCEPTION_EXECUTE_HANDLER) { Log::GetLog()->error("CheckOnTickCallbacks Failed"); } } void Commands::CheckOnTimerCallbacks() { __try { for (const auto& data : on_timer_callbacks_) { if (data) { data->callback(); } } } __except (EXCEPTION_EXECUTE_HANDLER) { Log::GetLog()->error("CheckOnTimerCallbacks Failed"); } }
Avatar
__try/__except is only SEH error handling. (edited)
5:02 PM
If it’s crashing I would attach a debugger and generate a crash dump.
5:04 PM
There are some functions provided by the WinApi to get exception info
5:04 PM
I can’t remember them off the top of my head but if you look up SEH exceptions they should have them
Avatar
Avatar
Frigoff
__try/__except is only SEH error handling. (edited)
Looks like it could be compiled using /EHa which which may allow for additional logging using both C and C++ try/catch blocks.
Avatar
Yes.
Avatar
Not sure if that will affect anything else API wise though.
Avatar
I think the best thing to do at this stage is to attach a debugger if at all possible and generate a crash dump.
Avatar
I'm not trying to fix a crash.
7:25 PM
I was looking for a way to help prevent the random crashing some servers get sometimes for timer callbacks.
Avatar
Oh. I misread.
Avatar
SEH handles that but gives them no information
7:26 PM
Mainly was looking for a way to not cause the crash and at least point to the plugin with the issue so that it can be reloaded etc.
Avatar
You could try using GetExceptionCode()
7:28 PM
To try get better information on the matter
7:31 PM
If you have access to C++ exceptions and not directly SEH. I would give those a try. Those can be more specific on the matter
7:34 PM
Might give you some good information if you want to backtrace it
Avatar
I figured it out and forced an error.
7:48 PM
I compiled the API with /EHa along with some function changes in commands.
7:50 PM
I can at least return back the registered name of the callback
Avatar
Nice
Avatar
I just noticed the tip from @Pelayori in #【🤹】ʀᴇꜰᴇʀᴇɴᴄᴇꜱ. The GetPlayerCharacter() function is used at different places in the Ark Server API code base : (edited)
2:58 PM
3:00 PM
So for example if I call ArkApi::GetApiUtils().GetInventoryItemCount() on a player that is just connecting and takes damage it can crash the server? (edited)
Avatar
It is not a 100% crash chance, but odds seem very high (edited)
Avatar
Maybe we can change these calls to LastControlledPlayerCharacterField()?
Avatar
Could change it yeah
Avatar
or make a warning in a comment 🤔
Avatar
The damage must be done within a very short time frame in connect/disconnect to actually trigger a crash
3:10 PM
It has happened in a project of mine recently, and I know other 1 or 2 devs who had to recreate this method in order to not crash the server
3:11 PM
The crash is usually trigger when a dino is targeting a sleeping body (possibly happens more often with invincible pawns?), or that someone is shot by a turret right after the pawn has been un-sleeped
Avatar
very specific
Avatar
As I said not 100% crash chances nor crash causes but if you do something with players on an interval you might come up with it at some point
Avatar
yes I'm doing some processing every seconds on players
3:12 PM
but it does not involve GetPlayerCharacter() :p
Avatar
I did not find anything wrong in my testings, but when live testing it the server would crash on the get player character call apparently
Avatar
@Pelayori it’s probably because of direct access
3:13 PM
Using the method probably wraps the access in a thread safe manner
3:13 PM
Instead of the field
3:13 PM
I’m fairly certain networking is a separate thread
Avatar
Doesn't seem like very thread safe specific on ida, I checked the method and all it does it get the weak ptr from the last character controlled, and call Get() on it
Avatar
yeah I use this now too 🤔
3:14 PM
with false as argument for the bEvenIfPendingKill (edited)
Avatar
Are weak ptrs thread safe already though
Avatar
AShooterCharacter *__fastcall AShooterPlayerController::GetPlayerCharacter(AShooterPlayerController *this) { AShooterCharacter *result; // rax FUObjectItem *v2; // [rsp+20h] [rbp-68h] TWeakObjectPtr<AShooterCharacter,FWeakObjectPtr,FIndexToObject> *v3; // [rsp+48h] [rbp-40h] UObjectBase *v4; // [rsp+50h] [rbp-38h] UObjectBase *v5; // [rsp+60h] [rbp-28h] v3 = &this->LastControlledPlayerCharacter; v4 = 0i64; if ( FWeakObjectPtr::IsValid(&this->LastControlledPlayerCharacter, 1, 0) ) { if ( v3->ObjectIndex >= GUObjectArray.ObjObjects.NumElements ) v2 = 0i64; else v2 = &GUObjectArray.ObjObjects.Objects[v3->ObjectIndex / 0x10000][v3->ObjectIndex % 0x10000]; if ( v2 && v2->Object && (v2->Object->ObjectFlags & 0x4000) != 0 ) v2 = 0i64; if ( v2 ) v5 = v2->Object; else v5 = 0i64; v4 = v5; } if ( !v4 || ((__int64)v4[55].vfptr & 0x20) != 0 ) result = 0i64; else result = (AShooterCharacter *)v4; return result; }
OOF 1
Avatar
No I mean the get and set on wptr
3:15 PM
Does that have an internal state machine (edited)
Avatar
they are inlined so the get is all you see above
Avatar
what are all those shenanigans they doing with GUObjectArray xD
Avatar
The Get() method from weak ptr
3:16 PM
It is inlined
Avatar
ah ok
Avatar
Are they pinning it?
Avatar
Not sure actually
Avatar
but if they're just doing LastControlledPlayerCharacterField().Get(false) inside this function (edited)
3:19 PM
it seems weird that replacing GetPlayerCharacter() with it fixes it (edited)
Avatar
Updated this to support x32 / other calling conventions @Pelayori (edited)
3:20 PM
Various classes/headers I've written that I find useful. - useful-cpp/hookableFunction.h at main · SubstituteR/useful-cpp
Avatar
That's neat 😋
Avatar
Avatar
OSubMarin
it seems weird that replacing GetPlayerCharacter() with it fixes it (edited)
It is odd indeed. But I could get it to crash using the get function around 95% of times I forced the crash, no crashes with accessing the field directly
Avatar
Alright then ^^
Avatar
I've used GetPlayerCharacter a lot until I realised it crashes on said circumnstances
Avatar
we're missing something but I don't care that much, important thing is just to access the field directly when there's a risk of a call during connection/disconnection
3:24 PM
thanks for the tip
🤟 1
Avatar
It's ark, I am kinda used to this 😂
pLol 1
Avatar
Wouldn't it be easier to add fn hook to the API for backward compatibility? AShooterCharacter* Hook_AShooterPlayerController_GetPlayerCharacter(AShooterPlayerController* _this) { if (_this != nullptr) { return _this->LastControlledPlayerCharacterField().Get(false); } return nullptr; }
Avatar
I mean, most times -> OK. Just gotta be cautious if running calls to that function in short intervals where players might login/logout
11:33 PM
It isn't "broken" as per say
Avatar
Could combine it with checking the object flags on the returned value to make sure it’s not pending destroy or unreachable (or use kismetsystemlibrary->is valid on it which does same thing I believe (edited)
Avatar
Is there a .NET wrapper for the API?
Avatar
Thanks @Lethal
Avatar
does anyone know why IDA Pro (v5.5) is truncating all the names of things? even the instructions are unreadable due to truncation (see the Rename window properly displays function name) looks like some sort of render issue potentially with font size calculation
5:59 PM
changed font and it made it better, so yeah font rendering issue
Avatar
Does someone know an entry point for controlling what dinos are allowed to enter boss arena? (edited)
10:58 PM
Not having much chance with IDA atm. (edited)
Avatar
There's a lot related to teleports. AGameState::TeleportTo(AController *this, FVector *DestLocation, FRotator *DestRotation, bool bIsATest, bool bNoCheck); AShooterGameState::PrepareActorForMassTeleport(AShooterGameState *this, AActor *PrepareActor, FMassTeleportData *WithMassTeleportData); AMissionType::GetTeleportedCharactersIndex(AMissionType *this, APrimalCharacter *Character); Is a boss fight considered to be a mission? 🤔 (edited)
Avatar
It is the blueprint of the arena controller IIRC.
11:34 PM
You will not find it in c++
Avatar
Thank you Lethal 👍 Gonna open the dev kit later on.
Avatar
Any thoughts on how i should get Dino and Item names from blueprint path?
Avatar
Avatar
Kal
Any thoughts on how i should get Dino and Item names from blueprint path?
std::string DinoName = ""; if (UObject* Obj = GetDefaultObjectOfClass(DinoBp.c_str()); Obj) { APrimalDinoCharacter* Dino = static_cast<APrimalDinoCharacter*>(Obj); if (Dino) DinoName = Dino->DescriptiveNameField().ToString(); }
12:11 AM
dino name
12:12 AM
UObject* GetDefaultObjectOfClass(FString BP) { UObject* Obj = nullptr; UClass* aClass = UVictoryCore::BPLoadClass(&BP); if (aClass && aClass->GetDefaultObject(true)) Obj = aClass->GetDefaultObject(true); return Obj; }
12:12 AM
std::string ItemName = ""; if (UObject* Obj = GetDefaultObjectOfClass(ItemBp.c_str()); Obj) { UPrimalItem* Item = static_cast<UPrimalItem*>(Obj); if (Item) ItemName = Item->DescriptiveNameBaseField().ToString(); }
12:12 AM
^^ item name
Avatar
How are you guys setting NoAllyLook, Passive, NoFollow on dinos? the methods ive tried dont seem to work
Avatar
jraServerAPI 7/13/2022 2:24 AM
did you try? player_controller->GetPlayerCharacter()->ServerDinoOrder(dino, EDinoTamedOrder::StopFollowing, nullptr); (edited)
Avatar
perfect, i think thats what i was needing
Avatar
dc.verify
Avatar
hello, on ARK DEV KIT i want create a buttom to get a item to the player inventory who can help me ? i have creat the menu and the buttom i juste want to click and get item (for exemple pickaxe) to the player inventory
Avatar
Avatar
warneur
hello, on ARK DEV KIT i want create a buttom to get a item to the player inventory who can help me ? i have creat the menu and the buttom i juste want to click and get item (for exemple pickaxe) to the player inventory
You probably want this discord https://discord.arkmodding.net/
Avatar
template<typename ...Ts> static auto FindProperties(UObject* object, Ts... properties) { auto apply = [&object](const char* property) { return object->FindProperty(FName(property, EFindName::FNAME_Find)); }; return std::make_tuple(apply(properties)...); }
2:57 AM
if you need 1+n properties from the same uclass (edited)
2:57 AM
example (with caching)
2:57 AM
static auto [NumAscensions, NumAscensionsAb, NumAscensionsExt, NumAscensionsGenesis, NumAscensionsGen2] = FindProperties(CDO, "NumAscensions", "NumAscensionsAb", "NumAscensionsExt", "NumAscensionsGenesis", "NumAscensionsGen2");
👍 1
Avatar
There is a client side UI element for server sessions when transferring between maps. It looks like all of the code for it lives in c++ does anyone know if a mod can trigger c++ code? The flow would be something like plugin calls a server side mod function. Server side mod triggers an client mod action on a specific client to find a reference to UUI_ListSessions for the owning client then trigger UUI_ListSessions::RefreshSlotButtons(this); to refresh the UI buttons.
Avatar
UUI_ListSessions is not exposed to blueprint I believe so there ends the chances.
Avatar
"ListSession" widget has a graph which makes a call I believe. Waiting for the kit to open back up again.
4:03 AM
UUI_ListSessions is the parent to "ListSession" also (edited)
Avatar
Ah, anyways mods can only call C++ functions that have been explicitly exposed with UFUNCTION(BlueprintCallable) UE4 header tool macro
Avatar
still loading... lol
4:05 AM
The other option would be to just force close any ui widgets.
4:05 AM
Also not sure how to accomplish this yet as a backup method.
4:06 AM
4:10 AM
I can copy this to my own mod just not sure how to get the reference for the owning client.
Avatar
You want to obtain a reference to the session list UI?
Avatar
I just want to tell the client to run this Refresh node when I trigger a call from a plugin to a mod
4:14 AM
Maybe it doesn't need an actual reference besides "self" since there is only one on the owning client?
Avatar
If you are not calling that function inside the ListSessions graph, you still need a reference.
4:15 AM
Client side you can do GetViewportClient -> GetUISceneFromClass -> Cast to ListSessions -> call
4:16 AM
GetUISceneFromClass there's 2, one with a single reference, and another one with an array. Both should work in this case
4:16 AM
It was something similar, or GetPrimalUISceneFromClass... around those lines
4:21 AM
I can probably just tell it to be hidden at this point then
Avatar
Yep, pretty much
Exported 128 message(s)
Timezone: UTC+1