RejectModders
RejectModders
CC#
Created by RejectModders on 6/13/2024 in #help
Needing help on why it always does 60 instead of 120.
alr
18 replies
CC#
Created by RejectModders on 6/13/2024 in #help
Needing help on why it always does 60 instead of 120.
Idk if its possible to help me since its related to plugins/modding/apis but im giving it a shot here lol
18 replies
CC#
Created by RejectModders on 6/13/2024 in #help
Needing help on why it always does 60 instead of 120.
line 91 - 121
18 replies
CC#
Created by RejectModders on 6/13/2024 in #help
Needing help on why it always does 60 instead of 120.
18 replies
CC#
Created by RejectModders on 6/13/2024 in #help
Needing help on why it always does 60 instead of 120.
This part is supposed to do a check to see if you have the permission sp.donator but its doing something wrong and always returns 60 instead of 120 even tho I have the permission sp.donator
18 replies
CC#
Created by RejectModders on 6/13/2024 in #help
Needing help on why it always does 60 instead of 120.
c#

private async Task OnPlayerSpawned(IServiceProvider serviceProvider, object? sender, UnturnedPlayerSpawnedEvent @event)
{
var user = await _userManager.FindUserAsync(KnownActorTypes.Player, @event.Player.SteamId.ToString(), UserSearchMode.FindById);
if (user == null)
{
Logger.LogWarning($"Could not find user for player {@event.Player.SteamId}");
return;
}

var hasDonatorPermission = await _permissionChecker.CheckPermissionAsync(user, "InvulnerablePlayers:sp.donator");
var invulnerabilityPeriod = hasDonatorPermission == PermissionGrantResult.Grant ? TimeSpan.FromSeconds(120) : TimeSpan.FromSeconds(60);

_invulnerablePlayers[@event.Player.SteamPlayer] = (DateTime.UtcNow, invulnerabilityPeriod);

int invulnerabilitySeconds = (int)invulnerabilityPeriod.TotalSeconds;
ChatManager.serverSendMessage($"You have {invulnerabilitySeconds} seconds of invulnerability from PvP.", Color.green, null, @event.Player.SteamPlayer, EChatMode.SAY, null, true);
}
c#

private async Task OnPlayerSpawned(IServiceProvider serviceProvider, object? sender, UnturnedPlayerSpawnedEvent @event)
{
var user = await _userManager.FindUserAsync(KnownActorTypes.Player, @event.Player.SteamId.ToString(), UserSearchMode.FindById);
if (user == null)
{
Logger.LogWarning($"Could not find user for player {@event.Player.SteamId}");
return;
}

var hasDonatorPermission = await _permissionChecker.CheckPermissionAsync(user, "InvulnerablePlayers:sp.donator");
var invulnerabilityPeriod = hasDonatorPermission == PermissionGrantResult.Grant ? TimeSpan.FromSeconds(120) : TimeSpan.FromSeconds(60);

_invulnerablePlayers[@event.Player.SteamPlayer] = (DateTime.UtcNow, invulnerabilityPeriod);

int invulnerabilitySeconds = (int)invulnerabilityPeriod.TotalSeconds;
ChatManager.serverSendMessage($"You have {invulnerabilitySeconds} seconds of invulnerability from PvP.", Color.green, null, @event.Player.SteamPlayer, EChatMode.SAY, null, true);
}
18 replies
CC#
Created by RejectModders on 6/13/2024 in #help
Needing help on why it always does 60 instead of 120.
So I thought my best bet was to come here n see if anyone could help tbh.
18 replies
CC#
Created by RejectModders on 6/13/2024 in #help
Needing help on why it always does 60 instead of 120.
Its just a plugin for Unturned, yes I should be asking in their support server, but their support server is not really fond on "new" c# users.
18 replies
CC#
Created by RejectModders on 6/13/2024 in #help
Needing help on why it always does 60 instead of 120.
Yes im new to c# but I am just confused on why it won't work. If anyone can help, that will be great.
18 replies