Jump to content

Last survivor on last survivor?


~Air

Recommended Posts

Hey guys,

I got a problem, when somebody wins the text doesn't get removed.. (it's only at last survivor, the wintext works perfectly)

Here's the code:

addEvent("onWins", true) 
function drawNexMapString(player,wintext) 
local x, y = guiGetScreenSize() 
if wintext == "none" then 
else 
    winnertext = dxText:create(wintext,  x/2, y/2 -180 + 1, false, "default-bold", 1.65, "center") 
    winnertext:type('shadow', 1.3,1) 
    winnertext:font("default-bold") 
setTimer( 
    function() 
    winnertext:visible(false) 
    end,  
    5000, 1) 
end 
winner = dxText:create("" ..getPlayerNametagText(player).." #FFFFFFis the final survivor!", x/2, y/2 -150 + 1, false, "default-bold", 1.65, "center") 
winner:type('shadow', 1.3,1) 
winner:font("default-bold") 
end 
setTimer( 
function() 
winner:visible(false) 
 end, 
 5000, 1) 
addEventHandler("onWins", getRootElement(), drawNexMapString) 
  

Link to comment
are you have any SQL or Data in your script?

Please don't reply if you have absolutely no idea what is this about.

@Air: One of the problems I just noticed, is that you have a timer outside of your "drawNexMapString" function, which causes it to execute when the resource starts, so 'winner' is nil then.

Try this:

function drawNexMapString ( player, wintext ) 
    local x, y = guiGetScreenSize ( ) 
    if ( wintext == "none" ) then 
    else 
        winnertext = dxText:create ( wintext,  x/2, y/2 -180 + 1, false, "default-bold", 1.65, "center" ) 
        winnertext:type ( 'shadow', 1.3, 1 ) 
        winnertext:font ( "default-bold" ) 
        setTimer ( 
            function ( ) 
                winnertext:visible ( false ) 
            end 
            ,5000, 1 
        ) 
    end 
  
    winner = dxText:create ( tostring ( getPlayerNametagText ( player ) ) .." #FFFFFFis the final survivor!", x/2, y/2 -150 + 1, false, "default-bold", 1.65, "center" ) 
    winner:type ( 'shadow', 1.3, 1 ) 
    winner:font ( "default-bold" ) 
    setTimer ( 
        function ( ) 
            winner:visible ( false ) 
        end 
        ,5000, 1 
    ) 
end 
addEvent ( "onWins", true ) 
addEventHandler ( "onWins", getRootElement(), drawNexMapString ) 

Link to comment

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