Skip to content

Commit

Permalink
Moved more weapon permissions over from pr #74
Browse files Browse the repository at this point in the history
  • Loading branch information
TomGrobbe committed Apr 16, 2018
1 parent 0246cf9 commit cbe35a2
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 16 deletions.
98 changes: 84 additions & 14 deletions vMenu/PermissionsManager.cs
Expand Up @@ -134,6 +134,90 @@ public enum Permission
WPSpawn,
WPSetAllAmmo,

//Weapons Permissions
WPSniperRifle,
WPFireExtinguisher,
WPCompactGrenadeLauncher,
WPSnowball,
WPVintagePistol,
WPCombatPDW,
WPHeavySniperMk2,
WPHeavySniper,
WPSweeperShotgun,
WPMicroSMG,
WPWrench,
WPPistol,
WPPumpShotgun,
WPAPPistol,
WPBall,
WPMolotov,
WPSMG,
WPStickyBomb,
WPPetrolCan,
WPStunGun,
WPAssaultRifleMk2,
WPHeavyShotgun,
WPMinigun,
WPGolfClub,
WPFlareGun,
WPFlare,
WPGrenadeLauncherSmoke,
WPHammer,
WPCombatPistol,
WPGusenberg,
WPCompactRifle,
WPHomingLauncher,
WPNightstick,
WPRailgun,
WPSawnOffShotgun,
WPSMGMk2,
WPBullpupRifle,
WPFirework,
WPCombatMG,
WPCarbineRifle,
WPCrowbar,
WPFlashlight,
WPDagger,
WPGrenade,
WPPoolCue,
WPBat,
WPPistol50,
WPKnife,
WPMG,
WPBullpupShotgun,
WPBZGas,
WPUnarmed,
WPGrenadeLauncher,
WPNightVision,
WPMusket,
WPProximityMine,
WPAdvancedRifle,
WPRPG,
WPPipeBomb,
WPMiniSMG,
WPSNSPistol,
WPPistolMk2,
WPAssaultRifle,
WPSpecialCarbine,
WPRevolver,
WPMarksmanRifle,
WPBattleAxe,
WPHeavyPistol,
WPKnuckleDuster,
WPMachinePistol,
WPCombatMGMk2,
WPMarksmanPistol,
WPMachete,
WPSwitchBlade,
WPAssaultShotgun,
WPDoubleBarrelShotgun,
WPAssaultSMG,
WPHatchet,
WPBottle,
WPCarbineRifleMk2,
WPParachute,
WPSmokeGrenade,

// Misc Settings
MSMenu,
MSAll,
Expand All @@ -146,8 +230,6 @@ public enum Permission
MSNightVision,
MSThermalVision,



// Voice Chat
VCMenu,
VCAll,
Expand All @@ -166,18 +248,11 @@ public static void SetPermission(string permissionName, bool allowed)
if (allowed)
{
Permissions.Add(permissionName);

}
//if (allowed)
// MainMenu.Cf.Log("Permission: " + permissionName.ToString() + " is ALLOWED.");
//else
// MainMenu.Cf.Log("Permission: " + permissionName.ToString() + " is DENIED.");
}


public static bool IsAllowed(Permission permission)
{

if (Permissions.Contains("Everything"))
{
MainMenu.Cf.Log("Everything allowed, breaking.");
Expand All @@ -190,17 +265,12 @@ public static bool IsAllowed(Permission permission)
{
allowed = true;
}

if (!allowed)
{
allowed = Permissions.Contains(permission.ToString());
}


return allowed;
}


}
}
}
90 changes: 89 additions & 1 deletion vMenu/ValidWeapon.cs
Expand Up @@ -12,6 +12,7 @@ public struct ValidWeapon
public uint Hash;
public string Name;
public Dictionary<string, uint> Components;
public Permission Perm;
}

public class ValidWeapons
Expand Down Expand Up @@ -52,7 +53,8 @@ public ValidWeapons()
{
Hash = hash,
Name = localizedName,
Components = componentHashes
Components = componentHashes,
Perm = weaponPermissions[realName]
};
_validWeaponsList[num] = vw;
num++;
Expand Down Expand Up @@ -147,6 +149,92 @@ public ValidWeapons()
["SmokeGrenade"] = "Tear Gas",
};

