Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The function for changing weather, clouds, and time checks for permissions #430

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions vMenuServer/MainServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,13 @@ private void RefreshWeather()
/// <param name="blackoutNew"></param>
/// <param name="dynamicWeatherNew"></param>
[EventHandler("vMenu:UpdateServerWeather")]
internal void UpdateWeather(string newWeather, bool blackoutNew, bool dynamicWeatherNew, bool enableSnow)
internal void UpdateWeather([FromSource] Player source, string newWeather, bool blackoutNew, bool dynamicWeatherNew, bool enableSnow)
{
if (source != null && !IsPlayerAceAllowed(source.Handle, "vMenu.WeatherOptions.Menu") && !IsPlayerAceAllowed(source.Handle, "vMenu.WeatherOptions.All"))
{
BanManager.BanCheater(source);
return;
}

// Automatically enable snow effects whenever one of the snow weather types is selected.
if (newWeather is "XMAS" or "SNOWLIGHT" or "SNOW" or "BLIZZARD")
Expand All @@ -684,8 +689,14 @@ internal void UpdateWeather(string newWeather, bool blackoutNew, bool dynamicWea
/// </summary>
/// <param name="removeClouds"></param>
[EventHandler("vMenu:UpdateServerWeatherCloudsType")]
internal void UpdateWeatherCloudsType(bool removeClouds)
internal void UpdateWeatherCloudsType([FromSource] Player source, bool removeClouds)
{
if (source != null && !IsPlayerAceAllowed(source.Handle, "vMenu.WeatherOptions.RemoveClouds") && !IsPlayerAceAllowed(source.Handle, "vMenu.WeatherOptions.RandomizeClouds"))
{
BanManager.BanCheater(source);
return;
}

if (removeClouds)
{
TriggerClientEvent("vMenu:SetClouds", 0f, "removed");
Expand All @@ -705,8 +716,14 @@ internal void UpdateWeatherCloudsType(bool removeClouds)
/// <param name="newMinutes"></param>
/// <param name="freezeTimeNew"></param>
[EventHandler("vMenu:UpdateServerTime")]
internal void UpdateTime(int newHours, int newMinutes, bool freezeTimeNew)
internal void UpdateTime([FromSource] Player source, int newHours, int newMinutes, bool freezeTimeNew)
{
if (source != null && !IsPlayerAceAllowed(source.Handle, "vMenu.TimeOptions.Menu") && !IsPlayerAceAllowed(source.Handle, "vMenu.TimeOptions.All"))
{
BanManager.BanCheater(source);
return;
}

CurrentHours = newHours;
CurrentMinutes = newMinutes;
FreezeTime = freezeTimeNew;
Expand Down