Jump to content

getPlayerName(killer) - error


stefutz101

Recommended Posts

addEventHandler("onPlayerWasted",root,function(_,killer) 
    local alivetime = getElementData(source,"alivetime") 
    local name = getPlayerName(killer) 
    if tonumber(alivetime)>3 then     
        outputChatBox("Playerul #ffffff"..name.."#ff0000 este suspectat de spawnkill!",root,255,0,0,true) 
    end 
end) 

Error at local name = getPlayerName(killer) . Please help :( TY

Link to comment

It should works, and be sure you did the setElementData of alivetime

addEventHandler("onPlayerWasted",root,function() 
    local alivetime = getElementData(source,"alivetime") 
    local name = getPlayerName(source) 
    if tonumber(alivetime)>3 then     
        outputChatBox("Playerul #ffffff"..name.."#ff0000 este suspectat de spawnkill!",root,255,0,0,true) 
    end 
end) 

Link to comment
addEventHandler("onPlayerWasted",root,function(killer) 
    local alivetime = getElementData(source,"alivetime") 
    if tonumber(alivetime)>3 then     
        outputChatBox("Playerul #ffffff"..getPlayerName(killer).."#ff0000 este suspectat de spawnkill!",root,255,0,0,true) 
    end 
end) 

Should work

Else check this out:

OnPlayerWasted

Link to comment

you've to check if killer isn't false.

addEventHandler( "onPlayerWasted", root, 
    function( _, killer ) 
        if killer and isElement ( killer ) and killer ~= source then 
            local alivetime = getElementData( source, "alivetime" ) 
            local name = getPlayerName( killer ) 
            if tonumber( alivetime ) > 3 then     
                outputChatBox( "Playerul #ffffff"..name.."#ff0000 este suspectat de spawnkill!", root, 255, 0, 0,true ) 
            end 
        end 
    end 
) 

Link to comment
  • 2 weeks later...
addEventHandler( "onPlayerWasted", root, 
    function( _, killer ) 
             
            local name = getPlayerName( killer ) 
            local alivetime = getElementData( playerSource, "alivetime" ) 
                if tonumber(alivetime) == nil then 
                    outputChatBox( "Playerul #ffffff"..getPlayerName(killer).."#ff0000 este suspectat de spawnkill!", root, 255, 0, 0,true ) 
                elseif tonumber (alivetime) <= 3 then 
                    outputChatBox( "Playerul #ffffff"..getPlayerName(killer).."#ff0000 este suspectat de spawnkill!", root, 255, 0, 0,true ) 
                end 
                     
    end 
) 
  

Attempting to compare number with boolean -- 7. What i must change ? I aleready try to put ..name..

Link to comment
Help , please ?
addEventHandler( "onPlayerWasted", root, 
    function( _, killer ) 
        if killer and getElementType(killer) == "player" and killer ~= source then 
            local alivetime = getElementData( source, "alivetime" ) or 0 
            local name = getPlayerName( killer ) 
            if tonumber( alivetime ) > 3 then     
                outputChatBox( "Playerul #ffffff"..name.."#ff0000 este suspectat de spawnkill!", root, 255, 0, 0,true ) 
            else 
                outputChatBox( "Playerul #ffffff"..name.."#ff0000 este suspectat de spawnkill!", root, 255, 0, 0,true ) 
            end 
        end 
    end 
) 

Link to comment
Help , please ?
addEventHandler( "onPlayerWasted", root, 
    function( _, killer ) 
        if killer and getElementType(killer) == "player" and killer ~= source then 
            local alivetime = getElementData( source, "alivetime" ) or 0 
            local name = getPlayerName( killer ) 
            if tonumber( alivetime ) > 3 then     
                outputChatBox( "Playerul #ffffff"..name.."#ff0000 este suspectat de spawnkill!", root, 255, 0, 0,true ) 
            else 
                outputChatBox( "Playerul #ffffff"..name.."#ff0000 este suspectat de spawnkill!", root, 255, 0, 0,true ) 
            end 
        end 
    end 
) 

Noting happen , and btw :

if tonumber( alivetime ) > 3 then     
                outputChatBox( "Playerul #ffffff"..name.."#ff0000 este suspectat de spawnkill!", root, 255, 0, 0,true ) 
            else 
                outputChatBox( "Playerul #ffffff"..name.."#ff0000 este suspectat de spawnkill!", root, 255, 0, 0,true ) 
            end 

thats wrong because if player have more than 3 minutes will show is spawnkill :D I can fix that but i dont under stand why dont enter in first if , i think it's wrong this script to get player name

Link to comment

Alivetime , is saved in MTA DayZ resources . First time i think too , but i made a command to see my alivetime and it work . I want to make a script what show a mesage on global chat ( x made spawnkill on y.) if y had under 3 minutes of life . Some players stay at spawn and kill players when they spawned.

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