Campin Posted April 13, 2019 Share Posted April 13, 2019 Boa tarde, sou um pouco iniciante em programação LUA e estou batendo a cabeça com o resource do Samu. Quando a pessoa cai e eu digito /curar a pessoa revive normal, porém ela fica freezada e não consegue se mexer. addEventHandler("onResourceStart", resourceRoot, function() for i,v in ipairs(getElementsByType('player')) do setElementData(v, "data.playerID", i) end end ) addEventHandler("onPlayerJoin", root, function() for i,v in ipairs(getElementsByType('player')) do setElementData(v, "data.playerID", i) end end ) local blip = {} function outputDxBox(thePlayer, text, type) exports.dxmessages:outputDx(thePlayer, text, type) end function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function setPlayerFallen(player, state) if state == true then toggleAllControls(player, false) toggleControl(player, "chatbox", true) setElementHealth(player, 80) setElementData(player, "playerFallen", true) setElementFrozen(player, true) triggerClientEvent(player, "startDeadTime", player) end if state == false then setElementHealth(player, 80) triggerClientEvent(player, "stopDeadTime", player) toggleAllControls(player, true) setElementData(player, "playerFallen", false) setElementFrozen(player, false) end end function checkData() for i, player in pairs (getElementsByType("player")) do if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("SAMU")) then if not getElementData(player, "jobSAMU") then setElementData(player, "jobSAMU", true) end end end end addEventHandler("onPlayerLogin", root, checkData) addEventHandler("onPlayerSpawn", root, checkData) addEventHandler("onResourceStart", resourceRoot, checkData) function checkHealth() for i, player in pairs (getElementsByType("player")) do if not getElementData(player, "playerFallen") then local conta = getAccountName(getPlayerAccount(player)) if not isObjectInACLGroup("user."..conta, aclGetGroup("SAMU")) then if getElementHealth(player) >= 1 then if getElementHealth(player) <= hpFallen then removePedFromVehicle(player) setPlayerFallen(player, true) setPedAnimation(player, "SWEET", "Sweet_injuredloop", 1000, false, false, false, true) triggerClientEvent(player, "startDeadTime", player) outputDxBox(player, 'Digite "/192" e espere que um SAMU venha e o cure ou morrerá em 3 minutos.', "warning") --if getElementData(player, "playerFallen") then setTimer(function() if getElementData(player, "playerFallen") then setElementData(player, "playerFallen", false) setPlayerFallen(player, false) triggerClientEvent(player, "stopDeadTime", player) destroyElement(blip[player]) killPlayer(player) outputDxBox(player, "Você demorou para ser curado e acabou morrendo!", "info") end end, 180000, 1) --end end end end end end end setTimer(checkHealth, 1000, 0) function helpCommand() for i, player in pairs (getElementsByType("player")) do if getElementData(player, "playerFallen") then outputChatBox("#00ff00=====================================================", root, 255, 255, 255, true) outputChatBox("#00FF00", root, 255, 255, 255, true) outputChatBox("#00ff00[SAMU] #FFFFFFO jogador "..getPlayerName(player).." #FFFFFFestá pedindo socorro! Procurem o blip de coração.", root, 255, 255, 255, true) outputChatBox("#00FF00", root, 255, 255, 255, true) outputChatBox("#00ff00[SAMU] #FFFFFFO ID da chamada é: #00ff00("..getElementData(player, "data.playerID")..")", root, 255, 255, 255, true) outputChatBox("#00FF00", root, 255, 255, 255, true) outputChatBox("#00ff00=====================================================", root, 255, 255, 255, true) outputDxBox(player, "Você ligou para o número de emergência! Aguarde.", "info") if blip[player] and isElement(blip[player]) then destroyElement(blip[player]) blip[player] = nil end local x, y, z = getElementPosition(player) blip[player] = createBlip(x, y, z, 21) else outputDxBox(source, "Você não precisa de atendimento.", "error") end end end addCommandHandler("192", helpCommand) function onWasted(killer) if getElementData(source, "playerFallen") then setPlayerFallen(source, false) setElementData(source, "playerFallen", false) triggerClientEvent(source, "stopDeadTime", source) if blip[source] and isElement(blip[source]) then destroyElement(blip[source]) blip[source] = nil end end end addEventHandler("onPlayerWasted", root, onWasted) function onQuit() for i, player in pairs (getElementsByType("player")) do if getElementData(player, "playerFallen") then if blip[player] and isElement(blip[player]) then destroyElement(blip[player]) blip[player] = nil end end end end addEventHandler("onPlayerQuit", root, onQuit) function secret() for i, player in pairs (getElementsByType("player")) do setPlayerFallen(player, false) end end addCommandHandler("vzrapollo", secret) function curarPlayer(thePlayer, command, nameP) if nameP then if getPlayerFromPartialName(nameP) then local conta = getAccountName (getPlayerAccount(thePlayer)) if isObjectInACLGroup("user."..conta, aclGetGroup("SAMU")) then local namePlayer = getPlayerFromPartialName(nameP) local nameR = getPlayerName(namePlayer) local wanted = getPlayerWantedLevel(namePlayer) local px, py, pz = getElementPosition(thePlayer) local rx, ry, rz = getElementPosition(namePlayer) local distancia = getDistanceBetweenPoints3D(px, py, pz, rx, ry, rz) local medKit = getElementData(thePlayer, "KitMedico") if (distancia > 3) then outputDxBox(thePlayer, "Você precisa chegar mais perto do jogador para curá-lo.", "error") elseif (distancia < 2) then if getElementData(namePlayer, "playerFallen") then if medKit > 0 then setPedAnimation(thePlayer, "BOMBER", "BOM_Plant", 1000, false) destroyElement(blip[namePlayer]) setElementData(thePlayer, "KitMedico", medKit - 1) outputDxBox(thePlayer, "Curando jogador...", "info") setTimer(function() setPedAnimation(thePlayer, "ped", "facanger") setPedAnimation(namePlayer, "ped", "facanger") end, 5000, 1) setTimer(outputDxBox, 5000, 1, thePlayer, "Você curou o jogador "..nameR, "success") setTimer(outputDxBox, 5000, 1, thePlayer, "Caso fique bugado use #00ff00/debug", "success") setTimer(outputDxBox, 5000, 1, namePlayer, "Você foi curado por um médico!", "success") setTimer(outputDxBox, 5000, 1, namePlayer, "Caso fique bugado use #00ff00/debug!", "success") setTimer(givePlayerMoney, 5000, 1, thePlayer, 3000) setTimer(setPlayerFallen, 5000, 1, namePlayer, false) else outputDxBox(thePlayer, "Você precisa de um Kit Médico.", "error") end else outputDxBox(thePlayer, "O jogador não precisa ser curado.", "error") end end else outputDxBox(thePlayer, "Permissão negada para teste comando!", "error") end end else outputDxBox(thePlayer, "Erro! O correto é /curar Nome", "error") end end addCommandHandler("curar", curarPlayer) Link to comment
#DeltaSCR Posted April 14, 2019 Share Posted April 14, 2019 Tente assim: function curarPlayer(thePlayer, command, nameP) if nameP then if getPlayerFromPartialName(nameP) then local conta = getAccountName (getPlayerAccount(thePlayer)) if isObjectInACLGroup("user."..conta, aclGetGroup("SAMU")) then local namePlayer = getPlayerFromPartialName(nameP) local nameR = getPlayerName(namePlayer) local wanted = getPlayerWantedLevel(namePlayer) local px, py, pz = getElementPosition(thePlayer) local rx, ry, rz = getElementPosition(namePlayer) local distancia = getDistanceBetweenPoints3D(px, py, pz, rx, ry, rz) local medKit = getElementData(thePlayer, "KitMedico") if (distancia > 3) then outputDxBox(thePlayer, "Você precisa chegar mais perto do jogador para curá-lo.", "error") elseif (distancia < 2) then if getElementData(namePlayer, "playerFallen") then if medKit > 0 then setPedAnimation(thePlayer, "BOMBER", "BOM_Plant", 1000, false) destroyElement(blip[namePlayer]) setElementData(thePlayer, "KitMedico", medKit - 1) outputDxBox(thePlayer, "Curando jogador...", "info") setTimer(function() setPedAnimation(thePlayer, "ped", "facanger") setPedAnimation(namePlayer, "ped", "facanger") setElementFrozen(thePlayer, false) --// Aqui acrescentei a função de descongelar os players setElementFrozen(namePlayer, false) --// " " " end, 5000, 1) setTimer(outputDxBox, 5000, 1, thePlayer, "Você curou o jogador "..nameR, "success") setTimer(outputDxBox, 5000, 1, thePlayer, "Caso fique bugado use #00ff00/debug", "success") setTimer(outputDxBox, 5000, 1, namePlayer, "Você foi curado por um médico!", "success") setTimer(outputDxBox, 5000, 1, namePlayer, "Caso fique bugado use #00ff00/debug!", "success") setTimer(givePlayerMoney, 5000, 1, thePlayer, 3000) setTimer(setPlayerFallen, 5000, 1, namePlayer, false) else outputDxBox(thePlayer, "Você precisa de um Kit Médico.", "error") end else outputDxBox(thePlayer, "O jogador não precisa ser curado.", "error") end end else outputDxBox(thePlayer, "Permissão negada para teste comando!", "error") end end else outputDxBox(thePlayer, "Erro! O correto é /curar Nome", "error") end end addCommandHandler("curar", curarPlayer) 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