Jump to content

mais de um veiculo so que so um container


Recommended Posts

E continuando meus estudos . estou muito feliz pq ta dando muito certo meu script ja esta pronto , eu so estou querendo add mais cminhoes com a mesma funçao.

me ajudem oque tenho que fazer. eu tentei desse jeito e foi sem sucesso!

function inicio ()
caminhao2 = createVehicle (515, 1212.864, -1278.703, 13.383+1)
caminhao1 = createVehicle (515, 1173.368, -1281.613, 13.491+1)
caminhao = createVehicle (515, 1194.816, -1297.128, 13.384+1)
trailer = createVehicle (584, 1204.033, -1299.422, 13.386+1)
addEventHandler ( "onTrailerAttach", trailer, teste )
addEventHandler("onTrailerDetach", trailer, desgrudar)
setVehicleDamageProof(trailer, true)
blipT = createBlipAttachedTo(trailer,51)
setTimer( tempo, 30000, 1 )
outputChatBox("#0000FF----------------------------------------------------------------------------------------------------------------",root,255,255,255,true)
outputChatBox("#00FF00Sobrevivente #FFFFFFPrecisamos da sua ajuda para transportar suprimentos que",root,255,255,255,true)
outputChatBox("serao vendidos na safezone! Marcamos em seu GPS a localizacao da carga.",root,255,255,255,true)
outputChatBox("Mas se apresse! Voce tem apenas 15 minutos. Tome cuidado pois muita gente",root,255,255,255,true)
outputChatBox("deseja roubar esses suprimentos. Boa sorte!!",root,255,255,255,true)
outputChatBox("#0000FF----------------------------------------------------------------------------------------------------------------",root,255,255,255,true)
end 
addCommandHandler("teste",inicio)
function teste ()
    marker = createMarker(1196.796, -1328.896, 12, "cylinder",3,255,255,255,50)
    blipM = createBlipAttachedTo(marker,53)
    addEventHandler("onMarkerHit", marker, final)
end
function final (player)
    if getElementType(player) == "player" then
        local veh = getPedOccupiedVehicle(player)
        if veh and veh == caminhao then
        if veh and veh == caminhao1 then
        if veh and veh == caminhao2 then
            destroyElement(caminhao)
            destroyElement(caminhao1)
            destroyElement(caminhao2)
            destroyElement(marker)
            destroyElement(trailer)
            destroyElement(blipM)
            destroyElement(blipT)
            givePlayerMoney(player, 1000)
            outputChatBox("Parabens! voce conseguiu trazer a carga em segurança!!",player,255,255,255,true)
            outputChatBox("Voce sera reconpensado com #00FF001000 #FFFFFFreais...",player,255,255,255,true)
            outputChatBox("#00FF00A Carga de suprimentos foi entregue em segurança para a safezone!",root,255,255,255,true)
        end
    end
end
function desgrudar ()
destroyElement(marker)
end
function tempo ()
destroyElement(caminhao)
destroyElement(caminhao1)
destroyElement(caminhao2)
destroyElement(trailer)
destroyElement(blipT)
destroyElement(marker)
destroyElement(blipM)
end

desculpem a desordem ainda nao peguei o jeito de organizar!

Edited by Lord Henry
Script convertido de texto para Lua.
Link to comment
  • Other Languages Moderators

Bom, no seu caso eu colocaria todos os caminhões numa table. Depois usaria um loop pela table para verificar o caminhão correto.

E já vi que você errou na lógica em alguns lugares. Use o /debugscript 3 para detectar os erros.

Edited by Lord Henry
  • Confused 1
Link to comment

o poblema e que eu nao estou conseguindo igualar os caminhoes para darem as mesmas funcoes a todos!

function final (player)
    if getElementType(player) == "player" then
        local veh = getPedOccupiedVehicle(player)
        if veh and veh == caminhao then
        if veh and veh == caminhao1 then
        if veh and veh == caminhao2 then
            destroyElement(caminhao)
            destroyElement(caminhao1)
            destroyElement(caminhao2)
            destroyElement(marker)
            destroyElement(trailer)
            destroyElement(blipM)
            destroyElement(blipT)
            givePlayerMoney(player, 1000)
            outputChatBox("Parabens! voce conseguiu trazer a carga em segurança!!",player,255,255,255,true)
            outputChatBox("Voce sera reconpensado com #00FF001000 #FFFFFFreais...",player,255,255,255,true)
            outputChatBox("#00FF00A Carga de suprimentos foi entregue em segurança para a safezone!",root,255,255,255,true)
        end
    end
end

 

Link to comment
  • Other Languages Moderators

Bom, pra começar, isso:

if veh and veh == caminhao then
if veh and veh == caminhao1 then
if veh and veh == caminhao2 then

Deve ser assim:

if veh and veh == caminhao then
    if veh and veh == caminhao1 then
        if veh and veh == caminhao2 then

 


E isso:

        end
    end
end

Vira isso:

                end
            end
        end
    end
end

 

