Jump to content

Script not working


.:HyPeX:.

Recommended Posts

It should draw a window with 2 blue lines in the bottom part of the screen with a text winner: default and an undertext streak: (1) when using the command /win, but nothing happens.

Any idea anyone?

  
local x,y = guiGetScreenSize() 
local announce = "default" 
local Streak = "1" 
announce = "default" 
Streak = "1" 
  
function setStreak(streak) 
Streak = streak 
end 
addEvent("setStreak", true) 
addEventHandler("setStreak", getRootElement(), setStreak) 
  
function setAnnounce(text) 
announce = text 
end 
addEvent("setAnnounce", true) 
addEventHandler("setAnnounce", getRootElement(), setAnnounce) 
  
function announce() 
executeCommandHandler ("win", localplayer) 
end 
addEvent("announce", true) 
addEventHandler("announce", getRootElement(), announce) 
  
local Dx_Rec = nil 
addCommandHandler("win",  
function () 
    if Dx_Rec then return end 
    Dx_Rec = {} 
    Dx_Rec.startTime = getTickCount() 
    Dx_Rec.endTime = Dx_Rec.startTime + 2000 
    Dx_Rec.easingFunction = "InQuad"  
    addEventHandler("onClientRender", getLocalPlayer(), drawStuff) 
end) 
  
function drawStuff() 
local x,y = guiGetScreenSize() 
local now = getTickCount() 
local elapsedTime = now - Dx_Rec.startTime 
local duration = Dx_Rec.endTime - Dx_Rec.startTime 
local progress = elapsedTime / duration 
local fAnimationTime = getEasingValue(progress, Dx_Rec.easingFunction) 
local alpha = fAnimationTime*200 
local alphal = alpha/1.2 
    dxDrawRectangle ( 0, y/1.4, x, y, tocolor ( 0, 0, 0, alpha ) ) 
    dxDrawText ( "Winner: #ffffff " .. announce, 0, y/1.3, x, y, tocolor ( 0, 170, 255, alpha ), 1.3, "bankgothic", "center","top",nil,nil,nil, true, true ) 
    dxDrawText ( "Streak: #00aaff( #ffffffx" .. Streak .." #00aaff)", 0, y/1.15, x, y, tocolor ( 0, 170, 255, alpha ), 1.3, "bankgothic", "center","top",nil,nil,nil, true, true ) 
    dxDrawLine ( 0, y/1.02, x, y/1.02, tocolor ( 0, 170, 255, alphal ), 15 ) 
    dxDrawLine ( 0, y/1.4, x, y/1.4, tocolor ( 0, 170, 255, alphal ), 15 ) 
        if now > Dx_Rec.endTime then 
        removeEventHandler("onClientRender", getRootElement(), drawStuff) 
        addEventHandler("onClientRender", getRootElement(), Paused) 
        Pause = setTimer(function() 
                        removeEventHandler("onClientRender", getLocalPlayer(), Paused) 
                        Dx_Rec.startTime = getTickCount() 
                        Dx_Rec.endTime = Dx_Rec.startTime + 4000 
                        Dx_Rec.easingFunction = "OutQuad" --Fast at first then decelerating 
                        addEventHandler("onClientRender", getLocalPlayer(), UndrawStuff) 
                        end, 5000, 1) 
    end 
end 
  
function Paused() 
dxDrawRectangle ( 0, y/1.4, x, y, tocolor ( 0, 0, 0, 200 ) ) 
dxDrawText ( "Winner: #ffffff " .. announce, 0, y/1.3, x, y, tocolor ( 0, 170, 200, alpha ), 1.3, "bankgothic", "center","top",nil,nil,nil, true, true ) 
dxDrawText ( "Streak: #00aaff(#ffffff x" .. Streak .." #00aaff)", 0, y/1.15, x, y, tocolor ( 0, 170, 255, 200 ), 1.3, "bankgothic", "center","top",nil,nil,nil, true, true ) 
dxDrawLine ( 0, y/1.02, x, y/1.02, tocolor ( 0, 170, 255, 166 ), 15 ) 
dxDrawLine ( 0, y/1.4, x, y/1.4, tocolor ( 0, 170, 255, 166 ), 15 ) 
end 
  
function UndrawStuff() 
local x,y = guiGetScreenSize() 
local now = getTickCount() 
local elapsedTime = now - Dx_Rec.startTime 
local duration = Dx_Rec.endTime - Dx_Rec.startTime 
local progress = elapsedTime / duration 
local fAnimationTime = getEasingValue(progress, Dx_Rec.easingFunction) 
local alpha = (1-fAnimationTime)*200 
local alphal = alpha/1.2 
    dxDrawRectangle ( 0, y/1.4, x, y, tocolor ( 0, 0, 0, alpha ) ) 
    dxDrawText ( "Winner: #ffffff " .. announce, 0, y/1.3, x, y, tocolor ( 0, 170, 255, alpha ), 1.3, "bankgothic", "center","top",nil,nil,nil, true, true ) 
    dxDrawText ( "Streak: #00aaff(#ffffff x" .. Streak .." #00aaff)", 0, y/1.15, x, y, tocolor ( 0, 170, 255, alpha ), 1.3, "bankgothic", "center","top",nil,nil,nil, true, true ) 
    dxDrawLine ( 0, y/1.02, x, y/1.02, tocolor ( 0, 170, 255, alphal ), 15 ) 
    dxDrawLine ( 0, y/1.4, x, y/1.4, tocolor ( 0, 170, 255, alphal ), 15 ) 
if now > Dx_Rec.endTime - 200 then 
removeEventHandler("onClientRender", getLocalPlayer(), UndrawStuff) 
Dx_Rec = nil 
end     
end 

Link to comment
  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...