pan7nikt Posted September 15, 2021 Posted September 15, 2021 (edited) Hi, I was trying to spawn a ped using a command and then make it invincible. The ped spawns normally, but using the setInvincible method returns an error:"TypeError: dynamicPed.setInvincible is not a function" Here is my code: mp.events.addCommand("ped", (player) => { let dynamicPed = mp.peds.new(mp.joaat('mp_m_freemode_01'), player.position, {dynamic:true}); dynamicPed.controller = player; dynamicPed.RelationshipGroupHash = 0x84DCFAAD; dynamicPed.setInvincible(true); }) I know that adding invincible:true to the 2nd line works, but i wanted to do it using the setInvincible() function. Perhaps it is not possible to use this method on server side? I have also tried other functions and none of them are working. I also tried to do it like that: dynamicPed.invincible = true and it doesn't give me an error but it also doesn't work. Does anyone know what is wrong here and how to fix it? Thanks in advance! Edited September 15, 2021 by pan7nikt
pan7nikt Posted September 15, 2021 Author Posted September 15, 2021 It seems that the method exists only on Clientside. I ended up passing it from the server through an event like this: Serverside: mp.events.addCommand("ped", (player) => { let dynamicPed = mp.peds.new(mp.joaat('s_m_y_swat_01'), player.position, {dynamic:true}); dynamicPed.controller = player; dynamicPed.RelationshipGroupHash = 0x84DCFAAD; player.call(`setPedBehavior`, [dynamicPed]); }) Clientside: mp.events.add('setPedBehavior',(ped) => { ped.setInvincible(false); }) Although I don't think it will synchronize for other players, so it still might not be the proper way to do it.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now