Can someone explain to me, in a general sense, how are modders able to do things they do? I saw them spawning objects, either static ones or attached to players. I also saw them spawning weapons, vehicles, infinite health etc. Couldn’t server owners detect, at least some of these cheats?
For example, when a player (modder) spawns an object, the server surely knows about since it synces it to other clients. Wouldn’t it be possible to instantly delete this object if the player that spawned it isn’t an admin?
Am i being naive about this and the functionality to detect this sort of things doesn’t exist? If so why doesn’t it exist … ?
shadw1, they do this by injecting code into the client, and then using that access to pop up a menu (or whatever), and then calling game native functions from there, or sometimes executing Lua code.
Yes that part i understand. My confusion was more on the server side of things. In theory, with the native that you provided, one could check if the entity owner is an admin, if not, that would be evidence enough that they are cheating?
“Evidence” is a strong word, and it depends on how your server is set up.
For example, if you have one of those phone scripts, and someone takes out their phone, that usually entails creating an entity (the phone model) and attaching it to their hand.
You don’t need to be an admin to take out your phone, and using the phone is likely not considered cheating on your server.
The mentioning of an admin was just an example, it could be looked as a permission. The phone script in question would need to give the player a temporary permission for that phone model entity. Some other script would be constantly going over all entities and their owners to see if they have permissions for them. If not - banned, or at the very least, their entities deleted.
In theory, this would be enough to stop modders from spawning entities?
they can indeed detect this, there calling server sided functions, by implementing “injecting” their own client side scripts or something.
You can block this from happening, by adding a block/autokick/ban on these functions or adding a keycheck to the functions, and checking serversided if they match.
here’s a list provided by @d0p3t with the most commonly abused functions.
I did still but i think native is broken becouse it wont work.
function GetOwnerOfEntity(entity)
if (not DoesEntityExist(entity)) then
return nil
end
local owner = NetworkGetEntityOwner(entity)
if (GetEntityPopulationType(entity) ~= 7) then return nil end
return owner
end
bObjs = {
['blocked_prop_hash'] = true,
}
AddEventHandler("entityCreating",function(entity)
if not DoesEntityExist(entity) then
return
end
local src = NetworkGetEntityOwner(entity)
if GetEntityType(entity) == 3 then
local model = GetEntityModel(entity)
if bObjs[model] == true then
CancelEvent()
-- Ban player TriggerEvent('YourEvent', src, model )
end
end
end)
I tried and it’s not a good idea, you could ban innocent players with that because if the modder spawns, for example, a cage or an unfriendly ped to troll someone, and the modder is far away, the owner will be the victim.
If you have OneSync and you can use the entityCreating event, then it works as DioneB showed, because most likely the entity owner in that tick is the real creator of the entity, but I never tried it because I don’t use OneSync at the moment.
Instead, if you don’t have OneSync, I suggest you to keep a server-side list of valid entities’ network-ids, and to regularly ask every player to return a list of all their “mission” entities (population type = 7)’ network ids, and if the entity is not on your list, then delete it.
Yes, well, I was assuming the context of the entityCreating event.
Also, why not use OneSync? It makes no sense to me that people want worse sync and no server-side entity awareness, so please elaborate on what the upside is.
The issue is that I am currently developing my server from scratch, and I don’t know how long it will take, so don’t want to start paying the monthly $15 too early; I will move to OneSync after I’ll see my server succeed.