Link to comment
function inicio ()
    caminhao2 = createVehicle (515, 1212.864, -1278.703, 13.383+1)
    caminhao1 = createVehicle (515, 1173.368, -1281.613, 13.491+1)
    caminhao = createVehicle (515, 1194.816, -1297.128, 13.384+1)
    trailer = createVehicle (584, 1204.033, -1299.422, 13.386+1)
    addEventHandler ( "onTrailerAttach", trailer, teste )
    addEventHandler("onTrailerDetach", trailer, desgrudar)
    setVehicleDamageProof(trailer, true)
    blipT = createBlipAttachedTo(trailer,51)
    setTimer( tempo, 30000, 1 )
    outputChatBox("#0000FF----------------------------------------------------------------------------------------------------------------",root,255,255,255,true)
    outputChatBox("#00FF00Sobrevivente #FFFFFFPrecisamos da sua ajuda para transportar suprimentos que",root,255,255,255,true)
    outputChatBox("serao vendidos na safezone! Marcamos em seu GPS a localizacao da carga.",root,255,255,255,true)
    outputChatBox("Mas se apresse! Voce tem apenas 15 minutos. Tome cuidado pois muita gente",root,255,255,255,true)
    outputChatBox("deseja roubar esses suprimentos. Boa sorte!!",root,255,255,255,true)
    outputChatBox("#0000FF----------------------------------------------------------------------------------------------------------------",root,255,255,255,true)
end 
addCommandHandler("teste",inicio)

function teste ()
    marker = createMarker(1196.796, -1328.896, 12, "cylinder",3,255,255,255,50)
    blipM = createBlipAttachedTo(marker,53)
    addEventHandler("onMarkerHit", marker, final)
end

function final (player)
    if getElementType(player) == "player" then
        local veh = getPedOccupiedVehicle(player)
        if veh and veh == caminhao then
            if veh and veh == caminhao1 then
                if veh and veh == caminhao2 then
                    destroyElement(caminhao)
                    destroyElement(caminhao1)
                    destroyElement(caminhao2)
                    destroyElement(marker)
                    destroyElement(trailer)
                    destroyElement(blipM)
                    destroyElement(blipT)
                    givePlayerMoney(player, 1000)
                    givePlayerMoney(player, 1000)
                    outputChatBox("Parabens! voce conseguiu trazer a carga em segurança!!",player,255,255,255,true)
                    outputChatBox("Voce sera reconpensado com #00FF001000 #FFFFFFreais...",player,255,255,255,true)
                    outputChatBox("#00FF00A Carga de suprimentos foi entregue em segurança para a safezone!",root,255,255,255,true)
                end
            end
        end
    end
end

function desgrudar ()
    destroyElement(marker)
end

function tempo ()
    destroyElement(caminhao)
    destroyE

pf me ajuda to quebrando a cabeça com isso

os caminhoes nao executam a funçao final

Edited by Lord Henry
Corrigida indentação.
Link to comment

function inicio ()
caminhao2 = createVehicle (515, 1212.864, -1278.703, 13.383+1)
caminhao1 = createVehicle (515, 1173.368, -1281.613, 13.491+1)
caminhao = createVehicle (515, 1194.816, -1297.128, 13.384+1)
trailer = createVehicle (584, 1204.033, -1299.422, 13.386+1)
addEventHandler ( "onTrailerAttach", trailer, teste )
addEventHandler("onTrailerDetach", trailer, desgrudar)
setVehicleDamageProof(trailer, true)
blipT = createBlipAttachedTo(trailer,51)
setTimer( tempo, 30000, 1 )
outputChatBox("#0000FF----------------------------------------------------------------------------------------------------------------",root,255,255,255,true)
outputChatBox("#00FF00Sobrevivente #FFFFFFPrecisamos da sua ajuda para transportar suprimentos que",root,255,255,255,true)
outputChatBox("serao vendidos na safezone! Marcamos em seu GPS a localizacao da carga.",root,255,255,255,true)
outputChatBox("Mas se apresse! Voce tem apenas 15 minutos. Tome cuidado pois muita gente",root,255,255,255,true)
outputChatBox("deseja roubar esses suprimentos. Boa sorte!!",root,255,255,255,true)
outputChatBox("#0000FF----------------------------------------------------------------------------------------------------------------",root,255,255,255,true)
end 
addCommandHandler("teste",inicio)
function teste ()
	marker = createMarker(1196.796, -1328.896, 12, "cylinder",3,255,255,255,50)
	blipM = createBlipAttachedTo(marker,53)
	addEventHandler("onMarkerHit", marker, final)
end
function final (player)
    if getElementType(player) == "player" then
        local veh = getPedOccupiedVehicle(player)
        if veh and veh == caminhao then
			local veh1 = getPedOccupiedVehicle(player)
            if veh1 and veh1 == caminhao1 then
				local veh2 = getPedOccupiedVehicle(player)
                if veh2 and veh2 == caminhao2 then
                    destroyElement(caminhao)
                    destroyElement(caminhao1)
                    destroyElement(caminhao2)
                    destroyElement(marker)
                    destroyElement(trailer)
                    destroyElement(blipM)
                    destroyElement(blipT)
                    givePlayerMoney(player, 1000)
		            givePlayerMoney(player, 1000)
			        outputChatBox("Parabens! voce conseguiu trazer a carga em segurança!!",player,255,255,255,true)
			        outputChatBox("Voce sera reconpensado com #00FF001000 #FFFFFFreais...",player,255,255,255,true)
			        outputChatBox("#00FF00A Carga de suprimentos foi entregue em segurança para a safezone!",root,255,255,255,true)
                end
            end
        end
    end
end
function desgrudar ()
destroyElement(marker)
end
function tempo ()
destroyElement(caminhao)
destroyElement(caminhao1)
destroyElement(caminhao2)
destroyElement(trailer)
destroyElement(blipT)
destroyElement(marker)
destroyElement(blipM)
end

desculpe copiei erado

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