Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. do pliku C:
  2.  
  3.  
  4. local start = getTickCount()
  5. function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
  6. if
  7. type( sEventName ) == 'string' and
  8. isElement( pElementAttachedTo ) and
  9. type( func ) == 'function'
  10. then
  11. local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
  12. if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
  13. for i, v in ipairs( aAttachedFunctions ) do
  14. if v == func then
  15. return true
  16. end
  17. end
  18. end
  19. end
  20.  
  21. return false
  22. end
  23.  
  24. foNte = dxCreateFont(":Sg_Buttony/font.ttf",9) or "defaul-bold"
  25.  
  26. l={}
  27. function hud()
  28. x,y = guiGetScreenSize()
  29. screenW,screenH = guiGetScreenSize()
  30. for k,v in ipairs ( getElementsByType ( "object" ) ) do
  31. if getElementData ( v, "ogloszenie" ) then
  32. local tekst = getElementData ( v, "tekstogloszenia" )
  33. local width = dxGetTextWidth(tekst,1,"default-bold")
  34. local now = getTickCount()
  35. local endTime = start + 2000
  36. local elapsedTime = now - start
  37. local duration = endTime - start
  38.  
  39. local progress = elapsedTime / duration
  40.  
  41. if progress and progress > 4 then
  42. if not s then
  43. s = getTickCount()
  44. end
  45. local x, y, z = interpolateBetween (screenW * 0.3493, screenH * - 0.1000, 0, screenW * 0.3493, screenH * - 0.1000, 0, (s-getTickCount())/(( s + 2000 ) - s ), "OutBack")
  46. local xt, yt, zt = interpolateBetween (screenW * 0.3551, screenH * - 0.1000, 0,screenW * 0.3551, screenH * - 0.1000 , 0, (s-getTickCount())/(( s + 2000 ) - s ), "OutBack")
  47. roundedRectangle(x, y, screenW * 0.2941, screenH * 0.0859 + (width * 0.05), tocolor(0, 0, 0, 150),tocolor(0, 0, 0, 150), false)
  48. dxDrawText(tekst,xt, yt,screenW * 0.6382, screenH * 0.8555, tocolor(255,255,255, 255), 1.00, foNte, "center", "top", false, true, false, false, false)
  49. return end
  50. local px, py, pz = getElementPosition(localPlayer)
  51. local x, y, z = interpolateBetween (screenW * 0.3493, screenH * - 0.1000, 0,screenW * 0.3493, screenH * 0.0100 , 0, progress, "OutBack")
  52. local xt, yt, zt = interpolateBetween (screenW * 0.3551, screenH * - 0.1000, 0,screenW * 0.3551, screenH * 0.0200 , 0, progress, "OutBack")
  53. roundedRectangle(x, y, screenW * 0.2941, screenH * 0.0859 + (width * 0.05), tocolor(0, 0, 0, 150), tocolor(0, 0, 0, 150), false)
  54. dxDrawText(tekst,xt, yt,screenW * 0.6382, screenH * 0.8555, tocolor(255,255,255, 255), 1.00, foNte, "center", "top", false, true, false, false, false)
  55. end
  56. end
  57. end
  58.  
  59. function roundedRectangle(x, y, w, h, borderColor, bgColor, postGUI)
  60. if (x and y and w and h) then
  61. if (not borderColor) then
  62. borderColor = tocolor(0, 0, 0, 200);
  63. end
  64.  
  65. if (not bgColor) then
  66. bgColor = borderColor;
  67. end
  68.  
  69. --> Background
  70. dxDrawRectangle(x, y, w, h, bgColor, postGUI);
  71.  
  72. --> Border
  73. dxDrawRectangle(x + 2, y - 1, w - 4, 1, borderColor, postGUI); -- top
  74. dxDrawRectangle(x + 2, y + h, w - 4, 1, borderColor, postGUI); -- bottom
  75. dxDrawRectangle(x - 1, y + 2, 1, h - 4, borderColor, postGUI); -- left
  76. dxDrawRectangle(x + w, y + 2, 1, h - 4, borderColor, postGUI); -- right
  77. end
  78. end
  79.  
  80.  
  81. addEventHandler ( "onClientElementDataChange", root, function(data,old)
  82. if getElementType(source) == "object" and data == "ogloszenie" then
  83. if getElementData(source,"ogloszenie") then
  84. if isEventHandlerAdded("onClientRender",root,hud) then
  85. removeEventHandler ( "onClientRender", root, hud)
  86. end
  87. l={math.random(0,255),math.random(0,255),math.random(0,255)}
  88. czas = getTickCount()
  89. start = getTickCount()
  90. s = nil
  91. addEventHandler ( "onClientRender", root, hud)
  92. else
  93. removeEventHandler ( "onClientRender", root, hud)
  94. czas = getTickCount()
  95. start = getTickCount()
  96. s = nil
  97. l={}
  98. end
  99. end
  100. end)
  101. addEventHandler ( "onClientRender", root, hud)
  102.  
  103. DO PLIKU S:
  104.  
  105.  
  106. local skrzyniaogloszen = createObject ( 980, 0,0, -100 )
  107.  
  108. function ogloszenie ( source, cmd, ... )
  109. if not getElementData(source,"user:premium") then outputChatBox("* Brak uprawnień.",source,255,0,0) return end
  110. if ... then
  111. if not getElementData ( skrzyniaogloszen, "ogloszenie" ) then
  112. local text = table.concat({...}, " " )
  113. setElementData ( skrzyniaogloszen, "ogloszenie", true )
  114. setElementData ( skrzyniaogloszen, "tekstogloszenia","[Premium] "..getPlayerName(source):gsub("#%x%x%x%x%x%x","").." ["..getElementData ( source, "id").."] : \n "..text.." ")
  115. setTimer ( setElementData, 10000,1, skrzyniaogloszen, "ogloszenie", false )
  116. else
  117. outputChatBox("* Ogłoszenia mogą być nadawane minimum 10 sekund.", source, 255, 0, 0, true )
  118.  
  119. end
  120. else
  121. outputChatBox("Aby nadać ogłoszenie /ogloszenie [tresc] .", source, 255, 96, 0, true )
  122. end
  123. end
  124. addCommandHandler("ogloszenie", ogloszenie)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement