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!

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.
 
_this->IsA(AShooterCharacter::GetPrivateStaticClass())
 
Tebex
Tempest Dedicated Servers
Rogue Vikings Discord Server - Rogue Vikings Gaming Servers - Minecraft Prison Servers - Minecraft Creative Servers
Monetize your ARK server
Back
Top