Jump to content

textItem not disappearing even if the timer is correct


Franc[e]sco

Recommended Posts

function onPlayerDeath (ammo, attacker, weapon, bodypart) 
    setTimer(spawnThePlayer, 10000, 1, source) 
    sendClientMsg("You died! 10 seconds till respawn", source, "red") 
    if attacker then 
        setElementData( attacker, "score", getElementData(attacker, "score")+1 ) 
        setElementData( attacker, "killingspree", getElementData(attacker, "killingspree")+1 ) 
        if (bodypart == 9) then 
            sendClientMsgToAll("* " .. getClientName(attacker) .. " just headshotted " .. getClientName(source) .. " !", "green") 
        elseif (bodypart == 4) then 
            sendClientMsgToAll("* " .. getClientName(attacker) .. " just ass shotted " .. getClientName(source) .. " ! Ow, that hurts :(", "green") 
        end 
        if (getElementData(attacker, "killingspree") == 5) then 
            killingSpreeMsg = textCreateTextItem(getClientName(attacker) .. " is dominating!", 0.3, 0.5) 
            textDisplayAddText(killingSpreeDisplay, killingSpreeMsg) 
            textItemSetColor(killingSpreeMsg, 255, 255, 255, 180) 
            setTimer(textDisplayRemoveText, 5000, 1, killingSpreeMsg, killingSpreeDisplay) 
        elseif (getElementData(attacker, "killingspree") == 10) then 
            killingSpreeMsg = textCreateTextItem(getClientName(attacker) .. " is on a killing spree!", 0.3, 0.5) 
            textDisplayAddText(killingSpreeDisplay, killingSpreeMsg) 
            textItemSetColor(killingSpreeMsg, 255, 255, 0, 180) 
            setTimer(textDisplayRemoveText, 5000, 1, killingSpreeMsg, killingSpreeDisplay) 
            sendClientMsg("* You get 5 granades for your 10 kills", attacker) 
            giveWeapon(attacker, 16, 5) 
        elseif (getElementData(attacker, "killingspree") == 15) then 
            killingSpreeMsg = textCreateTextItem(getClientName(attacker) .. " is unstoppable!", 0.3, 0.5) 
            textDisplayAddText(killingSpreeDisplay, killingSpreeMsg) 
            textItemSetColor(killingSpreeMsg, 255, 128, 64, 180) 
            sendClientMsg("* You get 5 more granades for your 15 kills", attacker) 
            giveWeapon(attacker, 16, 5) 
            setTimer(textDisplayRemoveText, 5000, 1, killingSpreeMsg, killingSpreeDisplay) 
        elseif (getElementData(attacker, "killingspree") == 20) then 
            killingSpreeMsg = textCreateTextItem(getClientName(attacker) .. " owned the entire server!", 0.3, 0.5) 
            textDisplayAddText(killingSpreeDisplay, killingSpreeMsg) 
            textItemSetColor(killingSpreeMsg, 200, 0, 0, 180) 
            setTimer(textDisplayRemoveText, 5000, 1, killingSpreeMsg, killingSpreeDisplay) 
            sendClientMsg("* You get 10 more granades for your 20 kills", attacker) 
            giveWeapon(attacker, 16, 10) 
        end 
        if (getElementData(source, "killingspree") > 5) then 
            sendClientMsgToAll("* " .. getClientName(attacker) .. " stopped " .. getClientName(source) .. " from doing " .. getElementData(source, "killingspree")+1 .. " straight kills!", "grey") 
        end 
        if(killingSpreeMsg) then 
            textItemSetScale(killingSpreeMsg, 5.0) 
        end 
    end 
    setElementData( source, "killingspree", 0 ) 
end 
addEventHandler("onPlayerWasted", getRootElement (), onPlayerDeath) 

I just can't understand whatìs whrong with this script... the killing spree textItems are displayed, but when they should disappear (after 5 secs) they don't and they stay there forever.... help?

ps: sendClientMsg and sendClientMsgToAll are my own functions and they work

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