Jump to content

[Ajude-Me] Sistema de prisão


Recommended Posts

Olá, como consigo fazer que o jogador que for preso possa andar pelo presidio, e como faço para eles ficarem visíveis entre si? No script original o player n consegui sair do local que ele desova '-'

Já tentei colocar "setElementFrozen (false)" mas mesmo assim n vai :/

 

Server:

--[[



 ################################################
 #                                              #
 #              Script Criado Por               #
 #           FACEBOOK.COM/AIRNEWSCR             #
 #                                              #
 #                                              #
 ################################################   



--]]

-------------------------------------------------

InteriorDP = 6
DimensaoDP = 0

Cmd01 = "a" -- Algema
Cmd02 = "d" -- Desalgema
Cmd03 = "r" -- Retira Armas

Grupo = "ComandosPolicia"

Distancia_Comandos = 7

Deixar_Preso = createMarker ( 1535.73486, -1672.03137, 13.38281 -1, "cylinder", 10, 255, 255, 255, 0 )

Local_Preso = createMarker ( 242.242, 50.246, 1019.539, "cylinder", 2.5, 255, 255, 255, 0 )
setElementFrozen( Jogador_Func, false )
setElementInterior ( Local_Preso, InteriorDP )
setElementDimension ( Local_Preso, DimensaoDP )

function emarker ( marker, md )
	if md then
	    if marker == Deixar_Preso then
		    if getElementData ( source, "ocupacao" ) == "Policial" then
		        setElementData ( source, "AirNewSCR_PrisaoArea", "Sim" )
				exports.Scripts_OnMarkerMsgs_:create ( source, "Aviso: Aperte F9 para Abrir / Fechar o Painel de Prender do DP" )
			end
		end
    end
end
addEventHandler ( "onPlayerMarkerHit", getRootElement ( ), emarker )

function lmarker ( marker, md )
	if md then
	    if marker == Deixar_Preso then
		    setElementData ( source, "AirNewSCR_PrisaoArea", "Não" )
			exports.Scripts_OnMarkerMsgs_:delete(source)
		end
    end
end
addEventHandler ( "onPlayerMarkerLeave", getRootElement ( ), lmarker )

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 Algemar_Jogador ( thePlayer, _, nick )
	if nick then
		if getPlayerFromPartialName ( nick ) then
            local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
            if isObjectInACLGroup ("user."..accName, aclGetGroup ( Grupo ) ) then
				local player_a_ser_algemado = getPlayerFromPartialName ( nick )
                local nick_do_jogador = getPlayerName ( player_a_ser_algemado )
				local nick_do_policial = getPlayerName ( thePlayer )
                local jX, jY, jZ = getElementPosition (player_a_ser_algemado) 
				local pX, pY, pZ = getElementPosition (thePlayer)
				local dist = getDistanceBetweenPoints3D ( pX, pY, pZ, jX, jY, jZ)
				if thePlayer == player_a_ser_algemado then
				    return exports.Scripts_Textos:createNewDxMessage ( "Erro: Você não pode algemar você mesmo!", thePlayer, 255, 255, 255 )
				end
				local Verificar = getElementData ( player_a_ser_algemado, "algemado" ) or false
				if Verificar == true then
				    exports.Scripts_Textos:createNewDxMessage ( "Erro: Esse Jogador ja Esta Algemado!", thePlayer, 255, 255, 255 )
				else				
				    if dist <= Distancia_Comandos then
				        setElementData(player_a_ser_algemado,"algemado", true )
				        setElementFrozen( player_a_ser_algemado, true )
				        toggleControl(player_a_ser_algemado, "fire", false)
				        setPedAnimation( player_a_ser_algemado, "GRAVEYARD", "mrnM_loop", -1, true, false, false, false)
				        exports.Scripts_Textos:createNewDxMessage ( "Aviso: Você foi Algemado pelo Policial "..nick_do_policial, player_a_ser_algemado, 255, 255, 255 )
				        exports.Scripts_Textos:createNewDxMessage ( "Aviso: Você algemou o Jogador "..nick_do_jogador.." com Sucesso!", thePlayer, 255, 255, 255 )
				    else
				        exports.Scripts_Textos:createNewDxMessage ( "Erro: Você esta Muito longe do Jogador! chegue mais Perto para poder Algema-lo!", thePlayer, 255, 255, 255 )
				    end
				end
			end
		end
	end
end
addCommandHandler( Cmd01, Algemar_Jogador)

function Desalgemar_Jogador ( thePlayer, _, nick )
	if nick then
		if getPlayerFromPartialName ( nick ) then
            local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
            if isObjectInACLGroup ("user."..accName, aclGetGroup ( Grupo) ) then
				local player_a_ser_desalgemado = getPlayerFromPartialName ( nick )
                local nick_do_jogador = getPlayerName ( player_a_ser_desalgemado )
				local nick_do_policial = getPlayerName ( thePlayer )
				if thePlayer == player_a_ser_desalgemado then
				    return exports.Scripts_Textos:createNewDxMessage ( "Erro: Você não pode desalgemar você mesmo!", thePlayer, 255, 255, 255 )
				end
				local Verificar = getElementData ( player_a_ser_desalgemado, "algemado" ) or false
				if Verificar == false then
				    exports.Scripts_Textos:createNewDxMessage ( "Erro: Esse Jogador não esta Algemado!", thePlayer, 255, 255, 255 )
				else
				    setElementData ( player_a_ser_desalgemado, "algemado", false )
				    setPedAnimation ( player_a_ser_desalgemado )
				    setElementFrozen ( player_a_ser_desalgemado, false )
				    toggleControl ( player_a_ser_desalgemado, "fire", true )
				    exports.Scripts_Textos:createNewDxMessage ( "Aviso: Você foi Desalgemado pelo Policial "..nick_do_policial, player_a_ser_desalgemado, 255, 255, 255 )
				    exports.Scripts_Textos:createNewDxMessage ( "Aviso: Você desalgemou o Jogador "..nick_do_jogador.." com Sucesso!", thePlayer, 255, 255, 255 )
				end
			end
		end
	end
