Bully-Board

Bully Modding Section => Modding Questions/Help => Topic started by: Ming on April 12, 2022, 10:34:43 PM

Title: DeletePersistentEntity not work
Post by: Ming on April 12, 2022, 10:34:43 PM
Code: [Select]
FPS6 = function()
 
  while true do
   
    local HX, HY, HZ = PedGetHeadPos(gPlayer)
    local Heading = PedGetHeading(gPlayer)
    local DeltaX = -math.sin(Heading)
    local DeltaY = math.cos(Heading)
    if math.deg(Heading) > 0 then
      Rotation = math.deg(Heading) - 180
    else
      Rotation = math.deg(Heading) + 179.99
    end
    Qiang = CreatePersistentEntity("WPCannon", HX + DeltaX, HY + DeltaY, HZ - 0.5, Rotation, AreaGetVisible())
   
    DeletePersistentEntity(Qiang)
   
    Wait(0)
  end
 
end
Why DeletePersistentEntity(Qiang) not work, it will be a lot of cannon and game crash
Title: Re: DeletePersistentEntity not work
Post by: RBS ID on April 13, 2022, 01:44:42 AM
CreatePersistentEntity  returns 2 value, the object index & the object itself/type/geometry(or something like that), so it must have 2 variable that assign to this function, example:
    local objIdx, obj = CreatePersistentEntity(bla, bla, ...)

DeletePersistentEntity  also takes 2 arguments, example:
    DeletePersistentEntity(objIdx, obj)

You can see the usage of those functions in decompiled 1_06_01.lur.
Title: Re: DeletePersistentEntity not work
Post by: Ming on April 13, 2022, 02:43:13 AM
CreatePersistentEntity  returns 2 value, the object index & the object itself/type/geometry(or something like that), so it must have 2 variable that assign to this function, example:
    local objIdx, obj = CreatePersistentEntity(bla, bla, ...)

DeletePersistentEntity  also takes 2 arguments, example:
    DeletePersistentEntity(objIdx, obj)

You can see the usage of those functions in decompiled 1_06_01.lur.
Get it !