Jump to content

getPlayerName(killer) - error


stefutz101

Recommended Posts

Posted
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

560x95_FFFFFF_B7FF00_000000_000000.png
Posted

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) 

Posted

Yes , it works but dont work correclty . I want to create this script to output in chatbox who make spawnkill . If someone kill me when i dont have 3 minutes nothing happen . If i use /kill will show " Player stefutz101 is suspect for spawnkill "

560x95_FFFFFF_B7FF00_000000_000000.png
Posted
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

Computer science student at { EPITECH }

Posted

Attempting to concatenate a boolean value outputChatBox("Playerul #ffffff"..getPlayerName(killer).."#ff0000 este suspectat de spawnkill!",root,255,0,0,true) :(

I already tested this version but i test again .

560x95_FFFFFF_B7FF00_000000_000000.png
Posted

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 
) 

  • 2 weeks later...
Posted
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..

560x95_FFFFFF_B7FF00_000000_000000.png
Posted
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 
) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
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

560x95_FFFFFF_B7FF00_000000_000000.png
Posted

i don't undrestand nothing explaine your problem better there is no timer in your code.

also 3 minutes = 180000 milliseconds you can't use the number 3

show me the code where you stored the elementData "alivetime".

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

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.

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