Big Smoker Posted January 31, 2018 Posted January 31, 2018 Boa Tarde estou tentando fazer uma função que quando jogador leve o dano de quem atirou e dar disconnect ele da o kill para quem atirou so que nao estou conseguindo podem me ajuda a ver a onde estou errando? addEventHandler ( "onPlayerQuit", getRootElement(), function (quitType,killer) if quitType == "Quit" or quitType == "Timed out" then local playerAccount = getPlayerAccount(source) if playerAccount and getElementData (source, "antiRelogWork") == true then setAccountData(playerAccount, "antiRelogWork", false) if killer then setElementData(killer,"murders",getElementData(killer,"murders")+1) outputDebugString("Player Killer") end end end end )
Moderators Lord Henry Posted February 1, 2018 Moderators Posted February 1, 2018 Não é possível matar o jogador que já desconectou. Mas você pode salvar no jogador que saiu do server o último jogador que deu dano nele. Então marque como +1 kill como data no jogador que estava marcado no momento em que este jogador desconectar. function saveAttacker (attacker, weapon, bodypart, loss) if attacker and getElementType (attacker) == "player" then -- Se o último dano recebido foi por um jogador, então: setElementData (source, "attacker", attacker) -- Salva o jogador que deu dano nele como data. elseif attacker and getElementType (attacker) == "vehicle" then -- Se o último dano recebido foi por um veículo, então: setElementData (source, "attacker", getVehicleController (attacker)) -- Salva o motorista do veículo como data. end end addEventHandler ("onPlayerDamage", getRootElement(), saveAttacker) function quitKill (quitType, reason, responsibleElement) local killer = getElementData (source, "attacker") -- Variável killer recebe o jogador que atacou por último este jogador que saiu do server. if isElement (killer) then -- Se o jogador que atacou por último ainda existe, então: local kills = getElementData (killer, "kills") -- Variável kills recebe a quantidade de kills deste jogador que atacou por último. if not kills then -- Se não há nenhuma kill, então é 0. kills = 0 end setElementData (killer, "kills", kills + 1) -- Adiciona mais uma kill no jogador que atacou por último e salva esse novo valor como data. end end addEventHandler ("onPlayerQuit", getRootElement(), quitKill) function removeLastAttacker (ammo, attacker, weapon, bodypart, stealth) -- Adiciona +1 kill no jogador que matou alguém. E remove o último atacante do jogador que morreu para evitar kill duplicada. if getElementData (source, "attacker") then setElementData (source, "attacker", false) end if attacker then if getElementType (attacker) == "vehicle" then attacker = getVehicleController (attacker) local kills = getElementData (attacker, "kills") if not kills then kills = 0 end setElementData (attacker, "kills", kills + 1) elseif getElementType (attacker) == "player" then local kills = getElementData (attacker, "kills") if not kills then kills = 0 end setElementData (attacker, "kills", kills + 1) end end end addEventHandler ("onPlayerWasted", getRootElement(), removeLastAttacker) Não cheguei a testar. Nos avise se der certo ou não. Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment Discord Oficial do MTA: https://mtasa.com/discord Blacklist e Whitelist de Scripters: Planilha Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.
Big Smoker Posted February 3, 2018 Author Posted February 3, 2018 Bom tive tempo só agora para ver a função, eu estou tentando entender a função que voce me deu como exemplo, a minha ideia é quando o jogador que recebeu o dano deslogar (quit), dar o kill para o jogador que atirou nele
Moderators Lord Henry Posted February 4, 2018 Moderators Posted February 4, 2018 On 01/02/2018 at 09:52, Lord Henry said: Nos avise se der certo ou não. Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment Discord Oficial do MTA: https://mtasa.com/discord Blacklist e Whitelist de Scripters: Planilha Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.
Big Smoker Posted February 4, 2018 Author Posted February 4, 2018 deu sim consegui fazer ele aqui voce pode me ajudar no meu outro tópico que eu criei ? sobre a altura? quer função devo usar
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