Jump to content

getPlayerName


Recommended Posts

Pessoal estou com um problema em um "script" que estou fazendo obs : sou bem leigo em programação lua

Bom Quero Fazer Um Script Que Quando O Jogador Digitar /hab Vai Aparecer No Chat O Nome Dele e Que Possui Ou Não A Habilitação , So que Quando Eu Coloco O getPlayerName Da Um Erro No Console Bem Assim :

attempt to concatenate local 'nick_do_jogador' < a boolean value >

 

Quote

function auto (  )
    if ( not getElementData ( thePlayer, "carLicense" ) and not isVehicleNoNeed ( getElementModel ( source )) ) then
        local nick_do_jogador           =   getPlayerName ( true )
            outputChatBox("#000000[#ff0000POLICIA#000000] #bebebeO Player : "..nick_do_jogador.." #ff0000Não #bebebePossui Habilitação!", root, 255, 255, 255, true)
        else
            outputChatBox("#000000[#ff0000POLICIA#000000] #bebebeO Player : "..nick_do_jogador.." #04B404Possui #bebebeHabilitação !", root, 255, 255, 255, true)
end
end
addCommandHandler ("hab", auto )

Agradeço Muito A Quem Me Ajudar :D

Edited by Katorzzee
Link to comment
  • Moderators

Tente:

function auto ( player )
	local vehicle = getPedOccupiedVehicle(player)
	local nick_do_jogador =   getPlayerName ( player )
	if not getElementData ( player, "carLicense" ) then
		if vehicle and not isVehicleNoNeed ( getElementModel ( vehicle )) then
			-- não entendi qual vai ser o uso dessa função
		end
		outputChatBox("#000000[#ff0000POLICIA#000000] #bebebeO Player : "..nick_do_jogador.." #ff0000Não #bebebePossui Habilitação!", root, 255, 255, 255, true)
	elseif getElementData ( player, "carLicense" ) then 
		outputChatBox("#000000[#ff0000POLICIA#000000] #bebebeO Player : "..nick_do_jogador.." #04B404Possui #bebebeHabilitação !", root, 255, 255, 255, true)
	end
end
addCommandHandler ("hab", auto )

 

Edited by DNL291
  • Thanks 1
Link to comment
  • Other Languages Moderators

O erro acontece pois você está tentando obter o nome de um true (valor booleano) em vez de um jogador.

Além disso, você não declarou em lugar nenhum thePlayer, isso significa que o getElementData ali sempre será false.

E também não entendi pra que serve esse isVehicleNoNeed, que também não foi declarado em lugar nenhum e portanto não funciona.

Uma pergunta: Essa mensagem do chat deve aparecer somente no chat do jogador que digitou /hab? Ou deve aparecer no chat de todo mundo?

  • Thanks 2
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...