[Help] Pickup Override

  • 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/

matttthias

FNG / Fresh Meat
Mar 5, 2010
174
9
0
Austria
www.team-gmk.com
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;
}
 

Marco

Active member
May 23, 2009
644
227
43
Finland
You have to do the checks on start of game since client connects and build up an array of classes that you can or can't pickup, there is no other reasonable way.