Tripwire Interactive Forums

  • Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/
it looks like the function ServerWeaponLocked() is too slow because the checking is already finished before this function is done with its work...
any solution for this would be awesome

Code:
class NewGameRules extends GameRules;

function PostBeginPlay()
{
    if( Level.Game.GameRulesModifiers==None )
        Level.Game.GameRulesModifiers = Self;
    else Level.Game.GameRulesModifiers.AddGameRules(Self);
}

function AddGameRules(GameRules GR)
{
    if ( GR!=Self )
        Super.AddGameRules(GR);
}

function bool OverridePickupQuery(Pawn Other, Pickup item, out byte bAllowPickup)
{
    local bool bResult;

    if ( NextGameRules != None )
        bResult = NextGameRules.OverridePickupQuery(Other, item, bAllowPickup);

    if ( !bResult || bAllowPickup == 1 )
    {
        bAllowPickup = 0;
        NewPlayerController(Other.Controller).UnlockWeapon();
        bResult = NewPlayerController(Other.Controller).bWeaponLocked;
    }
    return bResult;
}
Code:
class NewPlayerController extends KFPlayerController;

var bool bWeaponLocked;

replication
{
    reliable if( Role==ROLE_Authority && bNetOwner)
        IsPickupable; //cut out unimportant stuff but cant change the replication of this for some reason
        
    reliable if ( Role < ROLE_Authority )
        ServerWeaponLocked;
}

simulated function IsPickupable()
{
    if(Something Happens)
        bWeaponLocked = false;
    else
        bWeaponLocked = false;
    ServerWeaponLocked(bWeaponLocked);
}

function ServerWeaponLocked(bool bLocked)
{
    bWeaponLocked = bLocked;
}