Jump to content

Script not working


.:HyPeX:.

Recommended Posts

Posted

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 

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

  • 1 month later...
Posted

Where did you define 'localplayer' line 21 ?

And where do you call setAnnounce or announce ? In another script ?

MfG, ReDFoX///

The human is the biggest bug of a computer.

Posted

Line 5 & 6 is useless.

Change localplayer to localPlayer at line 21.

onClientRender should be called to the root element.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
Where did you define 'localplayer' line 21 ?

And where do you call setAnnounce or announce ? In another script ?

localplayer in client side is predefined by mta on client side: viewtopic.php?f=91&t=39678

Line 5 & 6 is useless.

Change localplayer to localPlayer at line 21.

onClientRender should be called to the root element.

it is not, if i dont add them, the script will fail.

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

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...