end
addCommandHandler( Cmd02, Desalgemar_Jogador)

function Retirar_Armas ( source, cmd, pname )
	if getElementData(source, "ocupacao" ) == "Policial" then
		local cliente = getPlayerFromPartialName(pname)
		if isElement(cliente) then
			if cliente == source then exports.Scripts_Dxmessages:outputDx(source, "Erro: Você não pode Retirar suas Proprias Armas!", "error") return end
			local cx,cy,cz = getElementPosition(cliente)
			local x,y,z = getElementPosition(source)
			local dist = getDistanceBetweenPoints3D(x,y,z,cx,cy,cz)
			if dist <= 7 then
			    takeAllWeapons ( cliente )
				exports.Scripts_Dxmessages:outputDx(source, "Aviso: Você removeu todas as Armas do Jogador #ffffff"..getPlayerName(cliente).." #ffffffcom Sucesso!", "success")
				exports.Scripts_Dxmessages:outputDx(cliente, "Aviso: O Policial #ffffff"..getPlayerName(source).."#ffffff Confiscou todas as suas Armas!", "warning")
			end
		else
		    exports.Scripts_Dxmessages:outputDx(source, "Erro: O Jogador Não Foi Encontrado!", "error")
		end
	end
end
addCommandHandler ( Cmd03, Retirar_Armas )

function Verificar_Emprego_Atual ( )
	for i, player in ipairs(getElementsByType("player")) do
		local acc = getPlayerAccount(player)
		if acc and not isGuestAccount(acc) then
			local job = getElementData(player,'ocupacao')
			local accName = getAccountName (acc)
			if isObjectInACLGroup ("user."..accName, aclGetGroup ( Grupo ) ) then
			    setElementData ( player, "ocupacao", "Policial" )
			    setElementData ( player, "AirNewSCR_Entrada_PortaoDP", "Sim" )
				setElementData ( player, "AirNew_Perm_Prender", "Sim" )
			else
			    setElementData ( player, "ocupacao", "Criminoso" )
			    setElementData ( player, "AirNewSCR_Entrada_PortaoDP", "Não" )
				setElementData ( player, "AirNew_Perm_Prender", "Não" )
			end
		end
	end
end
setTimer ( Verificar_Emprego_Atual, 1500, 0 )

local Prisao_Blip = createBlip ( 1535.89856, -1672.66479, 13.38281 )
setElementVisibleTo ( Prisao_Blip, root, false )

function Nivel_de_Procurado ( source, int )
	if int == 0 then
		setPlayerWantedLevel ( source, int )
	else
		local wl = getPlayerWantedLevel ( source )
		if wl + int <= 6 then
			setPlayerWantedLevel ( source, wl+int )
		else
			setPlayerWantedLevel ( source, 6 )
		end
	end
end
addEvent("AirNewSCR_Nivel_de_Procurado", true)
addEventHandler("AirNewSCR_Nivel_de_Procurado", getRootElement ( ), Nivel_de_Procurado )

function Mensagens_Exports ( source, msg )
	exports.Scripts_Textos:createNewDxMessage ( msg, source, 255, 255, 255 )
end
addEvent ( "AirNewSCR_Mensagens_Exports", true)
addEventHandler ( "AirNewSCR_Mensagens_Exports", getRootElement ( ), Mensagens_Exports )

function Enviar_Prisao_Servidor ( Jogador, Numero, Formato, Motivo )
    outputChatBox ( "#1100FF[HR] #FFFFFFO Policial "..getPlayerName(source).." Prendeu o Cidadao "..Jogador.."!", root, 255, 255, 255, true )
    outputChatBox ( "#1100FF[HR] #FFFFFFPelo tempo de "..Numero.." "..Formato..", Motivo: "..Motivo.."!", root, 255, 255, 255, true )
    Jogador_Func = getPlayerFromName ( Jogador )
    Estrelas_Preso = getPlayerWantedLevel ( Jogador_Func )
    givePlayerMoney ( source, Estrelas_Preso*1000 )
    if Formato == "Segundo(s)" then
        Multiplicador = 1
    elseif Formato == "Minuto(s)" then
        Multiplicador = 60
    elseif Formato == "Hora(s)" then
        Multiplicador = 3600
    elseif Formato == "Dia(s)" then
        Multiplicador = 86400
    end
    TempoPrisao = Numero*Multiplicador
    setElementData ( Jogador_Func, "AirNew_Tempo_Prisao", TempoPrisao )
    setElementData ( Jogador_Func, "AirNew_Preso", "Sim" )
	setPlayerWantedLevel ( Jogador_Func, 0 )
	takeAllWeapons ( Jogador_Func )
	
	setElementData ( Jogador_Func, "Policia:Captura", false )
	setElementData ( Jogador_Func, "Player:Msg", "" )
	showCursor ( Jogador_Func, false)
	setControlState ( Jogador_Func, "sprint", false)
	setControlState ( Jogador_Func, "walk", false)
	setControlState ( Jogador_Func, "forwards", false)
	toggleAllControls ( Jogador_Func, true )
	
	triggerClientEvent ( source, "CancelTimeParaPrender:Time", source )
	
	if getElementData ( Jogador_Func, "algemado" ) == false then
		setElementData ( Jogador_Func, "algemado", false )
		setPedAnimation ( Jogador_Func )
		toggleControl ( Jogador_Func, "fire", true )
	end
