C# int to string unable to compair data

After a long battle with the system i got some results, i have not pin point the exact situation, all i know is this works…

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())));
}

Hmm this is like fighting fire with fire, this is why:

Security concerns:

  • All they have to do is run the GiveWeapons scripts more often than your RemoveWeapons script.
  • It’s still on the client, so they could circumvent the check. I feel like this will be effective for 4-5 servers, but if it becomes widely used, hackers will try to make a bypass for this.
  • weaponFound is static, I assume that would make it quite easy to set it to false every tick.

Code quality:

  • Please store all the blacklisted weapons and ignored weapons into array/list. Right now this is quite heavy on the client, especially if you run it faster as 100ms.
  • Try not to use int for the hashes, it makes the code harder to understand.
  • allowedWeaponsCheck doesn’t need a wait nor async modifier, call it from the BaseScript tick function.

Possible improvements:

  • Replicate the user weapons list to the server, this way the blacklisted weapons should never be mutable by the client.
1 Like

The Code is raw… the coders need to evolve from this, and with I7 or 8 core and a good video card this is peanuts. i am getting 85 to 120 FPS, i dont think any one likes integrated OOP as example. and i learn from the hard way, not what any one is saying, if i was to take every ones advice, i would not be a programmer today. the async is optional, async means, wait untill there is is nothing else running.
I am programming with Chromium my self, so i am known with the concept.
I preferly stay away from server side scripting because that will effect all users.

Yes, that’s why I posted what I posted.

And assuming everyone has an high end PC is pretty bad, I’d say 60% of all users fall behind the specs you gave.

Maybe you should, learning to effectively learn new stuff is essential, especially when you work in a scene that is moving forward at a very rapid pace.

I preferly stay away from server side scripting because that will effect all users.

What? I think you realize how powerful server side script can be. Literally everything on the client is mutable, there is no 100% guarantee that that client is don’t something that stinks. In contrast to server side scripting, where you are 100% sure.

1 Like

Like i said… i really dont care what any body says, no matter how good his reputation is. i will figure out my mistakes on my own, if the SCRUM is not ready for outside influence, they should not have made it public yet, and i really really dont care about best practices. so far everythings looks good here, no frame drops no lags, no errors.

You’re welcome to figure out errors on your own, I believe he simply was attempting to help you improve your code in hopes to help you, help the community. It appears you took offense to this…

Also, from reading this code further it appears it’s simply a weapons blacklist script… I welcome you to visit a very successful build by Scammer for ideas and code review. You can find it here.

He clearly doesn’t want my help, It will bite him in the ass soon enough though!

Believe it or not, I always thought I could take on the world on my own, quite frankly, you can’t.

1 Like

I understand, but i have my own work, besides this, i have too much information to process, so this just fly’s right by me or flies what ever the correct grammar is i dont know i am Dutch.

I fear for you, that if a basic >50 line script is too much information to process either mentally or on your i7 or 8 Core w/ a good video card then what would happen if you attempt something more elaborate with the application of this knowledge.

Good luck.

Dont worry about me, i am a big boy… and yes 50 lines of code, you are worried about and using against me to belittle me… i am a programmar in 12 different langauges, english grammar is not one of them. besides i program the things i want for my self. the way i code is First i will use Raw code… then i will have a look at the project and see if i can i apply some OOP, right now we are a long way from OOP, because there is more to come. but above all this was very confusing to establish, normal coding did not get me the result i was looking for, its not the 50 lines of code… its the processing engine.

I cannot see your size through a computer screen via the interwebs so I can only imagine…

While that is impressive, it does not show in your coding of this script snippet. Also, English is not a coding language as it is a verbally spoken language but…okay?

While this is all well and good, it would be advised to listen to those who have a better understanding of coding…as you know within coding 12 languages - there are people out there that may have a more efficient way… You should thank them for sharing.

While some may appreciate your code, this is not something that is insanely difficult to do, nor should it be very confusing to establish being that you can code in 12 different languages…

Really… then why does a normal 30 line of code dont work the way it should work?
i really dont understand why we even are having this conversation.
I thought i was very clear in limited english grammar.

Agree, back on topic please.

Even though I don’t see the point of keeping this open if you instantly reject any input.

I will adhere to this and not reply from this point forward unless it’s on topic. Sorry!

First of all, I admire your stance towards cheaters/hackers and am happy you found your own way to tackle an aspect of cheating in FiveM. However…

This is not about knowing English well or not. If you were Dutch, which you claim to be, and you had years of experience in 12 different programming languages, your English would be much better. Dutch children start learning English at the age of 12 (might even be earlier now) and by the time they are 18, they are quite fluent.

I don’t believe you one bit you have a lot of programming experience. Your attitude reeks of amateuristic tendencies and especially you saying that you don’t listen to critique shows me you are inexperienced in programming and life.

Some friendly advice: Take peoples advice, evaluate it and see if what they are saying has some merit to it.

What @Syntasu mentioned is very valuable and constructive critique on your code. This critique will improve not only this code snippet, but also your own programming skills in the future. If you keep on being so defensive about criticism, you will never “make it” in IT, nor in life in general. People around you and work will critique you all the time, it’s up to you what you do with it.

I wish you the best of luck.

1 Like

Thanks i appreciate your comment… why dont u show us all how good u are and give us the correct way/code :slight_smile:

Oh i take advice… but i am very selective… i ignore like 90% :slight_smile: because my experience tells me it is bad advice :slight_smile: or totally from a different perspective…

You know those type of ppl who always complain about grammar?.. that is actually classified as a mental issue, it is no different with code :slight_smile:

Thanks for the facepalm David, here is something, the same ppl who edited my post have turned the “Qoutes” in to ”… this will cause the code to stop working :slight_smile: for newbees it will look like You are absolutely right about me Mittents :slight_smile:

If i can get one more person to learn coding my job is done :slight_smile: