For a good bug report you should probably include:
Client (production/canary) and FXServer version
Client: Canary
DLC Version: 2802
FXServer: 6497(vanilla server with vMenu)
What you expected to happen entityCreating event to always return 7 on script created peds
What actually happens
Calling SetPedAsNoLongerNeeded right after CreatePed will make the native GetEntityPopulationType return 5 instead of 7 inside entityCreating server event
Category of bug (eg. client, server, weapons, peds, native)
client
server
peds
native
Reproducible steps, preferably with example script(s)
Client Script
CreateThread(function()
-- just to not spam the event
while true do
SetPedDensityMultiplierThisFrame(0.0)
SetVehicleDensityMultiplierThisFrame(0.0)
Wait(0)
end
end)
RegisterCommand("spawnped", function(source, args, rawCommand)
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
local heading = GetEntityHeading(playerPed)
local model = GetHashKey("cs_amandatownley")
RequestModel(model)
while not HasModelLoaded(model) do
Citizen.Wait(0)
end
local spawnedPed = CreatePed(4, model, playerCoords.x + 2.0, playerCoords.y, playerCoords.z, heading, true, false)
print(GetEntityPopulationType(spawnedPed))
SetPedAsNoLongerNeeded(spawnedPed)
print(GetEntityPopulationType(spawnedPed))
end, false)
This could be a viable thing to do (not resetting the population type when the script owner is cleared), but that might have odd side effects if other game code expects this.
What’s the use case here? For example, as a workaround, can’t you e.g. wait a little while before removing script ownership from your ped, or just create the ped from a server-side setter? It feels like this is yet another ‘XY problem’ style post and this isn’t the actual root issue.
I have a hunting script that only allows skinning a game created animal. Lately I have found some players circumventing this by calling SetPedAsNoLongerNeeded right after creating an scripted ped. I’m aware of your stance on requesting changes that could be classified as ‘I need this for my anticheat’. While I still feel this is unintended behaviour I understand your concerns with
might have odd side effects if other game code expects this
Yes sir, unsure on what that actually entails since GetEntityPopulationType seems to work for most if not all situations when excluding this edge case. That is why I opened this as a bug report and not as a feature request.
The real problem is that people with cheats can execute this code to make vehicles, objects or ped appear that are noted as NPC entities. And so we server creators don’t really have a solution to this, apart from removing NPCs from the server altogether.