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!
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 !
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)
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.
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!