| Cheaters Spawning Weapons | Way to change natives |

Hello,
I would like to ask about GiveWeaponToPed() function if is any possible way to do something for cheaters! The could easily spawn weapons and i cant actually find a way to patch this!

Example Code That Cheaters use :
(qwxBa75Z2xuL.id is a weapon variable called from selecting a button)
GiveWeaponToPed(GetPlayerPed(-1), GetHashKey(qwxBa75Z2xuL.id), 1000.0, false)

I thinked about somehow changing the Native of GiveWeaponToPed() to something else
ex. GiveWeaponToPeed() but i dont know if this possible!

I would be very thankful, if someone could help me to solve this problem!

You could make a weapon blacklist to detect modders.

Giveweapontoped is a native function

You cant rename it… every client does have it.

And i know there is a giveweaponevent in server

I have already made a weapon blacklist! Modders spawn weapons thats not blacklist this is the problem! GiveWeaponEvent in server is for giving a weapon to target also !

Thanks for answering

make a check to see if the player is supposed to have the weapon if they dont then you remove it (youd need a backend database or some kinda storage for this)

I am think about something like this :slight_smile:

Idk if GetPlayerLoadout(PlayerPedId()) is the right way to check the weapons from client !

Do you have any idea in your mind how to check if the player is supposed to have the weapon ? If you want you can check what i pastebin and tell me if this is a wrong way or good way to check!

You should keep a server-side only array with the weapons that the player is ‘supposed to have’ on him. After that, you could create a client-side thread that checks player’s weapon loadout and sends it to the server, where you can compare the arrays (idk if you can do that on server only).

Citizen.CreateThread(function()
    while true do
        Wait(30000)
        TriggerServerEvent('es_extended:saveLoadout',GetPlayerLoadout(PlayerPedId()))
    end
end)

Why do you trust the client to have the correct loadout in the first place? You should add weapons to the esx loadout, or whatever esx uses, on the server-side (when buying a weapon, or whatever) and sending that to the client instead.

True, so do you have any example code for how to do this?

maybe be thankful that the modders only spawned weapons not the FIB building or ramps.
are you using any anti cheat? there is some free anticheat here in CFX forum to detect some low lvl injected resource

you could also try using a weapon as item and disable the weapon wheel, this what i have do in the past, and stopped some of them cheating a weapons.

as your question to critter

Citizen.CreateThread(function()

    while true do

        for i=0, GetNumPlayerIndices()-1 do

            local source = GetPlayerFromIndex(i)

            local xPlayer = ESX.GetPlayerFromId(source)

            local hasweapon = false

            local pedweapon = GetSelectedPedWeapon(GetPlayerPed(source))

            for k,v in ipairs(xPlayer.getLoadout()) do

                if GetHashKey(v.name) == GetSelectedPedWeapon(GetPlayerPed(source)) then

                    print("Player "..source.." has the weapon" ,v.name)

                    hasweapon = true

                elseif pedweapon == -1569615261 then

                    print("unarmed")

                    hasweapon = true

                    break

                end

            end

            if not hasweapon and pedweapon ~= -1569615261 then

                print("spawned weapon : possible mod?")

            end

        end

        Citizen.Wait(5000)

    end

end)

This will work only for ESX (tested v1 final) and not 100% will work in game build 2372 (some fxserver version)
this will check if player has a weapon from ESX LOADOUT
This is a Server script, you could do similar code using client, but client data is always untrusted.
DEMO: 2021-08-19 18-32-36

Im using an anticheat and i have block almost everything that a modder can to do and stop the gameplay.I also have disable the weapon wheel … I will try the code and reply to you again! I think this will solve my problem!

Hello again, this is actually working for menus that spawn the weapons and get the weapons in their hands! It solved the half problem! If someone spawn without getting the weapon in their hand this loop cannot detect it!

Thank you

1 Like

yes unfortunately there is no server native, that will detect all player loadout.

this is the only native can be used in this case that i have found

GetSelectedPedWeapon
1 Like