Jump to content

[RESOLVIDO] Error Nil value


Recommended Posts

Bom, muita gente está pedindo um algemar estilo do bvz, algo que seja semelhante, fui tentar algo, como não sei muito o que fazer pensei em uma forma de attach elements e doorstate, porem deu um erro, juntei algumas funçoes de um outro mod meu, creio que isso n faria nenhuma alteração no script, tentei colocar isso e deu esse erro: attempt to call global 'getPlayerFromPartialName' ( a nil value ) alguem sabe oque tem de erro nesse script?

function doesVehicleHaveDoorOpen(thePlayer, comando, nick, vehicle) 
    if nick then 
        if getPlayerFromPartialName ( nick ) then 
            local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
            if isObjectInACLGroup ("user."..accName, aclGetGroup ( "ComandosPolicia") ) then -- Acl Pra Quem Pode Usar o Comando 
    local player_a_ser_algemado    =   getPlayerFromPartialName ( nick ) 
    local nick_do_jogador           =   getPlayerName ( player_a_ser_algemado ) 
    local nick_do_policial          =   getPlayerName ( thePlayer ) 
    local vehicle = getPedOccupiedVehicle(thePlayer) 
    local isDoorAjar = false 
    for i=0,5 do 
        local doorState = getVehicleDoorState(vehicle, i) 
        if doorState == 6 then 
            isDoorAjar = true 
            attachElements ( isDoorAjar, thePlayer, 0, 0, 2 ) 
        end 
    end 
    return isDoorAjar 
end 
end 
end 
end 
addCommandHandler("algemar", doesVehicleHaveDoorOpen) 

Edited by Guest
Link to comment

Olha, acho que seu script está faltando a função

getPlayerFromPartialName 

que está na WIKI.. tente isso

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 doesVehicleHaveDoorOpen(thePlayer, comando, nick, vehicle) 
    if nick then 
        if getPlayerFromPartialName ( nick ) then 
            local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
            if isObjectInACLGroup ("user."..accName, aclGetGroup ( "ComandosPolicia") ) then -- Acl Pra Quem Pode Usar o Comando 
    local player_a_ser_algemado    =   getPlayerFromPartialName ( nick ) 
    local nick_do_jogador           =   getPlayerName ( player_a_ser_algemado ) 
    local nick_do_policial          =   getPlayerName ( thePlayer ) 
    local vehicle = getPedOccupiedVehicle(thePlayer) 
    local isDoorAjar = false 
    for i=0,5 do 
        local doorState = getVehicleDoorState(vehicle, i) 
        if doorState == 6 then 
            isDoorAjar = true 
            attachElements ( isDoorAjar, thePlayer, 0, 0, 2 ) 
        end 
    end 
    return isDoorAjar 
end 
end 
end 
end 
addCommandHandler("algemar", doesVehicleHaveDoorOpen) 

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