end
addEvent( "AirNew_Enviar_Prisao", true )
addEventHandler( "AirNew_Enviar_Prisao", getRootElement(), Enviar_Prisao_Servidor )

function Capturar_Jogador ( source, wantedlevel, vitima )
	local x, y, z = getElementPosition ( vitima )
	if x < -518 and y < 0 then -- SF
		time = 4
	end
	if x >= -518 and y < 510 then -- LS
		time = 2
	end
	if x >= -518 and y >= 510 then -- LV
		time = 4
	end	
	setElementData ( source, "PoliceToPrision:Time", tonumber(time*60) )	
	setTimer ( triggerClientEvent, 10000, 1, source, "ShowTimeParaPrender:Time", source )
	
	exports.Scripts_Textos:createNewDxMessage ( "Você foi Capturado pelo Policial "..getPlayerName(source), vitima, 255, 255, 255 )
	exports.Scripts_Textos:createNewDxMessage ( "Você tem "..time.." Minutos para Levar o Jogador para a Prisão!", source, 255, 255, 255 )
	
	toggleAllControls ( vitima, false )
	setElementVisibleTo ( Prisao_Blip, source, true )
end
addEvent("AirNewSCR_Capturar_Jogador", true)
addEventHandler("AirNewSCR_Capturar_Jogador", getRootElement(), Capturar_Jogador )

function Teleportar_Capturado_Veiculo ( state, player , vehicle , seat )
	if state == true then
		if seat and isElement ( vehicle ) then
		    warpPedIntoVehicle ( player, vehicle, seat )
		end
	else 
		removePedFromVehicle ( player )
	end
end
addEvent ( "AirNewSCR_TeleportarVeiculo", true )
addEventHandler ( "AirNewSCR_TeleportarVeiculo", getRootElement ( ), Teleportar_Capturado_Veiculo )

function Remover_Jogador_Veiculo ( player )
    removePedFromVehicle ( player )
end
addEvent ( "AirNewSCR_Remover_Jogador_Veiculo", true )
addEventHandler ( "AirNewSCR_Remover_Jogador_Veiculo", getRootElement ( ), Remover_Jogador_Veiculo )

function Teleportar_Capturado_Player ( source, type, value, x, y ,z)
	local Policial = getElementData ( source, "Policia:Captura" )
	if isElement ( Policial ) and not isPedInVehicle ( source ) then
		if type == "INT" then
			setElementInterior ( source, value )
		elseif type == "DIM" then
			setElementDimension ( source, value )
		end
		setElementPosition ( source, x, y ,z )
	end
end
addEvent ( "AirNewSCR_TeleportarPlayer", true )
addEventHandler ( "AirNewSCR_TeleportarPlayer", getRootElement ( ), Teleportar_Capturado_Player )

function Liberar_Capturado ( source )	
	for p, player in ipairs ( getElementsByType ( "player" ) ) do	
		job = getElementData ( player,"ocupacao" ) or "Nenhum"
		capturado = getElementData ( player, "Policia:Captura" )
		if job == "Criminoso" and isElement ( capturado ) then
			if capturado == source then
				Soltar_Fail_Captura ( source, player )
			end
		end
	end
end
addEvent ( "AirNewSCR_FalharCapturaLiberar", true )
addEventHandler ( "AirNewSCR_FalharCapturaLiberar", getRootElement ( ), Liberar_Capturado )

function Soltar_Fail_Captura ( policial, vitima )
	exports.Scripts_Textos:createNewDxMessage ( "O policial falhou e voce está solto novamnte, fuja",vitima, 255, 255, 255 )
	exports.Scripts_Textos:createNewDxMessage ( "Voce falhou e o criminoso está solto novamente",policial, 255, 255, 255 )
	setElementVisibleTo ( Prisao_Blip, policial, false )
	setElementData ( vitima, "Policia:Captura", false )
	setElementData ( vitima, "Player:Msg", "" )
	showCursor ( vitima, false )
	setControlState ( vitima, "sprint", false )
	setControlState ( vitima, "walk", false )
	setControlState ( vitima, "forwards", false )
	toggleAllControls ( vitima, true )
end

--- // Salvamento - Carregamento // ---

addEventHandler("onPlayerLogin", root,
function( _, acc )
 CarregarLoginPlay ( acc )
 end
)

function CarregarLoginPlay ( conta )
	if not isGuestAccount ( conta ) then
		if conta then	
			local source = getAccountPlayer ( conta )
			local AirNew_Tempo_Prisao = getAccountData ( conta, "AirNew_Tempo_Prisao" ) or 0
			setElementData ( source, "AirNew_Tempo_Prisao", AirNew_Tempo_Prisao )
			local AirNew_Preso = getAccountData ( conta, "AirNew_Preso" ) or "Não"
			setElementData ( source, "AirNew_Preso", AirNew_Preso )
		end
	end	
end

function ReiniciarScript ( res )
	if res == getThisResource ( ) then
		for i, player in ipairs ( getElementsByType ( "player" ) ) do
			local acc = getPlayerAccount ( player )
			if not isGuestAccount ( acc ) then
				CarregarLoginPlay ( acc )
			end
		end
	end
end
addEventHandler ( "onResourceStart", getRootElement ( ), ReiniciarScript )

--

function SalvarLoginPlay ( conta )
	if conta then
		local source = getAccountPlayer ( conta )
		local AirNew_Tempo_Prisao = getElementData ( source, "AirNew_Tempo_Prisao" ) or 0
		setAccountData ( conta, "AirNew_Tempo_Prisao", AirNew_Tempo_Prisao )
		local AirNew_Preso = getElementData ( source, "AirNew_Preso" ) or "Não"
		setAccountData ( conta, "AirNew_Preso", AirNew_Preso )
	end	
end

function DesligarScript ( res )
    if res == getThisResource ( ) then
		for i, player in ipairs ( getElementsByType ( "player" ) ) do
			local acc = getPlayerAccount ( player )
			if not isGuestAccount ( acc ) then
				SalvarLoginPlay ( acc )
			end
		end
	end
end 
addEventHandler ( "onResourceStop", getRootElement ( ), DesligarScript )

function JogadorQuit ( quitType )
	local acc = getPlayerAccount ( source )
	if not isGuestAccount ( acc ) then
		if acc then
			SalvarLoginPlay ( acc )
		end
	end
end
addEventHandler ( "onPlayerQuit", getRootElement ( ), JogadorQuit )

Client:

--[[



 ################################################
 #                                              #
 #              Script Criado Por               #
 #           FACEBOOK.COM/AIRNEWSCR             #
 #                                              #
 #                                              #
 ################################################   



--]]

-------------------------------------------------

local screenW, screenH = guiGetScreenSize()
local resW, resH = 1366, 768
local x, y = (screenW/resW), (screenH/resH)

InteriorDP = 6
DimensaoDP = 0

AirNew_Marker_Prisao = createMarker ( 242.242, 50.246, 1019.539 -1, "cylinder", 2.5, 0, 0, 0, 0 )
setElementInterior ( AirNew_Marker_Prisao, InteriorDP )
setElementDimension ( AirNew_Marker_Prisao, DimensaoDP )

function Jogador_na_Prisao ( player )
	return isElementWithinMarker ( player, AirNew_Marker_Prisao )
end

Policial_Atirar = {}
Timer_Policial_Atirar = {}

function Resetar_AgressaoPolicial ( cop )
	if Policial_Atirar[cop] and Policial_Atirar[cop] == true then
		Policial_Atirar[cop] = false	
	end 
end

Abrir_Fechar_Prender = "F9"

function Prender_Cacetete ( Atirador, weapon, bodypart )
	local Vitima = source
	local Tempo_Prisao_Vitima = getElementData ( Vitima, "AirNew_Tempo_Prisao" ) or 0
	local Emprego_Vitima = tostring ( getElementData ( Vitima, "ocupacao" ) ) or "Nenhum"
	if Atirador then
		Emprego_Atirador = getElementData ( Atirador, "ocupacao" ) or "Nenhum" 
	else
		Emprego_Atirador = "Nenhum" 
	end
	if Emprego_Vitima == true or Emprego_Vitima == false or Emprego_Vitima == nil or tostring ( Emprego_Vitima ) == "Nenhum" then 
	    cancelEvent ( )
	end
	if Atirador ~= localPlayer or weapon == 53 or weapon == 54 or weapon == 50 or weapon == 55 then		
		if Emprego_Vitima == "Criminoso" then
			local Capturado_Policial = getElementData ( Vitima, "Policia:Captura" )
			if isElement ( Capturado_Policial ) then
				cancelEvent ( )
			end
			if Jogador_na_Prisao ( Vitima ) == true and Tempo_Prisao_Vitima > 0 then
				cancelEvent ( )
			end
		end
		if isElement ( Atirador ) then		
			if Emprego_Atirador == "Criminoso" then
				if Emprego_Vitima == "Policial" then	
					for k, v in pairs(Policial_Atirar) do
						if k == Vitima and v == true then return end
					end	
					Policial_Atirar[Vitima] = true
					Timer_Policial_Atirar[Vitima] = setTimer ( Resetar_AgressaoPolicial, 30000, 1, Vitima )
					triggerServerEvent ( "AirNewSCR_Nivel_de_Procurado", Atirador, Atirador, 1 )
					Mensagens_Exports ( Atirador, "Aviso: Você Agrediu um Policial, e Pode ser Preso por isso!" )
				else
					--cancelEvent ( )
				end
			elseif Emprego_Atirador == "Policial" then
				if Emprego_Vitima == "Criminoso" then
					local wl = getPlayerWantedLevel ( Vitima ) or 0
					if wl == 0 then
						Mensagens_Exports ( Atirador, "Erro: Este Jogador não tem Mandato de Prisão!" )
					end	
					if wl > 0 then
						if weapon == 3 or weapon == 23 then -- Cacetete / Tazer (Silenced)
							local Policia_Captura = getElementData ( source, "Policia:Captura" )
							if isElement ( Policia_Captura ) then cancelEvent ( ) return end
							if Policia_Captura == false or Policia_Captura == nil then
								--local Captura_na_Prisao = Jogador_na_Prisao ( Vitima )
								--if Captura_na_Prisao then
								--	triggerServerEvent( "AirNewSCR_Prender_Jogador", Atirador, Atirador, wl, source )
								--else
									setElementData ( source, "Policia:Captura", Atirador )
									setElementData ( source, "Player:Msg", "Capturado por\n"..getPlayerName ( Atirador ) )
									triggerServerEvent ( "AirNewSCR_Capturar_Jogador", Atirador, Atirador, wl, source )
								--end
							end							
						end
					end	
				end
			end	
		end	
	end
