Jump to content

[AJUDA] Samu por ID (Script ID)


Recommended Posts

ola eu sou o novato na área de Scripter e baixei um mod de samu q levanta as pessoas pelo nick delas, só q eu gostaria q  levanta-se por ID e não por nome, as pessoas caidas . Vcs pode me ajudar?

 

hpMin = 15
Tempo = {}
ColMedic = {}

função getPlayerFromPartialName (nome) nome
    local = nome e nome: gsub ("#% x% x% x% x% x% x", ""): lower () ou nenhum
    nome
        para _, player em ipairs (getElementsByType (" player "))
            local name_ = getPlayerName (player): gsub (" #% x% x% x% x% x% x "," "): lower ()
            if name_: find (name, 1, true), em seguida,
                retornar jogador
            end
        end
    end
end    

Uma função ChecarVida ()
    para i, player em pares (getElementsByType ("player"))
        não faz getElementData (player, "PlayerCaido") e então
            conta local = getAccountName (getPlayerAccount (player)) e
                getElementHealth (player)> = 1 e
                    se getElementHealth (player) <= hpMin e 
                        removePedFromVehicle (player)
                        setElementData (player, "PlayerCaido", true)
                        setElementFrozen (player, true)
                        setPedAnimation (player, "CRACK", "crckdeth3", 1, false, true, false)
                        setTimer (função ()
                            if getElementData (player, "PlayerCaido") então    
                                killPlayer (player)
                            end
                        end, 240000, 1)
                end
            end
        else
            setPedAnimation (player, "CRACK", "crckdeth3", 1, false, true, false)
        fim
    end
end end
setTimer ( ChecarVida, 200, 0)

A função ChecarVidaA ()
    para i, player em pares (getElementsByType ("player"))
        torna-se getElementData (player, "PlayerCaido") e
        contém local = getAccountName (getPlayerAccount (player)) e
            getElementHealth (player)> = 31 e
                setElementData ( player, "PlayerCaido", false)
                setPedAnimation (player, false)
                setElementFrozen (player, false)
            fim
        final
    fim
final
setTimer (ChecarVidaA, 200, 0)

função SetarCaidoComHS ()
    player = origem,
    não getElementData (player, "PlayerCaido") e
        removePedFromVehicle (player)
        setElementHealth (player, 20)
        setElementData (player, "PlayerCaido", true)
        setPedAnimation (player, "CRACK", "crckdeth3", 1, falso, verdadeiro, falso)
        setTimer (function ()
            if getElementData (player, "PlayerCaido") e    
                killPlayer (player)
            end
        end, 240000, 1)
    end
end
addEvent ("OnHS", true)
addEventHandler ("OnHS", getRootElement (), SetarCaidoComHS)

Função curar_jogador (theplayer, Comando, nick)
    e
        se getPlayerFromPartialName (nick) e
            locais AccName = getAccountName (getPlayerAccount (theplayer))
            se isObjectInACLGroup ( "usuário." .. AccName, aclGetGroup ( "Samu")) e
                player_a_ser_curado locais getPlayerFromPartialName (entalhe )
                Samux local, Samuy, samuz = getElementPosition (theplayer)
                lOCAIS curadox, curadoy, curadoz = getElementPosition (player_a_ser_curado)
                lOCAIS dist = getDistanceBetweenPoints3D (Samux, Samuy, samuz, curadox, curado, curadoz)
                se player_a=er_do_campo
                    outputChatBox ( "# bebebeVocê Não PODE SE Curar!", theplayer, 255,255,255, true)
                    retorno
                acabar
                se (dist> 3) ENTÃO
                outputChatBox ( "# bebebeChegue Mais Perto fazer jogador!", theplayer, 255, 255, 255, true)
                elseif (dist <3)
                setPedAnimation (thePlayer, "MEDIC", "CPR", 4500, true, false, false, false)
                setTimer (function ()
                    setElementHealth (player_a_ser_curado, 100)
                    setPedAnimation (player_a_ser_curado, false)
                    setElementFrozen (player_a_ser_curado,)
                    setElementData (player_a_ser_curado, "PlayerCaido", false)
                end, 4500, 1)    
                end        
            end
        end
    end
end end end end
addCommandHandler ("curar", curar_jogador)

Edited by danielpaulino
Link to comment

tipo eu tenho o sistema de ID ja, mas como eu vou saber a data do ID do jogador?

hpMin = 15
Tempo = {}
ColMedic = {}

function getElementData (id)
    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 ChecarVida()
	for i, player in pairs (getElementsByType("player")) do
		if not getElementData(player, "PlayerCaido") then
			local conta = getAccountName(getPlayerAccount(player))
				if getElementHealth(player) >= 1 then
					if getElementHealth(player) <= hpMin then 
						removePedFromVehicle(player)
						setElementData(player, "PlayerCaido", true)
						setElementFrozen(player, true)
						setPedAnimation(player, "CRACK", "crckdeth3", 1, false, true, false)
						setTimer(function()
							if getElementData(player, "PlayerCaido") then	
								killPlayer(player)
							end
						end, 240000, 1)
				end
			end
		else
			setPedAnimation(player, "CRACK", "crckdeth3", 1, false, true, false)
		end
	end
end
setTimer(ChecarVida, 200, 0)

function ChecarVidaA()
	for i, player in pairs (getElementsByType("player")) do
		if  getElementData(player, "PlayerCaido") then
		local conta = getAccountName(getPlayerAccount(player))
			if getElementHealth(player) >= 31 then
				setElementData(player, "PlayerCaido", false)
				setPedAnimation(player, false)
				setElementFrozen(player, false )
			end
		end
	end
end
setTimer(ChecarVidaA, 200, 0)

function SetarCaidoComHS()
	player = source
	if not getElementData(player, "PlayerCaido") then
		removePedFromVehicle(player)
		setElementHealth(player, 20)
		setElementData(player, "PlayerCaido", true)
		setPedAnimation(player, "CRACK", "crckdeth3", 1, false, true, false)
		setTimer(function()
			if getElementData(player, "PlayerCaido") then	
				killPlayer(player)
			end
		end, 240000, 1)
	end
end
addEvent("OnHS", true)
addEventHandler("OnHS", getRootElement(), SetarCaidoComHS)

function curar_jogador ( thePlayer, comando, nick )
    if nick then
        if getElementData ( id ) then
            local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
            if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Samu") ) then
				local player_a_ser_curado    =   getElementData ( id )
				local samux, samuy, samuz = getElementPosition ( thePlayer )
				local curadox, curadoy, curadoz = getElementPosition ( player_a_ser_curado )
				local dist = getDistanceBetweenPoints3D ( samux, samuy, samuz, curadox, curadoy, curadoz )
				if player_a_ser_curado == thePlayer then
					outputChatBox("#bebebeVocê não pode se curar!",thePlayer,255,255,255,true)
					return
				end
				if ( dist > 3 )  then
				outputChatBox("#bebebeChegue mais perto do jogador!", thePlayer, 255, 255, 255, true)
				elseif ( dist < 3 )then
				setPedAnimation( thePlayer, "MEDIC", "CPR", 4500, true, false, false, false)
				setTimer ( function()
					setElementHealth ( player_a_ser_curado, 100 )
					setPedAnimation(player_a_ser_curado, false)
					setElementFrozen( player_a_ser_curado, false )
					setElementData(player_a_ser_curado,"PlayerCaido",false)
				end, 4500, 1 )	
				end		
			end
		end
	end
end
addCommandHandler ( "curar", curar_jogador )

Assim?

 

 

Edited by danielpaulino
Link to comment

 O sistema de ID q eu uso é esse

function Start_Id ( _, acc )
	if eventName == "onPlayerLogin" then
		setElementData ( source, "ID", getAccountID(acc) or "N/A" )
		--outputChatBox ( "#00ff00✘ #ffffffLOGIN #00ff00✘➺ #ffffffNick: #00ff00 ( ".. getPlayerName(source) .." #00ff00) #ffffffID: #00ff00( "..(getAccountID(acc) or "N/A") .." )", root, 255,255,255,true)
	elseif eventName == "onPlayerLogout" then
		removeElementData( source, "ID" )
		--outputChatBox ( "#00ff00✘ #ffffffLOGIN #00ff00✘➺ #ffffffNick: #00ff00 ( ".. getPlayerName(source) .." #00ff00) #ffffffDeslogou.", root, 255,255,255,true)
	elseif eventName == "onResourceStart" then
		for _, player in pairs(getElementsByType("player")) do
			local acc = getPlayerAccount(player)
			if not isGuestAccount(acc) then
				setElementData( source, "ID", getAccountID(acc) or "N/A" )
			end
		end
	end
end
addEventHandler("onResourceStart", resourceRoot, Start_Id)
addEventHandler("onPlayerLogout", root, Start_Id)
addEventHandler("onPlayerLogin", root, Start_Id)

function getPlayerID(id)
	v = false
	for i, player in ipairs (getElementsByType("player")) do
		if getElementData(player, "ID") == id then
			v = player
			break
		end
	end
	return v
end
--============================================================================================================================--
                                   --=============================--
                                   ----------- ID PLAYER ------------
                                   --=============================--
function getnick(player, command, id, ...)
    if(id) then
        local playerID = tonumber(id)
		if(playerID) then
			local Player2 = getPlayerID(playerID)
			if(Player2) then	
				outputChatBox ( "#00ff00✘ #ffffffINFO #00ff00✘➺ #ffffff Nome do Jogador #00ff00" .. getPlayerName(Player2) .."", player, 255,255,255,true)
			else
				outputChatBox ( "#00ff00✘ #ffffffERRO #00ff00✘➺ #ffffff O Jogador(a) de ID: #00ff00( " .. id .. " ) #ffffffNão Foi Encontrado!", player, 255,255,255,true)
			end 
		else
			outputChatBox ( "#00ff00✘ #ffffffERRO #00ff00✘➺ #ffffff ID: #00ff00( " .. id .. " ) #ffffffInválido!", player, 255,255,255,true)
		end
	else
		outputChatBox ( "#00ff00✘ #ffffffERRO #00ff00✘➺ #ffffffUse /id #00ff00[#ffffffID#00ff00]", player, 255,255,255,true)
	end
end
addCommandHandler("id", getnick)

 

Link to comment
  • Moderators

Tente isto:


hpMin = 15
Tempo = {}
ColMedic = {}

function getPlayerID(id)
	v = false
	for i, player in ipairs (getElementsByType("player")) do
		if getElementData(player, "ID") == id then
			v = player
			break
		end
	end
	return v
end
--====

function ChecarVida()
	for i, player in pairs (getElementsByType("player")) do
		if not getElementData(player, "PlayerCaido") then
			local conta = getAccountName(getPlayerAccount(player))
				if getElementHealth(player) >= 1 then
					if getElementHealth(player) <= hpMin then 
						removePedFromVehicle(player)
						setElementData(player, "PlayerCaido", true)
						setElementFrozen(player, true)
						setPedAnimation(player, "CRACK", "crckdeth3", 1, false, true, false)
						setTimer(function()
							if getElementData(player, "PlayerCaido") then	
								killPed(player)
							end
						end, 240000, 1)
				end
			end
		else
			setPedAnimation(player, "CRACK", "crckdeth3", 1, false, true, false)
		end
	end
end
setTimer(ChecarVida, 200, 0)

function ChecarVidaA()
	for i, player in pairs (getElementsByType("player")) do
		if  getElementData(player, "PlayerCaido") then
		local conta = getAccountName(getPlayerAccount(player))
			if getElementHealth(player) >= 31 then
				setElementData(player, "PlayerCaido", false)
				setPedAnimation(player, false)
				setElementFrozen(player, false )
			end
		end
	end
end
setTimer(ChecarVidaA, 200, 0)

function SetarCaidoComHS()
	player = source
	if not getElementData(player, "PlayerCaido") then
		removePedFromVehicle(player)
		setElementHealth(player, 20)
		setElementData(player, "PlayerCaido", true)
		setPedAnimation(player, "CRACK", "crckdeth3", 1, false, true, false)
		setTimer(function()
			if getElementData(player, "PlayerCaido") then	
				killPed(player)
			end
		end, 240000, 1)
	end
end
addEvent("OnHS", true)
addEventHandler("OnHS", getRootElement(), SetarCaidoComHS)

function curar_jogador ( thePlayer, comando, id )
	if id then
		id = tonumber ( id )
		if id then
			local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
			if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Samu") ) then
				local player_a_ser_curado    =   getPlayerID(id)
				if not player_a_ser_curado then
					return outputChatBox("#bebebeJogador não encontrado!",thePlayer,255,255,255,true)
				end
				local samux, samuy, samuz = getElementPosition ( thePlayer )
				local curadox, curadoy, curadoz = getElementPosition ( player_a_ser_curado )
				local dist = getDistanceBetweenPoints3D ( samux, samuy, samuz, curadox, curadoy, curadoz )
				if player_a_ser_curado == thePlayer then
					outputChatBox("#bebebeVocê não pode se curar!",thePlayer,255,255,255,true)
					return
				end
				if ( dist > 3 )  then
					outputChatBox("#bebebeChegue mais perto do jogador!", thePlayer, 255, 255, 255, true)
				elseif ( dist < 3 )then
					setPedAnimation( thePlayer, "MEDIC", "CPR", 4500, true, false, false, false)
					setTimer ( function()
						if not isElement(player_a_ser_curado) then return end
						
						setElementHealth ( player_a_ser_curado, 100 )
						setPedAnimation(player_a_ser_curado, false)
						setElementFrozen( player_a_ser_curado, false )
						setElementData(player_a_ser_curado,"PlayerCaido",false)
					end, 4500, 1 )
				end		
			end
		else
			outputChatBox("#bebebe["..comando.."]: id inválido", thePlayer, 255, 255, 255, true)
		end
	else
		outputChatBox("#bebebeSintaxe: /"..comando.." [id]", thePlayer, 255, 255, 255, true)
	end
