Skip to content

Commit

Permalink
Add permission for addon peds.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomGrobbe committed Feb 11, 2019
1 parent 887a9c3 commit ccd83c8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
55 changes: 28 additions & 27 deletions vMenu/menus/PlayerAppearance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,31 +112,32 @@ private void CreateMenu()
{
if (AddonPeds.Count > 0)
{
addonPedsBtn.Label = "→→→";
foreach (KeyValuePair<string, uint> ped in AddonPeds)
if (IsAllowed(Permission.PAAddonPeds))
{
var button = new MenuItem(ped.Key, "Click to use this ped.");
addonPeds.AddMenuItem(button);
if (!IsModelAPed(ped.Value) || !IsModelInCdimage(ped.Value))
addonPedsBtn.Label = "→→→";

foreach (KeyValuePair<string, uint> ped in AddonPeds)
{
button.Enabled = false;
button.LeftIcon = MenuItem.Icon.LOCK;
button.Description = "This ped is not available on this server. Are you sure the model is valid?";
var button = new MenuItem(ped.Key, "Click to use this ped.");
addonPeds.AddMenuItem(button);
if (!IsModelAPed(ped.Value) || !IsModelInCdimage(ped.Value))
{
button.Enabled = false;
button.LeftIcon = MenuItem.Icon.LOCK;
button.Description = "This ped is not available on this server. Ask the server owner to fix this streamed model and verify the model spawn name.";
}
}
}
addonPeds.OnItemSelect += async (sender, item, index) =>
{
if (item.Enabled)

addonPeds.OnItemSelect += async (sender, item, index) =>
{
await SetPlayerSkin(AddonPeds.ElementAt(index).Value, new PedInfo() { version = -1 });
}
else
{
Notify.Error("This ped is not available. Please ask the server owner to verify this addon ped.");
}
};
MenuController.BindMenuItem(menu, addonPeds, addonPedsBtn);
};
MenuController.BindMenuItem(menu, addonPeds, addonPedsBtn);
}
else
{
menu.RemoveMenuItem(addonPedsBtn);
}
}
else
{
Expand All @@ -153,7 +154,6 @@ private void CreateMenu()
}

addonPeds.RefreshIndex();
//addonPeds.UpdateScaleform();

// Add the spawn by name button after the addon peds menu item.
menu.AddMenuItem(spawnByName);
Expand Down Expand Up @@ -183,12 +183,12 @@ private void CreateMenu()
}
MenuListItem pedl = new MenuListItem("Peds #" + (i + 1).ToString(), pedList, 0);

menu.AddMenuItem(pedl);
if (!IsAllowed(Permission.PASpawnNew))
if (IsAllowed(Permission.PASpawnNew))
{
pedl.Enabled = false;
pedl.LeftIcon = MenuItem.Icon.LOCK;
pedl.Description = "This option has been disabled by the server owner.";
menu.AddMenuItem(pedl);
//pedl.Enabled = false;
//pedl.LeftIcon = MenuItem.Icon.LOCK;
//pedl.Description = "This option has been disabled by the server owner.";
}
}
}
Expand All @@ -208,7 +208,8 @@ private void CreateMenu()
}
else if (IsAllowed(Permission.PASpawnNew))
{
int i = ((itemIndex - 8) * 50) + listIndex;
int listsCount = (modelNames.Count / 50) + 1;
int i = ((itemIndex - (sender.Size - listsCount)) * 50) + listIndex;
string modelName = modelNames[i];
await SetPlayerSkin(modelName, new PedInfo() { version = -1 });
}
Expand Down
1 change: 1 addition & 0 deletions vMenuServer/config/permissions.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ add_ace builtin.everyone "vMenu.PlayerAppearance.All" allow
#add_ace builtin.everyone "vMenu.PlayerAppearance.Customize" allow
#add_ace builtin.everyone "vMenu.PlayerAppearance.SpawnSaved" allow
#add_ace builtin.everyone "vMenu.PlayerAppearance.SpawnNew" allow
#add_ace builtin.everyone "vMenu.PlayerAppearance.AddonPeds" allow

####################################
# TIME OPTIONS MENU #
Expand Down
1 change: 1 addition & 0 deletions vMenuShared/PermissionsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public enum Permission
PACustomize,
PASpawnSaved,
PASpawnNew,
PAAddonPeds,

// Time Options
TOMenu,
Expand Down

0 comments on commit ccd83c8

Please sign in to comment.