Jump to content

Kill Messages


DarkByte

Recommended Posts

How i can make to draw a hydra when i kill someone instead of punch or ped weapon. And when a player its in a vehicle and i kill him with hydra it shows that he blown himself or suicide. Or with such vehicle rockets

Server

local config = { 
["lines"] = 5, 
["startY"] = 0.35, 
["textHeight"] = 16, 
["iconHeight"] = 20, 
["iconSpacing"] = 4, 
["defaultWeapon"] = 255, 
["fadeTime"] = 5000, 
["startFade"] = 15000, 
["align"] = "right", 
["startX"] = -10 
} 
local default = { 
["lines"] = 5, 
["startY"] = 0.25, 
["textHeight"] = 16, 
["iconHeight"] = 20, 
["iconSpacing"] = 4, 
["defaultWeapon"] = 255, 
["fadeTime"] = 5000, 
["startFade"] = 15000, 
["align"] = "right", 
["startX"] = -10 
} 
  
function playerWasted ( ammo, attacker, weapon, bodypart ) 
     if vehicleIDs[weapon]  then --- if the player drowned 
          outputChatBox(""..getPlayerName(attacker).."killed "..source..",with weapon "..weapon.."") 
     end 
end 
addEventHandler("onPlayerWasted", getRootElement(), playerWasted) 
  
  
local vehicleIDs = { 
    [19] = true, 
    [37] = true, 
    [49] = true, 
    [50] = true, 
    [51] = true, 
    [52] = true, 
    [53] = true, 
    [54] = true, 
    [55] = true, 
    [56] = true, 
    [57] = true, 
    [59] = true, 
    [63] = true 
} 
function KillMessages_onPlayerWasted ( totalammo, killer, killerweapon, bodypart ) 
    ---These are special checks for certain kill types 
    local usedVehicle 
    if killerweapon == 19 and isElement(killer) then --rockets 
        killerweapon = killer and getElementType ( killer ) == "player" and getPedWeapon(killer) 
        if not killerweapon then 
            killerweapon = 51 
        end 
    elseif vehicleIDs[killerweapon] then --heliblades/rammed 
        if ( isElement(killer) and getElementType ( killer ) == "vehicle" ) then 
            usedVehicle = getElementModel ( killer ) 
            killer = getVehicleOccupant ( killer, 0 ) 
        end 
    elseif ( killerweapon == 59 or killerweapon == 19 or killerweapon == 21 and isElement(killer) ) then 
        if ( getElementType ( killer ) == "player" ) then 
            local vehicle = getPedOccupiedVehicle(killer) 
            if ( vehicle ) then 
                usedVehicle = getElementModel ( vehicle ) 
            end 
        end 
    end 
    --finish this 
    -- Got a killer? Print the normal "* X died" if not 
    if ( killer and isElement(killer) and getElementType ( killer ) == "player" ) then 
        local kr,kg,kb = getPlayerNametagColor  ( killer ) 
        if getPlayerTeam ( killer ) then 
            kr,kg,kb = getTeamColor ( getPlayerTeam ( killer ) ) 
        end 
        -- Suicide? 
        if (source == killer) then 
            if not killerweapon then killerweapon = 255 end 
            local triggered = triggerEvent ( "onPlayerKillMessage", source,false,killerweapon,bodypart ) 
            --outputDebugString ( "Cancelled: "..tostring(triggered) ) 
            if ( triggered ) then 
                eventTriggered ( source,false,killerweapon,bodypart,true,usedVehicle) 
                return 
            end 
        end 
        local triggered = triggerEvent ( "onPlayerKillMessage", source,killer,killerweapon,bodypart ) 
                --outputDebugString ( "Cancelled: "..tostring(triggered) ) 
        if ( triggered ) then 
            eventTriggered ( source,killer,killerweapon,bodypart,false,usedVehicle) 
        end 
    else 
        local triggered = triggerEvent ( "onPlayerKillMessage", source,false,killerweapon,bodypart ) 
        --outputDebugString ( "Cancelled: "..tostring(triggered) ) 
        if ( triggered ) then 
            eventTriggered ( source,false,killerweapon,bodypart,false,usedVehicle) 
        end 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), KillMessages_onPlayerWasted ) 
  
