Comments (7)
Can you verify that the same thing happens for non-player peds?
from fivem.
you can use this Thread to place MaxHealth
CreateThread(function()
while true do
local Ped = PlayerPedId()
if GetEntityMaxHealth(Ped) ~= 401 then
SetEntityMaxHealth(Ped,401)
SetPedMaxHealth(Ped,401)
end
Wait(1000)
end
end)
from fivem.
You need to use SET_ENTITY_MAX_HEALTH
to populate the CPedHealthDataNode
, using other natives to set the max health of a player-ped will only populate the CPlayerGameStateDataNode
.
The same applies for non-player peds.
from fivem.
adding SetEntityMaxHealth
doesn't seem to change the outcome. Testing on a server spawned ped appears to return the same results where clientside the value of the ped health reports the desired max and full values, but the server side still only reports 200.
server.lua:
RegisterCommand('create_test_ped', function(src)
local coords = GetEntityCoords(GetPlayerPed(src)) + vector3(2, 2, 1)
local ped = CreatePed(4, `s_m_y_cop_01`, coords.x, coords.y, coords.z, 0.0, true, true)
while not DoesEntityExist(ped) do Wait(0) end
print(NetworkGetNetworkIdFromEntity(ped))
print(GetEntityHealth(ped))
print(GetEntityMaxHealth(ped))
end)
RegisterCommand('report_ped_health', function(_, args)
local ped = NetworkGetEntityFromNetworkId(tonumber(args[1]))
print(GetEntityHealth(ped))
print(GetEntityMaxHealth(ped))
print(GetPedMaxHealth(ped))
end)
client.lua
RegisterCommand('set_test_ped_health', function(_, args)
local ped = NetworkGetEntityFromNetworkId(tonumber(args[1]))
SetPedMaxHealth(ped, 1100)
SetEntityMaxHealth(ped, 1100)
ReviveInjuredPed(ped)
Wait(0)
SetEntityHealth(ped, 1100)
print(GetEntityHealth(ped))
print(GetEntityMaxHealth(ped))
end)
results:
> create_test_ped
65534
0
0
> report_ped_health 65534
200
200
200
> set_test_ped_health 65534
1100
1100
> report_ped_health 65534
200
200
200
from fivem.
I tested a couple of other things.
using the test ped above, client A sets the higher values, which read back as expected on Client A. But Client B reports the normal 200/200 values while the ped is owned by Client A, regardless if the values are set while client B is present or arrives after.
Client A leaving the area and Client B setting health, Client A returning reports 200/200
Client A and B both report the expected elevated values for their player peds on the clientside in all scenarios though
from fivem.
You shouldn't call SET_PED_MAX_HEALTH
and only use SET_ENTITY_MAX_HEALTH
as calling SetPedMaxHealth
before SetEntityMaxHealth
with the same value causes game code to not set the change bit on the sync node as local max health hasn't changed. (Only SetEntityMaxHealth
sets the bit flag and only if local max health was altered by the script command, which isn't the case here as being previously set to the same value by SetPedMaxHealth
)
(You can easily test this with calling SetPedMaxHealth
before SetEntityMaxHealth
but with a different value.)
from fivem.
That makes sense, and removing the SET_PED_MAX_HEALTH call from my code as well as the examples outlined above creates the desired result for me.
Thanks!
from fivem.
Related Issues (20)
- Consider reverting 'ui_updateChannel' ScriptAPI restriction HOT 5
- GetVariantProp not working
- seriallization of ther server object id response failed HOT 1
- GetEntityHealth server side return 0
- Cannot use globbing to import scripts HOT 3
- No helping error info on new natives checks HOT 3
- Client Crashes when attempting to fix Poly Edge Refences on .ydr or .ybn [ Physics validation failed ] HOT 17
- Serialization of the server object id response failed HOT 1
- Client crash in specific area of the map HOT 1
- Player spawned at Michael (Player Zero) Sync Problem HOT 1
- Crash with lemon-jig-oxygen when loading some MLO's - 100% of the time. HOT 4
- REDM justs start one time after installation. The it does not start again.
- TxdStore is not enough. -solved HOT 7
- The issue of the number of people in a given area HOT 8
- POST request - GetEnforcementFlag being spammed in the console HOT 1
- Having awefull issue HOT 10
- Serialization of ID packet failed. Issue to report them HOT 10
- Large events not being executed on canary HOT 11
- New Type of Crash since last RedM update / RDR2_b1491.exe!sub_1426EDBDC (0x1b) HOT 20
- Rage input hook stops updating keyboard key states after CEF userMedia output stream for audio is created
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fivem.