Jump to content

[Ajuda]Wanted Level


Recommended Posts

Posted (edited)

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
  • Moderators
Posted

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

 

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

Posted

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

Posted (edited)

Nao consegui ele ainda puxa o meu nivel de procurado e nao ah do jogador que esta no veiculo

Edited by LucasMTA
  • Moderators
Posted (edited)

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

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

  • Moderators
Posted

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)

 

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

  • Moderators
Posted (edited)

De nada. Deixe um thanks pra me ajudar.

Edited by Lord Henry

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

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