end
addEventHandler ( "onClientPlayerDamage", getLocalPlayer ( ), Prender_Cacetete )

function Mensagens_Exports ( source, msg )
    triggerServerEvent ( "AirNewSCR_Mensagens_Exports", getRootElement(), source, msg )
end

addEventHandler("onClientPreRender", root,
function ( )
	local Policial = getElementData ( localPlayer, "Policia:Captura" )
	if isElement ( Policial ) then
		if isPedInVehicle ( Policial ) then
			statecop = true
		else
			statecop = false
		end
		if isPedInVehicle ( localPlayer ) then
			statecriminal = true
		else
			statecriminal = false
		end		
		if statecop ~= statecriminal then
			if statecop == true then
				local vh = getPedOccupiedVehicle ( Policial )
				if isElement ( vh ) then
					local passengers = getVehicleMaxPassengers ( vh )
					for seat = 0, passengers do
						if seat > 0 and not getVehicleOccupant ( vh, seat ) then
							triggerServerEvent ( "AirNewSCR_TeleportarVeiculo", localPlayer, true, localPlayer, vh, seat )
							break
						end
					end				
				end
			else
				triggerServerEvent("AirNewSCR_TeleportarVeiculo", localPlayer,false, localPlayer , vhw , 0)
			end
		end
		local copX, copY, copZ = getElementPosition ( Policial )
		local PrisonerX, PrisonerY, PrisonerZ = getElementPosition ( localPlayer )
		
		local copInt = getElementInterior ( Policial )
		local prisonerInt = getElementInterior ( localPlayer )
		if copInt ~= prisonerInt and not isTimer ( intTimer ) then
			intTimer = setTimer ( function ( ) end, 3000, 1 )
			triggerServerEvent ( "AirNewSCR_TeleportarPlayer", localPlayer, localPlayer, "INT", copInt, copX, copY, copZ )
		end
		
		local copDim = getElementDimension ( Policial )
		local prisonerDim = getElementDimension ( localPlayer )
		if copDim ~= prisonerDim and not isTimer ( dimTimer ) then
			dimTimer = setTimer(function() end, 3000, 1)
			triggerServerEvent ( "AirNewSCR_TeleportarPlayer", localPlayer, localPlayer, "DIM", copDim, copX+0.1, copY+0.1, copZ+0.5)
		end
		local Distancia_Policial_Capturado = getDistanceBetweenPoints3D ( copX, copY, copZ, PrisonerX, PrisonerY, PrisonerZ )
		if Distancia_Policial_Capturado > 20 then
			if not isTimer ( Muito_Longe_do_Policial ) then
				triggerServerEvent ( "AirNewSCR_TeleportarPlayer", localPlayer, localPlayer, false, false, copX+1, copY+1, copZ )
				setPedControlState ( "forwards", false )
				setPedControlState ( "walk", false )
				setPedControlState ( "sprint", false )
				Muito_Longe_do_Policial = setTimer ( function ( ) end, 3000, 1 )
			end
		elseif Distancia_Policial_Capturado > 10 then
			setPedControlState ( "forwards", true )
			setPedControlState ( "sprint", true )
			setPedControlState ( "walk", false )
		elseif Distancia_Policial_Capturado > 3 then
			setPedControlState ( "forwards", true )
			setPedControlState ( "sprint", false )
			setPedControlState ( "walk", false )
		elseif Distancia_Policial_Capturado > 2 then
			setPedControlState ( "forwards", true )
			setPedControlState ( "sprint", false )
			setPedControlState ( "walk", true )
		elseif Distancia_Policial_Capturado > 1 then
			setPedControlState ( "forwards", false )
			setPedControlState ( "walk", false )
			setPedControlState ( "sprint", false )
		end
		setPedRotation ( localPlayer, 360-math.deg(math.atan2((copX-PrisonerX), (copY-PrisonerY))) % 360 )
		setCameraTarget ( localPlayer )
	end
end)

