Jump to content

Detectar Skin e ACL para pegar veículo


Recommended Posts

Salve galera estou tentando fazer um script que detecta a skin e a acl do player para ele poder pegar um veículo porém da problema na hora de detectar a skin mesmo estando com a skin do id certo ele faz o "else" que é o texto e acaba não pegando o veículo, segue o código abaixo.

 

Spawn1 = createMarker(-1013.2669067383,-1061.5272216797,129.26875305176 -1,"cylinder", 1.5, 0,255,0,70)
Destroy1 = createMarker(-1043.8754882813,-1061.3928222656,129.26875305176 -1,"cylinder", 1.9, 255,0,0,80)

veh = {}
function spawnvtr ( hitElement )
    if getElementType(hitElement) == "player" and not isPedInVehicle(hitElement) then -- Adicionado 
        if isElement( veh[hitElement] ) then
        destroyElement ( veh[hitElement] )
            local accName = getAccountName ( getPlayerAccount ( hitElement ) )
                if isObjectInACLGroup ("user."..accName, aclGetGroup ( "PMESP") ) and getElementModel (thePlayer) == 144 then
                veh[hitElement] = createVehicle(540, -1038.7395019531,-1059.2214355469,129.65295410156, -0.021297674626112, -0.001555333728902, 359.54086303711) 
                warpPedIntoVehicle ( hitElement, veh[hitElement] )
                --exports._infobox:addNotification(hitElement, "", "success")
                else
                    outputChatBox("#FFFFFF| #E10000PMESP #FFFFFF| Somente #E10000PMESP #FFFFFFPodem Pegar Este Veiculo.",hitElement,255,255,255, true)
            end
        end
    end
end

addEventHandler("onMarkerHit", Spawn1, spawnvtr)


function destroyvtr ( hitElement )
if isElement(veh[hitElement]) then
   destroyElement (veh[hitElement])
   --exports._infobox:addNotification(thePlayer, "", "success")
end
end
addEventHandler("onMarkerHit", Destroy1, destroyvtr)

Link to comment
  • Other Languages Moderators

Olá! Seja bem-vindo(a) ao fórum.

Peço para que use a formatação Code, quando for enviar códigos Lua. 30r4ST3.png

Em relação à sua dúvida, basta alterar o thePlayer para hitElement, ali dentro da função getElementModel. Você definiu na função do marker que seria hitElement o jogador, portanto não existe thePlayer.

Edited by androksi
Link to comment
13 hours ago, Unka231 said:

Salve galera estou tentando fazer um script que detecta a skin e a acl do player para ele poder pegar um veículo porém da problema na hora de detectar a skin mesmo estando com a skin do id certo ele faz o "else" que é o texto e acaba não pegando o veículo, segue o código abaixo.

 

Spawn1 = createMarker(-1013.2669067383,-1061.5272216797,129.26875305176 -1,"cylinder", 1.5, 0,255,0,70)
Destroy1 = createMarker(-1043.8754882813,-1061.3928222656,129.26875305176 -1,"cylinder", 1.9, 255,0,0,80)

veh = {}
function spawnvtr ( hitElement )
    if getElementType(hitElement) == "player" and not isPedInVehicle(hitElement) then -- Adicionado 
        if isElement( veh[hitElement] ) then
        destroyElement ( veh[hitElement] )
            local accName = getAccountName ( getPlayerAccount ( hitElement ) )
                if isObjectInACLGroup ("user."..accName, aclGetGroup ( "PMESP") ) and getElementModel (thePlayer) == 144 then
                veh[hitElement] = createVehicle(540, -1038.7395019531,-1059.2214355469,129.65295410156, -0.021297674626112, -0.001555333728902, 359.54086303711) 
                warpPedIntoVehicle ( hitElement, veh[hitElement] )
                --exports._infobox:addNotification(hitElement, "", "success")
                else
                    outputChatBox("#FFFFFF| #E10000PMESP #FFFFFF| Somente #E10000PMESP #FFFFFFPodem Pegar Este Veiculo.",hitElement,255,255,255, true)
            end
        end
    end
end

addEventHandler("onMarkerHit", Spawn1, spawnvtr)


function destroyvtr ( hitElement )
if isElement(veh[hitElement]) then
   destroyElement (veh[hitElement])
   --exports._infobox:addNotification(thePlayer, "", "success")
end
end
addEventHandler("onMarkerHit", Destroy1, destroyvtr)


local Spawn1 = createMarker(-1013.2669067383,-1061.5272216797,129.26875305176 -1,"cylinder", 1.5, 0,255,0,70)
local Destroy1 = createMarker(-1043.8754882813,-1061.3928222656,129.26875305176 -1,"cylinder", 1.9, 255,0,0,80)

local veh = {}
function spawnvtr ( hitElement )
    if hitElement and isElement(hitElement) and getElementType(hitElement) == "player" and not isPedInVehicle(hitElement) then 
        if veh[hitElement] then 
            if isElement(veh[hitElement]) then
                destroyElement (veh[hitElement])
            end
            veh[hitElement] = nil  
        end
        local conta = getPlayerAccount(hitElement)
        if conta and not isGuestAccount(conta) then 
            local accName = getAccountName ( conta )
            if isObjectInACLGroup ("user."..accName, aclGetGroup ( "PMESP") ) and getElementModel (hitElement) == 144 then
                veh[hitElement] = createVehicle(540, -1038.7395,-1059.2214,129.6529, -0.0212, -0.0015, 359.5408) 
                warpPedIntoVehicle ( hitElement, veh[hitElement] )
            else
                outputChatBox("#FFFFFF| #E10000PMESP #FFFFFF| Somente #E10000PMESP #FFFFFFPodem Pegar Este Veiculo.",hitElement,255,255,255, true)
            end
        end
    end
end

addEventHandler("onMarkerHit", Spawn1, spawnvtr)


function destroyvtr ( hitElement )
    if hitElement and isElement(hitElement) and getElementType(hitElement) == "player" then
        if veh[hitElement] then
            if isElement(veh[hitElement]) then
                destroyElement (veh[hitElement])
            end
            veh[hitElement] = nil 
        end
    end
end
addEventHandler("onMarkerHit", Destroy1, destroyvtr)

Você estava verificando a skin do elemento (thePlayer) elemento qual, não estava sendo definido em nenhum lugar na função, fiz a alteração e algumas edições para previnir futuros erros...

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