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

Weapon StartFire StopFire hook problem

UPD.
the problem is self-solved. allowfire() works but only on client side... because of it log("im in allowfire()"); and broadcast message not displayed/worked on server log window. to make it work need to use replication. so I maked
replication
{
reliable if (ROLE < ROLE_Authority)
serverLog, serverMessageToPlayers
}
so if on client machine AllowFire() calls serverMessageToPlayers, this function work not only on client, but on server too.

spended to solve problem: 2 days.
-------------------
Intro:
Me use Welder, that can weld another players armor.

Situation:
In battle all players are always strafing and running so its very hard to weld other players. Using hotkeys with "say Please stop running! Im welding your armor!" is not what i want.

Idea:
When Player A want to weld armor of Player B and distanse is too far for starting weld-process, player B gets message "PlayerA trying to weld your armor!".. So playerB understand that better to stop and wait for weld process.

Realisation:
In welder->tick() I already maked routine that finds KFHumanPawn(PlayerB) so I can easily send messages to PlayerB
I want that PlayerB get message that PlayerA want to weld his armor only if
1.PlayerA current weapon is Welder
2.PlayerA pressed fire button

THE PROBLEM:
is in p.2 - I cant find any function that start to work when Fire button pressed. WelderFire->AllowFire() start to work only if distance close enought for welding, it dosent work when PlayerA far from PlayerB.

I need to find and redefine some native-native function wich start to work first when fire button pressed.

weapon->StartFire() - not working.. it start to work like WelderFire->AllowFire() -- only if distance close enought.

need some native function thar start to work before any distance checks.
 
Last edited:
ok I localized the problem.

WeldFire have AllowFire() function. Experimentally i found that this function run only on clientside. Look code and comments.

Code:
simulated function bool AllowFire()
{
	local KFDoorMover WeldTarget;
	WeldTarget = GetDoor();

	// Can't use welder, if no door.
	if ( WeldTarget == none && !CanFindHealee())
	{
		if ( KFPlayerController(Instigator.Controller) != none )
		{
			KFPlayerController(Instigator.Controller).CheckForHint(54);

			if ( FailTime + 0.5 < Level.TimeSeconds )
			{
				PlayerController(Instigator.Controller).ClientMessage(NoWeldTargetMessage, 'CriticalEvent');
				FailTime = Level.TimeSeconds;
			}

		}
		return false;
	}
	if(WeldTarget != none && WeldTarget.bDisallowWeld)
	{
		if( PlayerController(Instigator.controller)!=None )
			PlayerController(Instigator.controller).ClientMessage(CantWeldTargetMessage, 'CriticalEvent');   <<---------------- showing on client that CANT WELD CAUSE NEED TO BE NEAR DOOR
log("SERVER DEBUG MESSAGE");  <<-------- this debug message not showing on dedicated server console

	    return false;
    }

    return Weapon.AmmoAmount(ThisModeNum) >= AmmoPerFire ;

}

so if log() message dont show on server console I think that whole function AllowFire() runs only on client.... How to make it run on server too?
 
Upvote 0