function AbrirFechar_Prisao ( )
    if getElementData ( localPlayer, "AirNew_Perm_Prender" ) == "Sim" then
        if guiGetVisible ( AirNew_Painel_Prender ) == false then
		    if getElementData ( localPlayer, "AirNewSCR_PrisaoArea" ) == "Sim" then
		    	showCursor ( true )
		    	guiSetVisible ( AirNew_Painel_Prender, true )
		    	AtualizarListaDeNicks ()
				SetarNaLista ()
		   		playSoundFrontEnd ( 43 )
			end
	    else
		    showCursor ( false )
		    guiSetVisible ( AirNew_Painel_Prender, false )
		    playSoundFrontEnd ( 40 )
	    end
	end
end
bindKey ( Abrir_Fechar_Prender, "down", AbrirFechar_Prisao )

addEventHandler("onClientResourceStart", getResourceRootElement(),
function()
	guiSetInputMode("no_binds_when_editing")
end)

AirNew_Painel_Prender = guiCreateWindow((screenW - 535) / 2, (screenH - 362) / 2, 535, 362, "Painel de Prender - ("..Abrir_Fechar_Prender..")", false)
guiWindowSetSizable(AirNew_Painel_Prender, false)
guiSetAlpha(AirNew_Painel_Prender, 0.70)
guiSetVisible ( AirNew_Painel_Prender, false )

AirNew_Gridlist_Prender = guiCreateGridList(19, 37, 184, 299, false, AirNew_Painel_Prender)
AirNew_Gridlist_Prender_Coluna = guiGridListAddColumn(AirNew_Gridlist_Prender, "Jogadores", 0.9)
	
AirNew_Gridlist_Tempo = guiCreateGridList(226, 97, 289, 113, false, AirNew_Painel_Prender)
AirNew_Gridlist_Tempo_Coluna = guiGridListAddColumn(AirNew_Gridlist_Tempo, "Tempo", 0.9)
	
AirNew_Label_Motivo = guiCreateLabel(228, 218, 287, 15, "Motivo da Prisão", false, AirNew_Painel_Prender)
guiLabelSetHorizontalAlign(AirNew_Label_Motivo, "center", false)
guiLabelSetVerticalAlign(AirNew_Label_Motivo, "center")
AirNew_Edit_Motivo = guiCreateEdit(226, 237, 289, 34, "", false, AirNew_Painel_Prender)

AirNew_Edit_SMHD = guiCreateEdit(226, 56, 289, 34, tonumber("0"), false, AirNew_Painel_Prender)
AirNew_Label_SMHD = guiCreateLabel(228, 37, 287, 15, "Informe um Numero e Selecione um Tempo!", false, AirNew_Painel_Prender)
guiLabelSetHorizontalAlign(AirNew_Label_SMHD, "center", false)
guiLabelSetVerticalAlign(AirNew_Label_SMHD, "center")
	
AirNew_Botao_Prender = guiCreateButton(236, 288, 127, 48, "Prender", false, AirNew_Painel_Prender)
guiSetProperty(AirNew_Botao_Prender, "NormalTextColour", "FF17FE00")
	
AirNew_Botao_Fechar = guiCreateButton(378, 288, 127, 48, "Fechar", false, AirNew_Painel_Prender)
guiSetProperty(AirNew_Botao_Fechar, "NormalTextColour", "FFFD0000")

function AtualizarListaDeNicks ()
guiGridListClear ( AirNew_Gridlist_Prender )
	for index, player in ipairs ( getElementsByType ( "player" ) ) do
	    Lista_AirNew = guiGridListAddRow ( AirNew_Gridlist_Prender )
		local x, y, z = getElementPosition ( localPlayer) -- Eu
        local x1, y1, z1 = getElementPosition ( player ) -- Jogadores Proximos
        local Distancia = getDistanceBetweenPoints3D ( x, y, z, x1, y1, z1 )
		if Distancia <= 5 then
		    guiGridListSetItemText ( AirNew_Gridlist_Prender, Lista_AirNew, AirNew_Gridlist_Prender_Coluna, (string.gsub ( getPlayerName(player), '#%x%x%x%x%x%x', '' ) or getPlayerName(player)), false, false)
		    guiGridListSetItemData ( AirNew_Gridlist_Prender, Lista_AirNew, AirNew_Gridlist_Prender_Coluna, getPlayerName(player) )
		end
	end
end
addEventHandler ( "onClientPlayerJoin", getRootElement(), AtualizarListaDeNicks )
addEventHandler ( "onClientPlayerQuit", getRootElement(), AtualizarListaDeNicks )
addEventHandler ( "onClientResourceStart", getRootElement(), AtualizarListaDeNicks )
addEventHandler ( "onClientPlayerChangeNick", getRootElement(), AtualizarListaDeNicks )

function SetarNaLista ()
    guiGridListClear ( AirNew_Gridlist_Tempo )
    local components = { "Segundo(s)", "Minuto(s)", "Hora(s)", "Dia(s)" }
    for _, component in ipairs( components ) do
        ListaAnimF = guiGridListAddRow ( AirNew_Gridlist_Tempo )
        guiGridListSetItemText ( AirNew_Gridlist_Tempo, ListaAnimF, AirNew_Gridlist_Tempo_Coluna, component, false, false)
        guiGridListSetItemData ( AirNew_Gridlist_Tempo, ListaAnimF, AirNew_Gridlist_Tempo_Coluna, component)
    end
end
addEventHandler ( "onClientResourceStart", getRootElement(), SetarNaLista )

