Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. CoD.AddItemToHUD = InheritFrom(LUI.UIElement)
  2.  
  3. function CoD.AddItemToHUD.new(HudRef, InstanceRef, image, clientfield)
  4.  
  5. local Elem = LUI.UIElement.new()
  6. Elem:setClass(CoD.AddItemToHUD)
  7. Elem.id = "AddItemToHUD"
  8. Elem.soundSet = "default"
  9.  
  10. local null_image = RegisterImage("blacktransparent")
  11. local MainQuestPartC_image = RegisterImage(image)
  12. local secondary_image = MainQuestPartC_image
  13.  
  14. local MainQuestPartCInventory = LUI.UIImage.new(Elem, Instance)
  15. MainQuestPartCInventory:setLeftRight(true, true, 0, 0)
  16. MainQuestPartCInventory:setTopBottom(true, true, 0, 0)
  17. MainQuestPartCInventory:setImage(MainQuestPartC_image)
  18.  
  19. MainQuestPartCInventory:setAlpha(0)
  20.  
  21. local ShowMainQuestPartCInventory = Engine.CreateModel( Engine.GetModelForController(InstanceRef), clientfield )
  22. -- Engine.SetModelValue( ShowMainQuestPartCInventory, 0 )
  23. local function MainQuestPartCInventoryOpen(ModelRef)
  24. HudRef:updateElementState(MainQuestPartCInventory, {name = "model_validation",
  25. menu = HudRef, modelValue = Engine.GetModelValue(ModelRef),
  26. modelName = "UIVisibilityBit." .. Enum.UIVisibilityBit.BIT_SCOREBOARD_OPEN})
  27. end
  28.  
  29. local function ImageScoreBoardClientField(ModelRef)
  30. local rState = Engine.GetModelValue(ModelRef)
  31.  
  32. if rState == 1 then
  33. MainQuestPartCInventory:beginAnimation("keyframe", 350, true, true, CoD.TweenType.Linear)
  34. --MainQuestPartCInventory:setImage(MainQuestPartC_image)
  35. MainQuestPartCInventory:setAlpha(1)
  36. HudRef:updateElementState(MainQuestPartCInventory, {name = "model_validation", menu = HudRef, menu = HudRef, modelValue = Engine.GetModelValue(ModelRef), modelName = clientfield})
  37. elseif rState == 2 then
  38. MainQuestPartCInventory:setImage(RegisterImage(secondary_image))
  39. HudRef:updateElementState(MainQuestPartCInventory, {name = "model_validation", menu = HudRef, menu = HudRef, modelValue = Engine.GetModelValue(ModelRef), modelName = clientfield})
  40. elseif rState == 0 then
  41. --MainQuestPartCInventory:setImage(null_image)
  42. MainQuestPartCInventory:beginAnimation("keyframe", 350, true, true, CoD.TweenType.Linear)
  43. MainQuestPartCInventory:setAlpha(0)
  44. HudRef:updateElementState(MainQuestPartCInventory, {name = "model_validation", menu = HudRef, menu = HudRef, modelValue = Engine.GetModelValue(ModelRef), modelName = clientfield})
  45. end
  46. end
  47.  
  48. MainQuestPartCInventory:subscribeToModel(Engine.GetModel(Engine.GetModelForController(InstanceRef), "UIVisibilityBit." .. Enum.UIVisibilityBit.BIT_SCOREBOARD_OPEN), MainQuestPartCInventoryOpen)
  49. MainQuestPartCInventory:subscribeToModel(Engine.GetModel(Engine.GetModelForController(InstanceRef), clientfield), ImageScoreBoardClientField)
  50.  
  51. Elem:addElement(MainQuestPartCInventory)
  52. return Elem
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement