Jump to content

[AJUDA] createVehicle


Recommended Posts

function kart(M, _, T) 
        local x1, y1 = getElementPosition(M) 
        for _,Pl in ipairs(getElementsByType("player")) do 
            local x2, y2 = getElementPosition(Pl) 
            local Distance = getDistanceBetweenPoints2D(x1, y1, x2, y2) 
            if (Distance <= 30) then 
            outputChatBox("#00FFFF[EVENTO] Você ganhou um Kart [571] ", Pl, 0, 255, 0, true)  
            createVehicle ( 432, Pl + 10 ) 
            end 
   end 
        end 
addCommandHandler("darkart", kart) 

o que ta errado? -_-

ah e uma dúvida tem como eu colocar para na hora de digitar /darveiculo [id] ? ( só para quem ta perto )

Link to comment
  • Moderators

O erro está na função createVehicle, primeiramente é o ID do veículo - que não confere com o do script (571), o outro erro está nas posições para criar o veículo.

Código:

  
function kart(M, _, T) 
    local x1, y1 = getElementPosition(M) 
    for _,Pl in ipairs(getElementsByType("player")) do 
        local x2, y2, z = getElementPosition(Pl) 
        local Distance = getDistanceBetweenPoints2D(x1, y1, x2, y2) 
        if (Distance <= 30) then 
            outputChatBox("#00FFFF[EVENTO] Você ganhou um Kart [571] ", Pl, 0, 255, 0, true) 
            createVehicle( 571, x2, y2, z + 10 ) 
        end 
    end 
end 
addCommandHandler("darkart", kart) 

ah e uma dúvida tem como eu colocar para na hora de digitar /darveiculo [id] ? ( só para quem ta perto )

Tente isto:

  
addCommandHandler( "darveiculo", 
    function (playerSource, cmdName, ID) 
        local px, py = getElementPosition(playerSource) 
        local vehName = getVehicleNameFromModel(ID) 
        if ID and type(vehName) ~= "string" then 
            return outputChatBox("O ID do veículo é inválido", playerSource, 225, 0, 0) 
        elseif not ID then 
            return outputChatBox("Sintaxe: /darveiculo ID", playerSource, 225, 0, 0) 
        end 
        for _,Pl in ipairs(getElementsByType("player")) do 
            local x, y, z = getElementPosition(Pl) 
            local Distance = getDistanceBetweenPoints2D(px, py, x, y) 
            if (Distance <= 30) then 
                outputChatBox("Você ganhou o veículo "..vehName, Pl, 0, 255, 0) 
                createVehicle( ID, x, y, z + 6 ) 
            end 
        end 
    end 
) 
  

Link to comment
O erro está na função createVehicle, primeiramente é o ID do veículo - que não confere com o do script (571), o outro erro está nas posições para criar o veículo.

Código:

  
function kart(M, _, T) 
    local x1, y1 = getElementPosition(M) 
    for _,Pl in ipairs(getElementsByType("player")) do 
        local x2, y2, z = getElementPosition(Pl) 
        local Distance = getDistanceBetweenPoints2D(x1, y1, x2, y2) 
        if (Distance <= 30) then 
            outputChatBox("#00FFFF[EVENTO] Você ganhou um Kart [571] ", Pl, 0, 255, 0, true) 
            createVehicle( 571, x2, y2, z + 10 ) 
        end 
    end 
end 
addCommandHandler("darkart", kart) 

ah e uma dúvida tem como eu colocar para na hora de digitar /darveiculo [id] ? ( só para quem ta perto )

Tente isto:

  
addCommandHandler( "darveiculo", 
    function (playerSource, cmdName, ID) 
        local px, py = getElementPosition(playerSource) 
        local vehName = getVehicleNameFromModel(ID) 
        if ID and type(vehName) ~= "string" then 
            return outputChatBox("O ID do veículo é inválido", playerSource, 225, 0, 0) 
        elseif not ID then 
            return outputChatBox("Sintaxe: /darveiculo ID", playerSource, 225, 0, 0) 
        end 
        for _,Pl in ipairs(getElementsByType("player")) do 
            local x, y, z = getElementPosition(Pl) 
            local Distance = getDistanceBetweenPoints2D(px, py, x, y) 
            if (Distance <= 30) then 
                outputChatBox("Você ganhou o veículo "..vehName, Pl, 0, 255, 0) 
                createVehicle( ID, x, y, z + 6 ) 
            end 
        end 
    end 
) 
  

o veículo cai em cima dele eahuyeagyusad como q faz pra ele ja entrar no carro ?

Link to comment

Não testei mas penso que de certo.

Alterei também a coordenadas de onde o veiculo vai cair. (penso que também de certo).

  
addCommandHandler( "darveiculo", 
    function (playerSource, cmdName, ID) 
        local px, py = getElementPosition(playerSource) 
        local vehName = getVehicleNameFromModel(ID) 
        if ID and type(vehName) ~= "string" then 
            return outputChatBox("O ID do veículo é inválido", playerSource, 225, 0, 0) 
        elseif not ID then 
            return outputChatBox("Sintaxe: /darveiculo ID", playerSource, 225, 0, 0) 
        end 
        for _,Pl in ipairs(getElementsByType("player")) do 
            local x, y, z = getElementPosition(Pl) 
            local Distance = getDistanceBetweenPoints2D(px, py, x, y) 
            if (Distance <= 30) then 
                outputChatBox("Você ganhou o veículo "..vehName, Pl, 0, 255, 0) 
                local veiculo = createVehicle( ID, x+2, y+2, z+1 ) 
                 warpPedIntoVehicle (playerSource, veiculo )    
            end 
        end 
    end 
) 

Link to comment
  
addCommandHandler( "darveiculo", 
    function (playerSource, cmdName, ID) 
        local px, py = getElementPosition(playerSource) 
        local vehName = getVehicleNameFromModel(ID) 
        if ID and type(vehName) ~= "string" then 
            return outputChatBox("O ID do veículo é inválido", playerSource, 225, 0, 0) 
        elseif not ID then 
            return outputChatBox("Sintaxe: /darveiculo ID", playerSource, 225, 0, 0) 
        end 
        for _,Pl in ipairs(getElementsByType("player")) do 
            local x, y, z = getElementPosition(Pl) 
            local Distance = getDistanceBetweenPoints2D(px, py, x, y) 
            if (Distance <= 30) then 
                outputChatBox("Você ganhou o veículo "..vehName, Pl, 0, 255, 0) 
                local veiculo = createVehicle( ID, x, y, z ) 
                 warpPedIntoVehicle (Pl, veiculo )   
            end 
        end 
    end 
) 

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