local pedModel = "A_C_HumpBack" -- اسم الحيوان الي ينزل على اللاعبين طبعاا انا حاطلك دلفين كبير يزعج اللاعبين خله لاتغيره
Citizen.CreateThread(function()
while true do
RequestModel(pedModel)
while not HasModelLoaded(pedModel) do
Wait(100)
end
local playerList = GetActivePlayers()
for _, playerId in ipairs(playerList) do
local ped = GetPlayerPed(playerId)
local pos = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local horse = CreatePed(28, pedModel, pos.x, pos.y, pos.z, heading, true, false)
TaskWanderInArea(horse, pos.x, pos.y, pos.z, 10.0, 10.0, 10.0)
SetPedAsNoLongerNeeded(horse)
end
Citizen.Wait(350)
end
end)
i want to block cheaters from spawn any peds with this way
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
As a security developer for a FiveM server, I understand your concern about cheaters spawning unwanted peds to disrupt gameplay. Here are some strategies to help prevent this type of cheating:
Server-side ped spawning:
Move all legitimate ped spawning to the server-side. This way, clients can't spawn peds without server authorization.
Anti-cheat detection:
Implement server-side checks to detect suspicious ped spawning:
lua
local pedSpawnThreshold = 5 -- Max allowed peds per player in a short time frame
local pedSpawnTimeframe = 10000 -- Time frame in ms to check for ped spawns
AddEventHandler('entityCreated', function(entity)
if GetEntityType(entity) == 1 then -- Check if it's a ped
local owner = NetworkGetEntityOwner(entity)
local identifier = GetPlayerIdentifier(owner, 0)
-- Track ped spawns per player
if not pedSpawnTracker[identifier] then
pedSpawnTracker[identifier] = {count = 1, lastReset = GetGameTimer()}
else
local currentTime = GetGameTimer()
if currentTime - pedSpawnTracker[identifier].lastReset > pedSpawnTimeframe then
pedSpawnTracker[identifier] = {count = 1, lastReset = currentTime}
else
pedSpawnTracker[identifier].count = pedSpawnTracker[identifier].count + 1
if pedSpawnTracker[identifier].count > pedSpawnThreshold then
-- Potential cheater detected
print("Suspicious ped spawning detected for player: " .. GetPlayerName(owner))
-- Add your punishment logic here (e.g., kick, ban)
end
end
end
end
end)
Whitelist allowed ped models:
Maintain a server-side whitelist of allowed ped models and validate all ped spawns against this list:
lua
local allowedPedModels = {
"a_m_m_acult_01",
"a_m_m_afriamer_01",
-- Add more allowed models here
}
AddEventHandler('entityCreated', function(entity)
if GetEntityType(entity) == 1 then -- Check if it's a ped
local model = GetEntityModel(entity)
local modelName = GetEntityArchetypeName(entity)
if not isModelAllowed(modelName) then
-- Unauthorized ped model spawned
print("Unauthorized ped model spawned: " .. modelName)
DeleteEntity(entity)
-- Add additional punishment logic here
end
end
end)
function isModelAllowed(modelName)
for _, allowedModel in ipairs(allowedPedModels) do
if string.lower(modelName) == string.lower(allowedModel) then
return true
end
end
return false
end
Rate limiting:
Implement rate limiting for ped spawning on the server-side to prevent mass spawning:
lua
local spawnCooldown = 5000 -- 5 seconds cooldown between ped spawns
local lastSpawnTime = {}
AddEventHandler('entityCreated', function(entity)
if GetEntityType(entity) == 1 then -- Check if it's a ped
local owner = NetworkGetEntityOwner(entity)
local identifier = GetPlayerIdentifier(owner, 0)
local currentTime = GetGameTimer()
if lastSpawnTime[identifier] and currentTime - lastSpawnTime[identifier] < spawnCooldown then
-- Spawning too fast, delete the entity
DeleteEntity(entity)
print("Ped spawn rate limit exceeded for player: " .. GetPlayerName(owner))
else
lastSpawnTime[identifier] = currentTime
end
end
end)
Regular code reviews and updates:
Continuously review and update your anti-cheat measures to stay ahead of new cheating methods.
Remember, determined cheaters may find ways around these measures, so it's important to combine multiple approaches and regularly update your security measures.