#Not fully clear what u want to do.
1 messages · Page 1 of 1 (latest)
Basically this is being triggered by a FactionPlayerTriggerEntity. It's doing some math stuff with a scoring system, and the trigger also pops up a Hint with directions to the next faction trigger. I want this hint to only be displayed on the HUD of players in the faction of the player that triggers the faction trigger.
@fathom field
ah ok
Is there a better way of doing this? I'm not familiar with Rpl and Rpc, but I know I need to learn it.
RPC send message to all broadcast, you need filter on proxy side
show only on specified players
playerID more than enough for that
not need RplId
Is filtering happening in the player controller entity? Is that something I'll have to mod the DefaultPlayerControllerMP entity?
small example for send message from server to proxy
//Get Local Controlled Entity - SCR_ChimeraCharacter
IEntity player = SCR_PlayerController.GetLocalControlledEntity();
//Get the players FactionAffiliationComponent
FactionAffiliationComponent fa = FactionAffiliationComponent.Cast(player.FindComponent(FactionAffiliationComponent));
//If it has a FactionAffiliationComponent
if(fa)
{
//Check to see if the players faction name is the same as index 0 from the FactionManager
if(fa.GetAffiliatedFaction().GetFactionName() == GetGame().GetFactionManager().GetFactionByIndex(0).GetFactionName())
SCR_HintManagerComponent.GetInstance().ShowCustomHint("Only show for faction index 0", "Faction Sepcific", 10);
//Send Hint if they are the same
}
//If it doesn't have a FactionAffiliationComponent do nothing..
Wouldn't this work?
He uses faction trigger, so he can get all faction players inside trigger. Just need get playerIds and send message to all.
Or he could just see if the local entity is in said faction
I'm also not sure how SCR_HIntManagerComponent works
I just threw an example together
Rpc() call maybe not working in workbench, you need test on dedicated server.
in my tests Rpc() call just ignored on WB player-hosted servers.
And my position selection for code, not accidental.
GameMode easy to earn from anywhere, run on server and its have RplComponent. Its good place for server->proxy messages. But you can place another place too.
I tried this but haven't been able to try it on my dedicated server yet. Tom, I'm guessing your code has the hint print regularly, and if it's on a dedicated server than through Rpc?
I tried this in work bench and as expected it ran the non-Rpc method. Trying to fully understand how the process works - Does the Rpc method call on each proxy machine, so that get local variables are specific to the proxies and not the player who triggered the trigger?
void ShowCheckpointInfo(int checkpointIndex, int factionIndex)
{
string cpHintTitle = GetHintTitle(checkpointIndex, factionIndex);
string cpHintDesc = GetHintDesc(checkpointIndex, factionIndex);
if (RplSession.Mode() == RplMode.Dedicated)
{
Rpc(RpcDo_RecieveHint, factionIndex, cpHintTitle, cpHintDesc);
}
else
{
RpcDo_RecieveHint(factionIndex, cpHintTitle, cpHintDesc);
}
}
[RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
void RpcDo_RecieveHint(int factionIndex, string cpHintTitle, string cpHintDesc)
{
Faction localFaction = SCR_FactionManager.SGetLocalPlayerFaction();
FactionManager facMan = GetGame().GetFactionManager();
Faction fValidate = facMan.GetFactionByIndex(factionIndex);
if (localFaction != fValidate)
{
Print("This Rpc call is ignored!", LogLevel.WARNING);
return;
}
SCR_HintManagerComponent.GetInstance().ShowCustomHint(cpHintDesc, cpHintTitle, m_iHintTextDuration);
}