How to get players weapon?

Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Public Service Announcement

    Hey Guest, I’ve got some exciting news to share! 🎉

    Starting this December, I’ll be moving the entire GameServersHub website away from WordPress and rebuilding it in Next.js! This upgrade will bring incredibly faster speeds, smoother performance, and a modern user experience that sets the stage for everything coming next.

    In 2026, GameServersHub will be entering a new era. I’ll be revamping the entire platform from the ground up and launching a brand-new, fully modernized marketplace. It’ll feature a cleaner design, improved functionality, and better tools for both creators and server owners.

    On top of that, development has already started on the GameServerListing project at https://gsl-six.vercel.app/, which is expected to launch in early Q1 2026. This new system will make discovering and managing servers easier than ever before.


    👉 Stay in the loop!
    Join our Discord for behind-the-scenes updates, early previews, and community discussions.

    » Click here to join our Discord! «

    ~ MrOwlSky

Codeboy

Well-known member
Joined
May 25, 2018
Messages
29
hi~ How do I get for player's weapon? I need to block specific gun.
 
Michidu, Can you help me have a look? I want to make long tube rifle dozen players without damage, Here is my code snippet, But it dozen dino also no harm, this is not what I want results.:confused:


C++:
DECLARE_HOOK(AShooterCharacter_TakeDamage, float, AShooterCharacter *, float, FDamageEvent *, AController *, AActor *);
float Hook_AShooterCharacter_TakeDamage(AShooterCharacter *_this, float Damage, FDamageEvent * DamageEvent, AController* EventInstigator, AActor * DamageCauser)
{
    if (_this && _this->PlayerStateField() && EventInstigator && !EventInstigator->IsLocalController() && EventInstigator->IsA(AShooterPlayerController::StaticClass()))
    {
        AShooterPlayerController* InstigatorShooterController = static_cast<AShooterPlayerController*>(EventInstigator);

        if (InstigatorShooterController && InstigatorShooterController->PlayerStateField() && InstigatorShooterController->GetPlayerCharacter())
        {
            if (InstigatorShooterController->GetPlayerCharacter()->CurrentWeaponField() && InstigatorShooterController->GetPlayerCharacter()->CurrentWeaponField()->AssociatedPrimalItemField())
            {
                UPrimalItem* WeaponItem = InstigatorShooterController->GetPlayerCharacter()->CurrentWeaponField()->AssociatedPrimalItemField();

                const FString WeaponItemBP = ArkApi::IApiUtils::GetItemBlueprint(WeaponItem);

                if (WeaponItemBP.EndsWith("PrimalItem_WeaponOneShotRifle'"))
                {//长管步枪;
                    return AShooterCharacter_TakeDamage_original(_this, 1.0f, DamageEvent, EventInstigator, DamageCauser);
                }
                else if (WeaponItemBP.EndsWith("PrimalItem_WeaponMachinedSniper'"))
                {//制式狙击步枪;
                    return AShooterCharacter_TakeDamage_original(_this, 1.0f, DamageEvent, EventInstigator, DamageCauser);
                }
            }
        }
    }

    return AShooterCharacter_TakeDamage_original(_this, Damage, DamageEvent, EventInstigator, DamageCauser);
}
 
Check if _this is AShooterPlayerCharacter.
 
try AShooterCharacter::GetPrivateStaticClass() or AShooterCharacter::StaticClass()

on another note.
if you want to intercept both character and dino damage hook APrimalCharacter::TakeDamage
if you want to intercept dino damage hook APrimalDinoCharacter::TakeDamage
 
Last edited:
try AShooterCharacter::GetPrivateStaticClass() or AShooterCharacter::StaticClass()

on another note.
if you want to intercept both character and dino damage hook APrimalCharacter::TakeDamage
if you want to intercept dino damage hook APrimalDinoCharacter::TakeDamage

thank you, I know, I just need to intercept the player's damage, dino and don't want to damage.
But, I didn't find AShooterPlayerCharacter::TakeDamage, so use APrimalCharacter::TakeDamage.
Now I don't know how to distinguish between _this is a player, rather than a dino.:confused:
in ArkApi all .h file, not found AShooterPlayerCharacter related information.
 
Back
Top