how can i make a value to get an histeresis? like if i want it to be 5 ± 2?
well of course without having to change every value…
like if i have to make a
for k,v in pairs(some_array) do
if v.value ± 2 then
code here
end
end
how can i make a value to get an histeresis? like if i want it to be 5 ± 2?
well of course without having to change every value…
like if i have to make a
for k,v in pairs(some_array) do
if v.value ± 2 then
code here
end
end
the only solution i came to is
local hysteresis = 2
for k,v in pairs(some_array) do
if (somevalue <= v.value + 2) or (somevalue >= v.value - 2) then
code here
end
end
but i was looking for something more elegant and direct
What are you trying to accomplish? from the description and code examples I can’t tell…
honestly i’m trying to make a teleport anticheat… since coordinates are a pain in the ass if more than one player get teleported if died for example… i need to make an hysteresis to make sure the anticheat won’t get someone teleported by script but slightly left or right or front or behind those coords since i need to whitelist them
So basically a math.random function?
not actually…
i start with a local array of coords like
local WhitelistedCoords = {
hospital = { x =, y =, z = },
police cells = { x =, y = , z = },
etc
}
then since i need to whitlist those checks from being reported in a loop i do
local ped = PlayerPedId()
local pedCoordBefore = GetEntityCoords(ped, true)
Wait(50)
local pedCoordAfter = GetEntityCoords(ped, true)
for k,v in pairs(WhitelistedCoords) do
if(GetDistanceBetweenCoords(pedCoordBefore , pedCoordAfter.x, pedCoordAfter.y, pedCoordAfter.z , true) > 200) and pedCoordAfter.x ~= v.x ± 5 and pedCoordAfter.y ~= v.y ± 5 and pedCoordAfter.z ~= v.z ± 5 then
ReportPlayer()
end
end
this is a simple example of course, the need here is to make an hysteresis of the coords to be sure players that are slightly not in center of those coords don’t get reported for nothing since 2 peds in same coords can’t coexist
that’s what i wanna do
Sorry, I have no clue on what you are trying to ask or convey to me/us
what i want exactly is to know how can i say in the script that i vant a value with hysteresis… since it can’t be that single one or it triggers too often… i need give that variable in a range of + a value and minus a value…