This is a mobile optimized page that loads fast, if you want to load the real page, click this text.

How to mange green zone that the specific fraction can fight in there desired safe zone

dagar6424

Новый участник
25 Июн 2021
27
2
60
I have tried a function but that not working enough. Can someone modify that
private bool CanPlayerFightInSafeZone(ExtPlayer player, int index)
{
var sessionData = player.GetSessionData();
if (sessionData == null)
return false;


if (sessionData.Fraction == null)
return false;

var fracId = player.GetFractionId();


if (!sessionData.WorkData.OnDuty && Manager.FractionTypes.TryGetValue(fracId, out var fractionType))
{
switch ((ZoneName)index)
{
case ZoneName.LCN:
return fractionType == FractionsType.ARMY;
case ZoneName.lspd:
return fractionType == FractionsType.POLICE;
case ZoneName.EMS:
return fractionType == FractionsType.EMS;
default:
return true;
}
}

return false;
}
 

Jerry (ChatGPT)

AI-powered language model
VIP
helper
17 Окт 2023
2,414
238
100
It looks like your function is almost correct. There are a couple of things that can be improved:

1. Use sessionData.Fraction instead of sessionData.FractionId for checking the player's fraction.
2. The CanPlayerFightInSafeZone function seems to be deciding if a player can fight in a specific zone based on their faction. Make sure that Manager.FractionTypes contains the appropriate mappings for all the zone names.
3. You may want to make sure that fracId is not null before using it in the Manager.FractionTypes.TryGetValue(fracId, out var fractionType) line.

Other than that, the function should work if the necessary data (like Manager.FractionTypes) is set up properly.
 

dagar6424

Новый участник
25 Июн 2021
27
2
60
Can u give modified code
 

dagar6424

Новый участник
25 Июн 2021
27
2
60
private bool CanPlayerFightInSafeZone(ExtPlayer player, int index)
{
var sessionData = player.GetSessionData();
if (sessionData == null)
return false;
var playerFraction = sessionData.Fraction;
if (playerFraction == null)
return false;
var fractionType = playerFraction.Type;
if (fractionType == FractionsType.NONE)
return false;
switch ((ZoneName)index)
{
case ZoneName.LCN:
return fractionType == FractionsType.ARMY
case ZoneName.lspd:
return fractionType == FractionsType.POLICE;
case ZoneName.EMS:
return fractionType == FractionsType.EMS;
default:
return true;
}
}