[Code snippet] Weapons blacklist

Hi i just finished up some problems, i thought i would make i new topic so others can find it.
Here it is, the beginning of Security for script enabled servers.
Hope it evolves from here, i will be posting more, because i really hate cheaters. especially those with aim bots.
For some reason i cant post in Release so that is why i am posting it here.
This will check if the user is using weapons you want them to use.

internal status.

public static bool weaponFound;

Function.

public async void allowedWeaponsCheck()
{
int CombatMG = GetHashKey("weapon_CombatMG");
int CarbineRifle = GetHashKey("weapon_CarbineRifle");
int HeavySniper = GetHashKey("weapon_heavysniper");
int Pistol = GetHashKey("weapon_pistol");
int weaponPlayer = GetSelectedPedWeapon(GetPlayerPed(PlayerId()));
string weaponUser = weaponPlayer.ToString().Replace("-", "");
int ignoreWeapon = 0;
int ignoreWeapon1 = 1569615261;
int ignoreWeapon2 = 453432689;
int[] weaponList1 = { CombatMG, CarbineRifle, HeavySniper, Pistol, ignoreWeapon, ignoreWeapon1, ignoreWeapon2 };

        foreach (int x in weaponList1)
        {
            if (weaponPlayer == x)
            {
                weaponFound = true;
               
            }  
        }   
        await Delay(100);
    }

async task.

weaponFound = false;
allowedWeaponsCheck();
if (weaponFound == false && GetSelectedPedWeapon(GetPlayerPed(PlayerId())) != 0 && GetSelectedPedWeapon(GetPlayerPed(PlayerId())) != 1569615261 && GetSelectedPedWeapon(GetPlayerPed(PlayerId())) != 453432689)
{
weaponFound = true;
Screen.ShowNotification("Weapon not allowed " + GetSelectedPedWeapon(GetPlayerPed(PlayerId())).ToString().Replace("-", ""));
RemoveWeaponFromPed(GetPlayerPed(PlayerId()), (uint)GetSelectedPedWeapon(GetPlayerPed(PlayerId())));
 }

Would you like this moved to releases?

1 Like

i think if the title is right it really does not matter, as long as other ppl can find it and learn from it.

33 posts were merged into an existing topic: C# int to string unable to compair data

So is this to stop players spawn guns from menus?

Yes weapons you dont allow…

Moved back to #development:releases. Even though it’s not a “final script” it is a code snippet that is being released. It’s not a request for “help” on how to achieve something, so it belongs in the #development:releases category.

1 Like

Temporarily closed, for discussion about best practices, go to the “discussion” topic: C# int to string unable to compair data

This topic was automatically opened after 2 hours.

do you have the file to release so we can download it? :wink:

You are able to copy paste this into software like VSC and export it your self, its a code snippet not a final release.