addEvent ( "onPlayerKillMessage" ) 
function eventTriggered ( source,killer,weapon,bodypart,suicide,usedVehicle ) 
    local wr,wg,wb = getPlayerNametagColor  ( source ) 
    if getPlayerTeam ( source ) then 
        wr,wg,wb = getTeamColor ( getPlayerTeam ( source ) ) 
    end 
    local kr,kg,kb = false,false,false 
    if ( killer ) then 
        kr,kg,kb = getPlayerNametagColor    ( killer ) 
        if getPlayerTeam ( killer ) then 
            kr,kg,kb = getTeamColor ( getPlayerTeam ( killer ) ) 
        end 
    end 
    if ( usedVehicle ) then 
        weapon = usedVehicle 
    end 
    outputKillMessage ( source, wr,wg,wb,killer,kr,kg,kb,weapon ) 
    -- 
    local extra = "" 
    if ( usedVehicle ) then 
    extra = " (Vehicle)" 
    end 
    if ( killer ) then 
        if suicide then 
            local weaponName = getWeaponNameFromID ( weapon ) 
            if weaponName then 
                outputConsoleKillMessage ( "* "..getPlayerName(source).." killed himself. ("..weaponName..")" ) 
            else 
                outputConsoleKillMessage ( "* "..getPlayerName(source).." killed himself."..extra ) 
            end 
        else 
            local weaponName = getWeaponNameFromID ( weapon ) 
            if weaponName then 
                outputConsoleKillMessage ( "* "..getPlayerName(killer).." killed "..getPlayerName(source)..". ("..weaponName..")" ) 
            else 
                outputConsoleKillMessage ( "* "..getPlayerName(killer).." killed "..getPlayerName(source).."."..extra ) 
            end 
        end 
    else 
        outputConsoleKillMessage ( "* "..getPlayerName(source).." died."..extra ) 
    end 
    -- 
end 
  
function outputConsoleKillMessage ( text ) 
    outputConsole ( text ) 
end 
  
function outputKillMessage ( killed, wr,wg,wb,killer,kr,kg,kb,weapon,width,resource ) 
    if ( resource ) then resource = getResourceName(resource) end 
    if not isElement(killed) then 
        outputDebugString ( "outputKillMessage - Invalid 'wasted' player specified",0,0,0,100) 
        return false 
    end 
    if not getElementType(killed) == "player" then 
        outputDebugString ( "outputKillMessage - Invalid 'wasted' player specified",0,0,0,100) 
        return false 
    end 
    return triggerClientEvent(getRootElement(),"onClientPlayerKillMessage",killed,killer,weapon,wr,wg,wb,kr,kg,kb,width,resource ) 
end 
  
function outputMessage ( message, visibleTo, r, g, b, font ) 
    if type(message) ~= "string" and type(message) ~= "table" then 
        outputDebugString ( "outputMessage - Bad 'message' argument", 0, 112, 112, 112 )  
        return false  
    end 
    if not isElement(visibleTo) then  
        outputDebugString ( "outputMessage - Bad argument", 0, 112, 112, 112 )  
        return false  
    end 
    --Turn any resources into resource names 
    if type(message) == "table" then 
        for i,part in ipairs(message) do 
            if type(part) == "table" and part[1] == "image" then 
                if part.resource then 
                    message[i].resourceName = getResourceName(part.resource) 
                else 
                    part.resourceName = getResourceName(sourceResource) 
                end 
            end 
        end 
    end 
    return triggerClientEvent ( visibleTo, "doOutputMessage", visibleTo, message, r, g, b, font ) 
end 
  
function setKillMessageStyle ( startX,startY,align,lines,fadeStart,fadeAnimTime ) 
    if ( not startX ) then startX = default.startX end 
    if ( not startY ) then startY = default.startY end 
    if ( not align ) then startY = align.startY end 
    if ( not lines ) then lines = default.lines end 
    if ( not fadeStart ) then fadeStart = default.startFade end 
    if ( not fadeAnimTime ) then fadeAnimTime = default.fadeTime end 
    config.startX = startX 
    config.startY = startY 
    config.align = align 
    config.lines = lines 
    config.startFade = fadeStart 
    config.fadeTime = fadeAnimTime 
    for k,v in ipairs(getElementsByType"player") do 
        triggerClientEvent(v,"doSetKillMessageStyle",v,config.startX,config.startY,config.alignX,config.lines,config.startFade,config.fadeTime) 
    end 
    return true 
