Jump to content

Por favor me ajuda com o meu script


Recommended Posts

Estou tentando fazer um script para os policiais, para ver os procurados no servidor, mas não consigo achar o meu erro, (não manjo de script), por favor me ajuda, esse script é para por em um celular.

Meu script:

 

addCommandHandler ("Procurados", Procurados)
isObjectInACLGroup  (Player,Policia)
aclGetGroup  (Policia)
local players = getElementsByType ( "player" )
for theKey,thePlayer in ipairs(players) do
    if ( isPlayerInVehicle ( thePlayer ) ) then
       outputChatBox ( getPlayerName ( thePlayer ) .. "Está em um veiculo" )
        else
         outputChatBox ( getPlayerName ( thePlayer ) .. "está a pé" )
        end
    end
local level = getPlayerWantedLevel ( thePlayer )
    if ( level > 0 ) then 
      outputChatBox ( getPlayerName ( thePlayer ) .. " Player procurado por " .. level .. "  de estrelas!" )
    end
end    
getPlayerName  ( thePlayer )
    function(playerSource)
       outputChatBox ("Nome:".. getPlayerName (playerSource),playerSource)
    end
    

Link to comment
  • Other Languages Moderators

Utilize a opção <> do fórum para postar seu código.

bLankbMBQZKXC6j0YcADtg.png

E de cara já da pra ver que seu código não tem função. Você abre o evento e anexa ele a uma função que não existe.

Vc pode descobrir esses erros de sintaxe usando /debugscript 3 no jogo. Use esse comando e depois dê start nesse resource para aparecer os erros.

Link to comment
addCommandHandler( "procurados", function (player, cmd)
isObjectInACLGroup  (Player,Policia)
aclGetGroup  (Policia)
local players = getElementsByType ( "player" )
for theKey,thePlayer in ipairs(players) do
    if ( isPlayerInVehicle ( thePlayer ) ) then
       outputChatBox ( getPlayerName ( thePlayer ) .. "Está em um veiculo" )
        else
         outputChatBox ( getPlayerName ( thePlayer ) .. "está a pé" )
		end
	end
local level = getPlayerWantedLevel ( thePlayer )
    if ( level > 0 ) then 
	  outputChatBox ( getPlayerName ( thePlayer ) .. " Player procurado por " .. level .. "  de estrelas!" )
	end
end	
getPlayerName  ( thePlayer )
    function(playerSource)
       outputChatBox ("Nome:".. getPlayerName (playerSource),playerSource)
	end
	

O script está assim me expliquem oq eu fiz de errado ?

Link to comment
function playersProcurados (me)
    local acc = getPlayerAccount (me)
    if isObjectInACLGroup ( "user." ..getAccountName(acc), aclGetGroup ( "ACL_NOME" ) ) then
        local everybody = getElementsByType ("player")
        outputChatBox ("Players procurados: #FFFFFF", me, 255, 150, 0, true)
        for i, thePlayer in ipairs (everybody) do
            local wantedLevel = getPlayerWantedLevel (thePlayer)
            if (wantedLevel > 0) then
                outputChatBox ("-> #FFFFFF"..getPlayerName(thePlayer).." #FF0000("..wantedLevel..") #FFFFFFEstrelas", me, 255, 0, 0, true)
            else
                outputChatBox ( "Nenhum procurado foi encontrado !", me, 0, 255, 0)
            end    
        end
    else
        outputChatBox ( "Você não é da profissão ACL_NOME !", me, 255, 0, 0)
    end    
end    
addCommandHandler ("procurados", playersProcurados)

~ Caso acontecer algum erro, deve ter sido na hora de copiar, para ajeitar, deve-se refazer a linha.

~ Não fiz comentários, deixei pra você ler.

3 minutes ago, JohwXD said:

addCommandHandler( "procurados", function (player, cmd)
isObjectInACLGroup  (Player,Policia)
aclGetGroup  (Policia)
local players = getElementsByType ( "player" )
for theKey,thePlayer in ipairs(players) do
    if ( isPlayerInVehicle ( thePlayer ) ) then
       outputChatBox ( getPlayerName ( thePlayer ) .. "Está em um veiculo" )
        else
         outputChatBox ( getPlayerName ( thePlayer ) .. "está a pé" )
		end
	end
local level = getPlayerWantedLevel ( thePlayer )
    if ( level > 0 ) then 
	  outputChatBox ( getPlayerName ( thePlayer ) .. " Player procurado por " .. level .. "  de estrelas!" )
	end
end	
getPlayerName  ( thePlayer )
    function(playerSource)
       outputChatBox ("Nome:".. getPlayerName (playerSource),playerSource)
	end
	

O script está assim me expliquem oq eu fiz de errado ?

Cara, não vai adiantar eu explicar, se você não sabe a lógica da programação. Para você criar um script, deve ter uma lógica, no caso uma sequência de comandos que vai segundo uma lógica.
O Cria Jogos, é um canal que ensinou este assunto. Dê uma procurada lá.

  • Like 1
Link to comment
  • Moderators

Tente isto (não testado) :

addCommandHandler( "procurados",
	function (player, cmd)
		if isObjectInACLGroup( "user." ..getAccountName(getPlayerAccount(player)), aclGetGroup( "Policia" ) ) then
			local wantedPlayers = getWantedPlayers()
			outputChatBox( "[Polícia] Jogadores procurados:", player, 220, 20, 20 )
			if wantedPlayers == 0 then
				return outputChatBox( "Nenhum jogador com nível de procurado no momento!", player, 30, 30, 230 )
			end
			for wp in pairs(wantedPlayers) do
				local level = getPlayerWantedLevel ( wp )
				outputChatBox ( "Jogador: '"..getPlayerName ( wp ) .. "' procurado por: " .. tostring(level) .. " níve"..(level > 1 and "is" or "l").." de estrela(s)!", player, 30, 30, 230 )
			end
		end
	end
)

function getWantedPlayers()
	local players = {}
	for _,thePlayer in ipairs(getElementsByType ( "player" )) do
		local level = getPlayerWantedLevel ( thePlayer )
		if ( level > 0 ) then 
			players[ thePlayer ] = true
		end
	end
	return (tablelength(players) > 0) and players or 0
end

function tablelength(T)
	local count = 0
	for _ in pairs(T) do count = count + 1 end
	return count
end

 

Edited by DNL291
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...