Jump to content

[Ajuda]Wanted Level


Recommended Posts

Eu estou tentando pegar o nivel do jogador quando click no veiculo que o jogador esta mais aparece o meu nivel de procurado e nao o do jogador .-.

			function click(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement)
				if isElement(chaseWindow) and button == "left" and state == "down" then
					if clickedElement  and getElementType(clickedElement) == "vehicle" then
			        		local sx,sy,sz = getElementVelocity(clickedElement)
							local driver = getVehicleOccupant(clickedElement)
							local proc = getVehicleOccupant(clickedElement)
							local realSpeed = ((sx^2 + sy^2 + sz^2)^(0.5)) * 180
							guiSetText(speedLabel,"Velocidade de: "..math.floor(realSpeed).." км/H")
							if driver then
								guiSetText(driverLabel,"Motorista: "..getPlayerName(driver))
							else
								guiSetText(driverLabel,"Motorista: Não encontrado")
							end
							if numberLabel then
								guiSetText(numberLabel,"Nivel de Procurado: "..getPlayerWantedLevel(thePlayer,proc))
							end
							if realSpeed >= chaseSpeedLimit then
								guiSetEnabled(chaseButton,true)
								guiLabelSetColor(speedLabel,255,0,0)
							else
								guiSetEnabled(chaseButton,false)
								guiLabelSetColor(speedLabel,255,255,255)
							end
							clickedVeh = clickedElement
		        	end
		        end
			end

 

Edited by LucasMTA
Link to comment
  • Other Languages Moderators

Vc está usando 2 parâmetros no getPlayerWantedLevel: thePlayer e proc.

E não faz sentido vc usar a variável proc pois ela é igual a driver. Seria mais fácil vc simplesmente usar driver no lugar de proc.

function click(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement)
	if isElement(chaseWindow) and button == "left" and state == "down" then
		if clickedElement  and getElementType(clickedElement) == "vehicle" then
			local sx,sy,sz = getElementVelocity(clickedElement)
			local driver = getVehicleOccupant(clickedElement)
			local realSpeed = ((sx^2 + sy^2 + sz^2)^(0.5)) * 180
			guiSetText(speedLabel,"Velocidade de: "..math.floor(realSpeed).." км/H")
			if driver then
				guiSetText(driverLabel,"Motorista: "..getPlayerName(driver))
			else
				guiSetText(driverLabel,"Motorista: Não encontrado")
			end
			if numberLabel then
				guiSetText(numberLabel,"Nivel de Procurado: "..getPlayerWantedLevel(driver))
			end
			if realSpeed >= chaseSpeedLimit then
				guiSetEnabled(chaseButton,true)
				guiLabelSetColor(speedLabel,255,0,0)
			else
				guiSetEnabled(chaseButton,false)
				guiLabelSetColor(speedLabel,255,255,255)
			end
			clickedVeh = clickedElement
		end
	end
end

 

Link to comment

Sim eu tentei ja usar o driver mais mesmo assim ele puxa o meu nivel de procurado nao o do player que esta dentro do carro.

Outra duvida como faço para tirar o player forçado de dentro do veiculo 

Em relação ao player forçado eu consegui

Link to comment
  • Other Languages Moderators

Tente com getVehicleController.

function click(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement)
	if isElement(chaseWindow) and button == "left" and state == "down" then
		if clickedElement  and getElementType(clickedElement) == "vehicle" then
			local sx,sy,sz = getElementVelocity(clickedElement)
			local driver = getVehicleController(clickedElement)
			local realSpeed = ((sx^2 + sy^2 + sz^2)^(0.5)) * 180
			guiSetText(speedLabel,"Velocidade de: "..math.floor(realSpeed).." км/H")
			if driver then
				guiSetText(driverLabel,"Motorista: "..getPlayerName(driver))
			else
				guiSetText(driverLabel,"Motorista: Não encontrado")
			end
			if numberLabel then
				guiSetText(numberLabel,"Nivel de Procurado: "..getPlayerWantedLevel(driver))
			end
			if realSpeed >= chaseSpeedLimit then
				guiSetEnabled(chaseButton,true)
				guiLabelSetColor(speedLabel,255,0,0)
			else
				guiSetEnabled(chaseButton,false)
				guiLabelSetColor(speedLabel,255,255,255)
			end
			clickedVeh = clickedElement
		end
	end
end

EDIT:

Testei aqui e descobri.

A função getPlayerWantedLevel sempre retornará o nível de procurado do localPlayer quando executada client-side. Tanto é que ela não usa parâmetros se estiver client-side.

Edited by Lord Henry
Link to comment
  • Other Languages Moderators

client:

function updateWanted (level)
	if numberLabel then
		guiSetText(numberLabel,"Nivel de Procurado: "..level)
	end
end
addEvent ("wantedClient", true)
addEventHandler ("wantedClient", getRootElement(), updateWanted)

function click(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement)
	if isElement(chaseWindow) and button == "left" and state == "down" then
		if clickedElement  and getElementType(clickedElement) == "vehicle" then
			local sx,sy,sz = getElementVelocity(clickedElement)
			local driver = getVehicleController(clickedElement)
			local realSpeed = ((sx^2 + sy^2 + sz^2)^(0.5)) * 180
			guiSetText(speedLabel,"Velocidade de: "..math.floor(realSpeed).." км/H")
			if driver then
				guiSetText(driverLabel,"Motorista: "..getPlayerName(driver))
				triggerServerEvent ("wantedServer", localPlayer, driver)
			else
				guiSetText(driverLabel,"Motorista: Não encontrado")
			end
			if realSpeed >= chaseSpeedLimit then
				guiSetEnabled(chaseButton,true)
				guiLabelSetColor(speedLabel,255,0,0)
			else
				guiSetEnabled(chaseButton,false)
				guiLabelSetColor(speedLabel,255,255,255)
			end
			clickedVeh = clickedElement
		end
	end
end
addEventHandler ("onClientClick", getRootElement(), click)

server:

function getWantedServer (theDriver)
	if isElement (theDriver) then
		local wantedLevel = getPlayerWantedLevel (theDriver)
		triggerClientEvent (client, "wantedClient", client, wantedLevel)
	end
end
addEvent ("wantedServer", true)
addEventHandler ("wantedServer", getRootElement(), getWantedServer)

 

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