end 
  
addEvent ("onClientKillmessagesLoaded",true) 
addEventHandler ( "onClientKillmessagesLoaded", getRootElement(), 
function() 
    triggerClientEvent(source,"doSetKillMessageStyle",source,config.startX,config.startY,config.alignX,config.lines,config.startFade,config.fadeTime) 
end ) 
  

Client

addEvent ("onClientPlayerKillMessage",true) 
function onClientPlayerKillMessage ( killer,weapon,wr,wg,wb,kr,kg,kb,width,resource ) 
    if wasEventCancelled() then return end 
    outputKillMessage ( source, wr,wg,wb,killer,kr,kg,kb,weapon,width,resource ) 
end 
addEventHandler ("onClientPlayerKillMessage",getRootElement(),onClientPlayerKillMessage) 
  
function outputKillMessage ( source, wr,wg,wb,killer,kr,kg,kb,weapon,width,resource ) 
    if not iconWidths[weapon] then  
        if type(weapon) ~= "string" then 
            weapon = 999  
        end 
    end 
    local killerName 
    local wastedName 
    if not tonumber(wr) then wr = 255 end 
    if not tonumber(wg) then wg = 255 end 
    if not tonumber(wb) then wb = 255 end 
    if not tonumber(kr) then kr = 255 end 
    if not tonumber(kg) then kg = 255 end 
    if not tonumber(kb) then kb = 255 end 
    if ( source ) then 
        if isElement ( source ) then 
            if getElementType ( source ) == "player" then  
                wastedName = getPlayerName ( source ) 
            elseif getElementType ( source ) == "ped" and getElementType ( source ) ~= "player" then 
                wastedName = "Simulation" 
            else  
            outputDebugString ( "outputKillMessage - Invalid 'wasted' player specified",0,0,0,100) 
            return false end 
        elseif type(source) == "string" then 
            wastedName = source 
        end 
    else  
        outputDebugString ( "outputKillMessage - Invalid 'wasted' player specified",0,0,0,100) 
    return false end 
    if ( killer ) then 
        if isElement ( killer ) then 
            if getElementType ( killer ) == "player" then 
                killerName = getPlayerName ( killer ) 
            elseif getElementType ( killer ) == "ped" then 
                killerName = "Simulation" 
            else  
                outputDebugString ( "outputKillMessage - Invalid 'killer' player or ped specified",0,0,0,100) 
            return false end 
        elseif type(killer) == "string" then 
            killerName = killer 
        else 
            killerName = "" 
        end 
    else killerName = "" end 
    --create the new text 
    if not killerName then 
        killerName = "" 
    end 
    return outputMessage ( {killerName, {"padding",width=3}, {"icon",id=weapon}, 
        {"padding",width=3},{"color",r=wr,g=wg,b=wb}, wastedName}, 
        kr,kg,kb ) 
end 
  

Definitions

