magnux Posted April 11, 2018 Share Posted April 11, 2018 (edited) Pessoal não consigo termina esse trampo coloquei um comando para digita /s e nick, sem código para executar uma função de da Health a outro player Mais quando eu digito o comando /s nick, Ele só executa a função da Animação, e a de dar vida não funciona, AJUDEM AI ! -- server addCommandHandler ("s", function (thePlayer, command, Jogador) accountname = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup("user." .. accountname, aclGetGroup("SAMU")) then triggerClientEvent(thePlayer, "SAMU", getRootElement()) setPedAnimation(thePlayer, "medic", "CPR") if not hasObjectPermissionTo(thePlayer, "command.slap", false) then outputChatBox ( "Você não pode usar este comando", source ) return false end local targetPlayer = getPlayerFromName ( Jogador ):gsub("#%x%x%x%x%x%x", "") if targetPlayer then setElementHealth ( targetPlayer, getElementHealth(targetPlayer) + 100 ) else outputChatBox ( "Não há nenhum jogador chamado " .. Jogador .. "!", source ) end end end) Edited April 11, 2018 by magnux Link to comment
DNL291 Posted April 12, 2018 Share Posted April 12, 2018 Isso não seria um sistema de médico? Tente isto: addCommandHandler ("s", function (thePlayer, command, Jogador) local accountname = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup("user." .. accountname, aclGetGroup("SAMU")) then if Jogador then local targetPlayer = getPlayerFromName ( Jogador:gsub("#%x%x%x%x%x%x", "") ) else return outputChatBox ( "Sintaxe incorreta! /"..command.." <nome_do_jogador>", thePlayer ) end if targetPlayer then setElementHealth ( targetPlayer, getPedMaxHealth(targetPlayer) ) triggerClientEvent(thePlayer, "SAMU", thePlayer) setPedAnimation(thePlayer, "medic", "CPR") outputChatBox ( "Você foi curado por "..getPlayerName(thePlayer).." !", targetPlayer ) outputChatBox ( "Você curou o jogador "..getPlayerName(targetPlayer).." !", thePlayer ) else outputChatBox ( "Não há nenhum jogador chamado " .. Jogador .. "!", thePlayer ) end else outputChatBox ( "Você não pode usar este comando", thePlayer ) end end) function getPedMaxHealth(ped) -- Output an error and stop executing the function if the argument is not valid assert(isElement(ped) and (getElementType(ped) == "ped" or getElementType(ped) == "player"), "Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got " .. tostring(ped) .. "]") -- Grab his player health stat. local stat = getPedStat(ped, 24) -- Do a linear interpolation to get how many health a ped can have. -- Assumes: 100 health = 569 stat, 200 health = 1000 stat. local maxhealth = 100 + (stat - 569) / 4.31 -- Return the max health. Make sure it can't be below 1 return math.max(1, maxhealth) end 2 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