Manticore Posted August 28, 2017 Share Posted August 28, 2017 Hey again, I want to fix killmessages for my server so that it shows hydra or hunter rocket kills on players inside a vehicle. When a rocket was fired at a car and my friend was in a car, it appears as if no one had killed him. (skull icon, just ''died'') here's photo: http://imgur.com/a/bSLbz Please help me! Link to comment
Moderators IIYAMA Posted August 28, 2017 Moderators Share Posted August 28, 2017 There is nothing wrong with your killmessage, it works as it should be. But if you want to take vehicle kills in account then you should do some research mate. Because vehicle blow-up kills do never count as a player kill, which is just the way gta works. I do not say that it is impossible to create it, but it requires a higher scripting level. If you want this: (or) Improve your script level, make some effort yourself and do some research. Hire a paid scripter. (high level) I hope I have informed you enough about this matter. Link to comment
Manticore Posted August 29, 2017 Author Share Posted August 29, 2017 On 28-8-2017 at 22:51, IIYAMA said: There is nothing wrong with your killmessage, it works as it should be. But if you want to take vehicle kills in account then you should do some research mate. Because vehicle blow-up kills do never count as a player kill, which is just the way gta works. I do not say that it is impossible to create it, but it requires a higher scripting level. If you want this: (or) Improve your script level, make some effort yourself and do some research. Hire a paid scripter. (high level) I hope I have informed you enough about this matter. I know, that isn't proplem. But i really want to fix it, and i just come here to ask someone if he have that script or text about player killed inside his car. and showing on killmessage. Is like shot rocket and player inside his car, then he blow up. is like i killed him without his car. Please help Link to comment
Moderators IIYAMA Posted August 29, 2017 Moderators Share Posted August 29, 2017 Why don't you try to solve it first? Link to comment
Manticore Posted August 29, 2017 Author Share Posted August 29, 2017 I try many times! And its doesn't work Please i need help I'm begging you Link to comment
Manticore Posted August 30, 2017 Author Share Posted August 30, 2017 Bruh, I just need help. No for give me the script man Link to comment
MTA Anti-Cheat Team Dutchman101 Posted September 10, 2017 MTA Anti-Cheat Team Share Posted September 10, 2017 I released a fixed version @Mohamed Asad that detects Hydra and hunter-on vehicle kills (with rocket as you described...) and some other types of kills. Get it here, https://community.multitheftauto.com/index.php?p=resources&s=details&id=14801 Anyways, clientside; local explosionVehicles = { [432] = true, [520] = true, [425] = true } local possibleKillers = {} local killerTimer = false 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 ) 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 ) else outputDebugString ( "outputKillMessage - Invalid 'killer' player 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 function getVehiclePassengerCount(vehicle) local n = 0 for _, v in pairs(getVehicleOccupants(vehicle)) do n = n + 1 end return n end function getNearbyVehicle(x, y, z) for _, vehicle in pairs(getElementsByType("vehicle", nil, true)) do local vx, vy, vz = getElementPosition(vehicle) local dist = getDistanceBetweenPoints3D(x, y, z, vx, vy, vz) if dist <= 10 and getVehiclePassengerCount(vehicle) > 0 then return vehicle end end end function tableCount(t) local n = 0 for _, v in pairs(t) do n = n + 1 end return n end addEventHandler("onClientExplosion", root, function(x, y, z, explosionType) -- Check if it is a rocket explosion and if rocket creator has hunter/hydra/rhino if getElementType(source) == "player" and (explosionType == 2 or explosionType == 10) and getPedOccupiedVehicle(source) and explosionVehicles[getElementModel(getPedOccupiedVehicle(source))] then local victimVehicle = getNearbyVehicle(x, y, z) if victimVehicle then -- Store occupants' possible killer only to occupants' client memory for _, occupant in pairs(getVehicleOccupants(victimVehicle)) do if occupant == localPlayer then if not killerTimer then killerTimer = setTimer(function() possibleKillers = {} end, 7000, 1) end if killerTimer and isTimer(killerTimer) then resetTimer(killerTimer) end possibleKillers = {} possibleKillers[getVehicleOccupants(victimVehicle)] = source end end end end end, nil, "high+10" ) addEventHandler("onClientVehicleDamage", root, function(attacker, weapon) -- Additionally check if weapon used to damage a vehicle was hunter minigun, which in that case, hunter is the real killer here if getVehiclePassengerCount(source) > 0 and attacker and getElementType(attacker) == "vehicle" and weapon == 38 and getElementModel(attacker) == 425 then for _, occupant in pairs(getVehicleOccupants(source)) do if occupant == localPlayer then if not killerTimer then killerTimer = setTimer(function() possibleKillers = {} end, 7000, 1) end if killerTimer and isTimer(killerTimer) then resetTimer(killerTimer) end possibleKillers = {} possibleKillers[getVehicleOccupants(source)] = getVehicleController(attacker) end end end -- Also check if killer had a rustler or rc baron if getVehiclePassengerCount(source) > 0 and attacker and getElementType(attacker) == "vehicle" and weapon == 31 and (getElementModel(attacker) == 464 or getElementModel(attacker) == 476) then for _, occupant in pairs(getVehicleOccupants(source)) do if occupant == localPlayer then if not killerTimer then killerTimer = setTimer(function() possibleKillers = {} end, 7000, 1) end if killerTimer and isTimer(killerTimer) then resetTimer(killerTimer) end possibleKillers = {} possibleKillers[getVehicleOccupants(source)] = getVehicleController(attacker) end end end end ) addEventHandler("onClientPlayerWasted", root, function(killer, weapon, bodypart) if source == localPlayer then if tableCount(possibleKillers) > 0 then local theKiller = false; for _, pkiller in pairs(possibleKillers) do theKiller = pkiller break end if theKiller then local veh = getPedOccupiedVehicle(theKiller); if veh then triggerServerEvent("outputKillFromClient", localPlayer, theKiller, getElementModel(veh)) end end if killerTimer and isTimer(killerTimer) then killTimer(killerTimer) end possibleKillers = {} end end end ) serverside; 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 KillMessages_onPlayerWasted(totalammo, killer, killerweapon, bodypart) local usedVehicle = nil local killerType = nil local killerweapon = killerweapon or 255 -- In very rare cases killer isn't nil or false but isn't an element. if (killer and not isElement(killer)) then killer = nil end if (killer) then killerType = getElementType(killer) end -- Sometimes the killer is returned as the driver instead of vehicle, like when driving a Rhino but we need the vehicle ID if (killerType == "player") then local vehicle = getPedOccupiedVehicle(killer) if (vehicle and getPedWeapon(killer) == 0) then usedVehicle = getElementModel(vehicle) end end -- Change the killer into the vehicle controller if (killer and killerType == "vehicle") then usedVehicle = getElementModel(killer) killer = getVehicleController(killer) or killer killerType = getElementType(killer) end -- If killed by rocket and was on foot player turn it into their current weapon if (killerweapon == 19 and killerType == "player" and not isPedInVehicle(killer)) then killerweapon = getPedWeapon(killer) or 51 end -- Got a killer? Print the normal "* X died" if not if (killer and killerType == "player") then local kr, kg, kb = getPlayerNametagColor(killer) if (getPlayerTeam(killer)) then kr, kg, kb = getTeamColor(getPlayerTeam(killer)) end -- Suicide? if (source == killer) then 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 if killerweapon ~= 63 then 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 end addEventHandler("onPlayerWasted", root, KillMessages_onPlayerWasted) addEvent ( "onPlayerKillMessage" ) function eventTriggered ( source,killer,weapon,bodypart,suicide,usedVehicle,ignoreExplosions ) --outputDebugString("after: source = " .. getElementType(source) .. "killer = " .. getElementType(killer) .. " weapon = " .. tostring(weapon) .. " bodypart = " .. tostring(bodypart) .. " suicide = " .. tostring(suicide) .. "usedVehicle = " .. tostring(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 addEvent("outputKillFromClient", true) addEventHandler("outputKillFromClient", root, function(killer, model) if source == client then --outputDebugString("before: client = " .. getElementType(client) .. " killer = " .. getElementType(killer).. " model = " .. tostring(model)) local triggered = triggerEvent("onPlayerKillMessage", client, killer, 19, nil) if (triggered) then eventTriggered(client, killer, 19, nil, false, model, true) end end 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(client,"doSetKillMessageStyle",client,config.startX,config.startY,config.alignX,config.lines,config.startFade,config.fadeTime) end ) @Mohamed Asad Today 22th september i fixed a few bugs in code (bad outputting aka wrong killfeed data) i suggest you update version (or just watch the community resource page i linked regularly) 1 Link to comment
Manticore Posted September 10, 2017 Author Share Posted September 10, 2017 Thank you very much its working fine!!!, But RPG doesnt show anything. And player need to finish his "Killmessage download" to see it. And Hydra+Rhino and other vehicle have missiles. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now