function AirNew_Clicar_Botoes ()
    if guiGetVisible ( AirNew_Painel_Prender ) == true then
	    if getElementData ( localPlayer, "AirNew_Perm_Prender" ) == "Sim" then
	        if source == AirNew_Botao_Prender then
			    local Jogador_Selecionado = guiGridListGetItemData( AirNew_Gridlist_Prender, guiGridListGetSelectedItem ( AirNew_Gridlist_Prender ), 1 ) or nil
				local SMHD_Selecionado = tonumber( guiGetText ( AirNew_Edit_SMHD ) ) or nil
				local Tempo_Selecionado = guiGridListGetItemData( AirNew_Gridlist_Tempo, guiGridListGetSelectedItem ( AirNew_Gridlist_Tempo ), 1 ) or nil
				local Motivo_Prisao = guiGetText ( AirNew_Edit_Motivo ) or nil
				if Jogador_Selecionado == nil then
				    return outputChatBox ( "Erro: Selecione um Jogador para Prender!", 255, 255, 255, true )
				end
				if SMHD_Selecionado == tonumber("0") or SMHD_Selecionado == nil then
				    return outputChatBox ( "Erro: Informe um Numero e Selecione um Tempo antes de Prender o Jogador!", 255, 255, 255, true )
				end
				if Tempo_Selecionado == nil then
				    return outputChatBox ( "Erro: Selecione um Tempo (Seg, Min etc) para Prender o Jogador!", 255, 255, 255, true )
				end
				if Motivo_Prisao == "" or Motivo_Prisao == nil then
				    return outputChatBox ( "Erro: Informe o Motivo da Prisão Corretamente para Prender o Jogador!", 255, 255, 255, true )
				end
				local Converter_Jogador = getPlayerFromName ( Jogador_Selecionado )
				if Converter_Jogador == localPlayer then
				    return outputChatBox ( "Erro: Você não pode Prender você mesmo!", 255, 255, 255, true )
				end
		        local x, y, z = getElementPosition ( localPlayer ) -- Eu
                local x1, y1, z1 = getElementPosition ( Converter_Jogador ) -- Jogadores Proximos
                local Distancia = getDistanceBetweenPoints3D ( x, y, z, x1, y1, z1 )
		        if Distancia > 15 then
		            return outputChatBox ( "Erro: Chegue mais Proximo do Jogador para Prende-lo!", 255, 255, 255, true )
		        end
				triggerServerEvent ( "AirNew_Enviar_Prisao", getLocalPlayer(), Jogador_Selecionado, SMHD_Selecionado, Tempo_Selecionado, Motivo_Prisao )
			    if guiGetVisible ( AirNew_Painel_Prender ) == true then
		            AbrirFechar_Prisao ()
			    end
			elseif source == AirNew_Botao_Fechar then
			    if guiGetVisible ( AirNew_Painel_Prender ) == true then
		            AbrirFechar_Prisao ()
			    end
			end
		end
	end
end
addEventHandler ( "onClientGUIClick", getRootElement(), AirNew_Clicar_Botoes )

function Verificar_Fuga ( )
	if isElementWithinMarker ( localPlayer, AirNew_Marker_Prisao ) and getElementData ( localPlayer, "AirNew_Preso" ) == "Não" then
	    if isPedInVehicle ( localPlayer ) then
			triggerServerEvent ( "AirNewSCR_Remover_Jogador_Veiculo", localPlayer, localPlayer )
		end
	    setElementPosition ( localPlayer, 1553.81995, -1675.62549, 16.19531 )
		setElementInterior ( localPlayer, 0 )
		setElementDimension ( localPlayer, 0 )
	    setElementRotation ( localPlayer, 0, 0, 90 )
		setTimer ( setCameraTarget, 50, 1, localPlayer )
	elseif not isElementWithinMarker ( localPlayer, AirNew_Marker_Prisao ) and getElementData ( localPlayer, "AirNew_Preso" ) == "Sim" then
	    if isPedInVehicle ( localPlayer ) then
		    triggerServerEvent ( "AirNewSCR_Remover_Jogador_Veiculo", localPlayer, localPlayer )
		end
		setElementPosition ( localPlayer, 242.242, 50.246, 1019.539 )
		setElementInterior ( localPlayer, InteriorDP )
		setElementDimension ( localPlayer, DimensaoDP )
	    setElementRotation ( localPlayer, 0, 0, 270 )
		setTimer ( setCameraTarget, 50, 1, localPlayer )
    end
end
setTimer ( Verificar_Fuga, 50, 0 )