end
addCommandHandler ( "curar", curar_jogador )

 

  • Like 1
Link to comment

muito obrigado funcionou.

 

so mais uma coisa, aparece uma mensagem la em cima falando "vc tem 3 min para ser curado" so q o contador q aparece embaixo ta errado, ele não começa a contagem do 3 ate o 0, ele começa do 5 e ai ate o 2,59 q da 3 min isso ta certo, o único erro é o contador .Oq eu faço?

function contador()
	local timer = interpolateBetween(deadTime, 0, 0, 0, 0, 0, (getTickCount()-tick)/deadTime, "Linear")
    local minutes, seconds = convertTime(timer)
    dxDrawText("Tempo de vida restante: "..minutes..":"..seconds, (screenW * 0.3801) + 1, (screenH * 0.9089) + 1, (screenW * 0.7059) + 1, (screenH * 1.0299) + 1, tocolor(0, 0, 0, 132), 1.00, dxfont0_fonte, "left", "top", false, false, false, false, false)
	dxDrawText("Tempo de vida restante: #FF0000"..minutes.."#FFFFFF:#FF0000"..seconds, screenW * 0.3801, screenH * 0.9089, screenW * 0.7059, screenH * 1.0299, tocolor(255, 255, 255, 255), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false)
end

 

Link to comment

como eu iria fazer isso? tipo o script do contador q eu usso é esse 

function contador()
	local timer = interpolateBetween(deadTime, 0, 0, 0, 0, 0, (getTickCount()-tick)/deadTime, "Linear")
    local minutes, seconds = convertTime(timer)
    dxDrawText("Tempo de vida restante: "..minutes..":"..seconds, (screenW * 0.3801) + 1, (screenH * 0.9089) + 1, (screenW * 0.7059) + 1, (screenH * 1.0299) + 1, tocolor(0, 0, 0, 132), 1.00, dxfont0_fonte, "left", "top", false, false, false, false, false)
	dxDrawText("Tempo de vida restante: #FF0000"..minutes.."#FFFFFF:#FF0000"..seconds, screenW * 0.3801, screenH * 0.9089, screenW * 0.7059, screenH * 1.0299, tocolor(255, 255, 255, 255), 1.00, dxfont0_fonte, "left", "top", false, false, false, true, false)
end

 

Link to comment
  • Moderators

Exemplo:

local time

addEvent( "onServerCallAddSetTimer", true )
addEventHandler( "onServerCallAddSetTimer", root, function ()

	time = setTimer(function() time = nil removeEventHandler( "onClientRender", root, renderTime ) end, 180000, 1)
	addEventHandler( "onClientRender", root, renderTime )
end )

function renderTime()
	local gDetails = getTimerDetails(time)
	if not gDetails then return end
	local remainingTime = secondsToTimeDesc( gDetails / 1000 )
	
	dxDrawText( "Tempo de vida restante: "..tostring(remainingTime), left, top, right, bottom )
end

function secondsToTimeDesc( seconds )
	if seconds then
		local results = {}
		local sec = ( seconds %60 )
		local min = math.floor ( ( seconds % 3600 ) /60 )
		local hou = math.floor ( ( seconds % 86400 ) /3600 )
		local day = math.floor ( seconds /86400 )
		
		if day > 0 then table.insert( results, day .. ( day == 1 and " day" or " days" ) ) end
		if hou > 0 then table.insert( results, hou .. ( hou == 1 and " hour" or " hours" ) ) end
		if min > 0 then table.insert( results, min .. ( min == 1 and " minute" or " minutes" ) ) end
		if sec > 0 then table.insert( results, sec .. ( sec == 1 and " second" or " seconds" ) ) end
		
		return string.reverse ( table.concat ( results, ", " ):reverse():gsub(" ,", " dna ", 1 ) )
	end
	return ""
end

 

  • Like 1
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...