public static Dictionary<string, Permission> weaponPermissions = new Dictionary<string, Permission>()
{
["SniperRifle"] = Permission.WPSniperRifle,
["FireExtinguisher"] = Permission.WPFireExtinguisher,
["CompactGrenadeLauncher"] = Permission.WPCompactGrenadeLauncher,
["Snowball"] = Permission.WPSnowball,
["VintagePistol"] = Permission.WPVintagePistol,
["CombatPDW"] = Permission.WPCombatPDW,
["HeavySniperMk2"] = Permission.WPHeavySniperMk2,
["HeavySniper"] = Permission.WPHeavySniper,
["SweeperShotgun"] = Permission.WPSweeperShotgun,
["MicroSMG"] = Permission.WPMicroSMG,
["Wrench"] = Permission.WPWrench,
["Pistol"] = Permission.WPPistol,
["PumpShotgun"] = Permission.WPPumpShotgun,
["APPistol"] = Permission.WPAPPistol,
["Ball"] = Permission.WPBall,
["Molotov"] = Permission.WPMolotov,
["SMG"] = Permission.WPSMG,
["StickyBomb"] = Permission.WPStickyBomb,
["PetrolCan"] = Permission.WPPetrolCan,
["StunGun"] = Permission.WPStunGun,
["AssaultRifleMk2"] = Permission.WPAssaultRifleMk2,
["HeavyShotgun"] = Permission.WPHeavyShotgun,
["Minigun"] = Permission.WPMinigun,
["GolfClub"] = Permission.WPGolfClub,
["FlareGun"] = Permission.WPFlareGun,
["Flare"] = Permission.WPFlare,
["GrenadeLauncherSmoke"] = Permission.WPGrenadeLauncherSmoke,
["Hammer"] = Permission.WPHammer,
["CombatPistol"] = Permission.WPCombatPistol,
["Gusenberg"] = Permission.WPGusenberg,
["CompactRifle"] = Permission.WPCompactRifle,
["HomingLauncher"] = Permission.WPHomingLauncher,
["Nightstick"] = Permission.WPNightstick,
["Railgun"] = Permission.WPRailgun,
["SawnOffShotgun"] = Permission.WPSawnOffShotgun,
["SMGMk2"] = Permission.WPSMGMk2,
["BullpupRifle"] = Permission.WPBullpupRifle,
["Firework"] = Permission.WPFirework,
["CombatMG"] = Permission.WPCombatMG,
["CarbineRifle"] = Permission.WPCarbineRifle,
["Crowbar"] = Permission.WPCrowbar,
["Flashlight"] = Permission.WPFlashlight,
["Dagger"] = Permission.WPDagger,
["Grenade"] = Permission.WPGrenade,
["PoolCue"] = Permission.WPPoolCue,
["Bat"] = Permission.WPBat,
["Pistol50"] = Permission.WPPistol50,
["Knife"] = Permission.WPKnife,
["MG"] = Permission.WPMG,
["BullpupShotgun"] = Permission.WPBullpupShotgun,
["BZGas"] = Permission.WPBZGas,
["Unarmed"] = Permission.WPUnarmed,
["GrenadeLauncher"] = Permission.WPGrenadeLauncher,
["NightVision"] = Permission.WPNightVision,
["Musket"] = Permission.WPMusket,
["ProximityMine"] = Permission.WPProximityMine,
["AdvancedRifle"] = Permission.WPAdvancedRifle,
["RPG"] = Permission.WPRPG,
["PipeBomb"] = Permission.WPPipeBomb,
["MiniSMG"] = Permission.WPMiniSMG,
["SNSPistol"] = Permission.WPSNSPistol,
["PistolMk2"] = Permission.WPPistolMk2,
["AssaultRifle"] = Permission.WPAssaultRifle,
["SpecialCarbine"] = Permission.WPSpecialCarbine,
["Revolver"] = Permission.WPRevolver,
["MarksmanRifle"] = Permission.WPMarksmanRifle,
["BattleAxe"] = Permission.WPBattleAxe,
["HeavyPistol"] = Permission.WPHeavyPistol,
["KnuckleDuster"] = Permission.WPKnuckleDuster,
["MachinePistol"] = Permission.WPMachinePistol,
["CombatMGMk2"] = Permission.WPCombatMGMk2,
["MarksmanPistol"] = Permission.WPMarksmanPistol,
["Machete"] = Permission.WPMachete,
["SwitchBlade"] = Permission.WPSwitchBlade,
["AssaultShotgun"] = Permission.WPAssaultShotgun,
["DoubleBarrelShotgun"] = Permission.WPDoubleBarrelShotgun,
["AssaultSMG"] = Permission.WPAssaultSMG,
["Hatchet"] = Permission.WPHatchet,
["Bottle"] = Permission.WPBottle,
["CarbineRifleMk2"] = Permission.WPCarbineRifleMk2,
["Parachute"] = Permission.WPParachute,
["SmokeGrenade"] = Permission.WPSmokeGrenade,
};

/// <summary>
/// Key = Weapon Name (NOT localized - string), value = hash (uint).
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion vMenu/menus/WeaponOptions.cs
Expand Up @@ -493,7 +493,7 @@ private void CreateMenu()
foreach (ValidWeapon weapon in vw.WeaponList)
{
uint cat = (uint)GetWeapontypeGroup(weapon.Hash);
if (weapon.Name != null)
if (weapon.Name != null && cf.IsAllowed(weapon.Perm))
{
#region Create menu for this weapon and add buttons
UIMenu weaponMenu = new UIMenu("Weapon Options", weapon.Name, true)
Expand Down

0 comments on commit cbe35a2

Please sign in to comment.