function CronometroPrisao ()
    if getElementData ( localPlayer, "AirNew_Preso" ) == "Sim" then
        Tempo_Preso = getElementData ( localPlayer, "AirNew_Tempo_Prisao" ) or 0
	    if tonumber ( Tempo_Preso ) > 0 then
		    Tempo_Preso = Tempo_Preso - 1
		    setElementData ( localPlayer, "AirNew_Tempo_Prisao", tonumber(Tempo_Preso))
		    local horas_seg = 3600
		    local hora = math.floor(Tempo_Preso/horas_seg)
		    local minuto = math.floor((Tempo_Preso-(horas_seg*hora))/60)
		    local segundo = math.floor((Tempo_Preso-(horas_seg*hora)-(minuto*60)))
		    if hora > 0 then Medida = "Hora(s)"
			elseif hora < 1 and minuto > 0 then Medida = "Minuto(s)"
			elseif hora < 1 and minuto < 1 and segundo > 0 then Medida = "Segundo(s)"
			end
            if hora == 9 then hora = "09" elseif hora == 8 then hora = "08" elseif hora == 7 then hora = "07" elseif hora == 6 then hora = "06" elseif hora == 5 then hora = "05" elseif hora == 4 then hora = "04" elseif hora == 3 then hora = "03" elseif hora == 2 then hora = "02" elseif hora == 1 then hora = "01" elseif hora == 0 then hora = "00" end		
			exports.Scripts_OnMarkerMsgs_:create("Você sera Liberado em: "..hora..":"..string.format("%02d:%02d", minuto, segundo).." "..Medida.."")
	    elseif tonumber ( Tempo_Preso ) <= 0 then
			Tempo_Preso = 0
			exports.Scripts_OnMarkerMsgs_:delete()
			if not getElementData ( localPlayer, "AirNew_PagouFianca" ) == "Sim" then
			    outputChatBox ( "Sucesso: Você cumpriu sua pena na Prisão, Agora você está Livre!", 255, 255, 255, true )
			end
			setElementData ( localPlayer, "AirNew_Tempo_Prisao", tonumber(0) )
			setElementData ( localPlayer, "AirNew_Preso", "Não" )
			setElementData ( localPlayer, "AirNew_PagouFianca", "Não" )
	    end
	end	
end
setTimer ( CronometroPrisao, 1000, 0 )

Verificar_Tempo_Capturado = false

function ParaPrender_AirNewSCR ( )
	Tempo_para_Prender = tonumber ( getElementData ( localPlayer, "PoliceToPrision:Time" ) ) or 0
	if Tempo_para_Prender > 0 then
		Tempo_para_Prender = Tempo_para_Prender - 1
		setElementData ( localPlayer, "PoliceToPrision:Time", tonumber ( Tempo_para_Prender ) )
		local horas_seg = 3600
		local hora = math.floor ( Tempo_para_Prender / horas_seg )
		local minuto = math.floor ( ( Tempo_para_Prender - ( horas_seg * hora ) ) / 60 )
		local segundo = math.floor ( ( Tempo_para_Prender - ( horas_seg * hora ) - ( minuto * 60 ) ) )	
		exports.Scripts_OnMarkerMsgs_:create2 ( "Tempo para levar o criminoso: "..string.format("%02d:%02d",minuto,segundo).." segundos") 		
	end
	if Tempo_para_Prender <= 0 then
		if Verificar_Tempo_Capturado == true then 
			exports.Scripts_OnMarkerMsgs_:delete2 ( )	
			Tempo_para_Prender = 0
			setElementData ( localPlayer, "PoliceToPrision:Time", tonumber(0) )
			triggerServerEvent ( "AirNewSCR_FalharCapturaLiberar", getRootElement(), localPlayer )
			Verificar_Tempo_Capturado = false
			return
		end
	end
end
setTimer ( ParaPrender_AirNewSCR, 1000, 0 )

Tempo_Prender = 0

function Mostrar_Tempo_Captura ( )
	if Verificar_Tempo_Capturado == false then
	    Verificar_Tempo_Capturado = true
	end
end
addEvent("ShowTimeParaPrender:Time", true )
addEventHandler("ShowTimeParaPrender:Time", getRootElement(), Mostrar_Tempo_Captura )

function Cancelar_Tempo_Captura ( )
	if Verificar_Tempo_Capturado == true then
		exports.Scripts_OnMarkerMsgs_:delete2 ( )
		setElementData ( localPlayer, "PoliceToPrision:Time", tonumber(0) )
		Verificar_Tempo_Capturado = false
	end
end
addEvent ( "CancelTimeParaPrender:Time", true )
addEventHandler ( "CancelTimeParaPrender:Time", getRootElement ( ), Cancelar_Tempo_Captura )

 

Link to comment
5 hours ago, Furzy said:

na função 


function Enviar_Prisao_Servidor

na linha 222,223,224  voce vai achar setControlState

isso está impossibilitando o player de correr,caminhar, se mover ( creio que seja isso )

Creio que não seja, pois removi a linha que dizia "toggleAllControls ( Jogador_Func, true )" mas mesmo assim n funfo:(

Edited by dener189
Link to comment
On 18/09/2019 at 18:43, Furzy said:

Não é essa

remova os setControlState

 

  1. setControlState ( Jogador_Func, "sprint", false)
  2. setControlState ( Jogador_Func, "walk", false)
  3. setControlState ( Jogador_Func, "forwards", false)

 

ou bote true

Eu consigo andar, mas eu sou teletransportado pro local que nasci após ser preso.

Como faço para parar de teletransportar pro local que nasço após ser preso?

Link to comment

coloca 2 traços no SetElementdimension e interior (--setelementdimension ) vai ficar assim ......

e no local preso onde tem 2.5 vc aumenta para o tamanho da cadeia .

ele ta criando um marker invisível de tamanho '''2.5''

 

obs : se vc colocar cor nesse marker vai conseguir ver o tamanho que ele ta está e ir modificando até onde o preso pode se mover na cadeia , e o local preso tem q mudar quanto no server.Lua quanto no client.Lua.

se der certo avisa ai

setElementDimension 
setElementInterior 
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...