iconWidths = { 
[0] = 21,
[1] = 15,
[2] = 97,
[3] = 55,
[4] = 83,
[5] = 72,
[6] = 55,
[7] = 138,
[8] = 127,
[9] = 59,
[10] =40 ,
[11] =31 ,
[12] =41 ,
[14] =10 ,
[15] =71 ,
[16] =15 ,
[17] =10 ,
[18] =4 ,
[19] =17,
[22] =28 ,
[21] =63 ,
[20] =61 ,
[23] =55 ,
[24] =34 ,
[25] =79 ,
[26] =52 ,
[27] =80 ,
[28] =36 ,
[29] =48 ,
[30] =61 ,
[31] =74 ,
[32] =22 ,
[33] =101 ,
[34] =90 ,
[35] =74 ,
[36] =66 ,
[37] =19 ,
[38] =75 ,
[39] =20,
[42] = 14,
[49] = 86
[50] = 34
[51] = 24,
[59] =61 ,
[53] = 22
[54] = 15
[63] = 24,
[255] = 17,
[256] = 20,
[406] = 42,
[408] = 47,
[416] = 46,
[417] = 33,
[423] = 31,
[424] = 39,
[427] = 52,
[428] = 43,
[429] = 51,
[432] = 63,
[433] = 56,
[434] = 45,
[441] = 50,
[443] = 49,
[448] = 31,
[457] = 26,
[460] = 50,
[462] = 27,
[463] = 37,
[464] = 43,
[468] = 36,
[470] = 49,
[471] = 30,
[476] = 49,
[480] = 66,
[485] = 45,
[486] = 39,
[508] = 45,
[511] = 49,
[512] = 37,
[513] = 48,
[520] = 61,
[524] = 41,
[528] = 49,
[530] = 27,
[531] = 40,
[532] = 42,
[539] = 46,
[564] = 48,
[568] = 47,
[571] = 41,
[572] = 32,
[573] = 37,
[574] = 30,
[578] = 37,
[588] = 35,
[593] = 40,
[599] = 43,
[601] = 48,
--
[400]=36,
[401]=36,
[402]=36,
[403]=36,
[404]=36,
[405]=36,
[409]=36,
[410]=36,
[411]=36,
[412]=36,
[413]=36,
[415]=36,
[418]=36,
[419]=36,
[420]=36,
[421]=36,
[422]=36,
[426]=36,
[435]=36,
[436]=36,
[438]=36,
[439]=36,
[445]=36,
[449]=36,
[450]=36,
[451]=36,
[458]=36,
[466]=36,
[467]=36,
[474]=36,
[475]=36,
[477]=36,
[478]=36,
[479]=36,
[489]=36,
[490]=36,
[491]=36,
[492]=36,
[494]=36,
[495]=36,
[496]=36,
[500]=36,
[503]=36,
[504]=36,
[505]=36,
[506]=36,
[507]=36,
[516]=36,
[517]=36,
[518]=36,
[525]=36,
[526]=36,
[527]=36,
[529]=36,
[533]=36,
[534]=36,
[535]=36,
[536]=36,
[540]=36,
[541]=36,
[542]=36,
[543]=36,
[545]=36,
[546]=36,
[547]=36,
[549]=36,
[550]=36,
[551]=36,
[552]=36,
[554]=36,
[555]=36,
[558]=36,
[559]=36,
[560]=36,
[561]=36,
[562]=36,
[565]=36,
[566]=36,
[567]=36,
[575]=36,
[576]=36,
[579]=36,
[580]=36,
[583]=36,
[584]=36,
[585]=36,
[587]=36,
[589]=36,
[591]=36,
[594]=36,
[600]=36,
[602]=36,
[603]=36,
[604]=36,
[605]=36,
[606]=36,
[607]=36,
[608]=36,
[610]=36,
[611]=36,
--
[431]=44,
[437]=44,
[430]=61,
[446]=61,
[452]=61,
[453]=61,
[454]=61,
[472]=61,
[473]=61,
[484]=61,
[493]=61,
[595]=61,
[414]=37,
[456]=37,
[498]=37,
[499]=37,
[609]=37,
[440]=46,
[459]=46,
[482]=46,
[483]=46,
[582]=46,
[447]=39,
[469]=39,
[487]=42,
[488]=42,
[497]=42,
[548]=42,
[563]=42,
[465]=32,
[501]=32,
[481]=30,
[509]=30,
[510]=30,
[514]=46,
[515]=46,
[461]=35,
[521]=35,
[522]=35,
[523]=35,
[581]=35,
[586]=35,
[537]=41,
[569]=41,
[570]=41,
[590]=41,
[407]=55,
[544]=55,
Link to comment

I believe, you just have to change the definitions file.

To draw hunter icon when you killed player with your fist.

In definitions.lua, under icons tables,

Change this line

  
[0] =  "icons/fist.png" 
  

to

  
[0] =  "icons/hunter.png" -- actually fist 
  

And you are done. :)

Adding a comment isn't necessary but will help you getting the originals one's(and changing them again) faster.

Link to comment
And when i will kill with punch it will show hunter thats logic.

That's not logic. logically, It SHOULD show punch Icon but WILL show hunter Icon as I have edited it.

I gave you the example to show how it is done and I expect you to edit the script as per your needs.

If that is not what you asked then can you explain what you actually want?

Link to comment

Can some one tell me what to use Or What To Edit i can do any thing please help ? it should Draw Hunter Image and Hydra image if i killed by hunter or hydra but it draw punch or victim killed himself , and i have the hunter and hydra images Hunter.png , 520.png (HYDRA)

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