Jump to content

tempo para entrar no carro


Recommended Posts

é possivel especificar tempo em HUD, e existem alguns erros poderiam me ajudar ?

--Fora da mission

tempoMission = 0:00

setTimer(function(source)
    if
        tempoMission = tempoMission 0:01
    end
    if tempoMission >= 4:00 then
        tempoMission () 
    end
end, 100, 0)

function createText ()
        dxDrawText("Tempo para a missão"..(tempoMission).."/4:00", 348, 4, 582, 30, tocolor(255, 255, 255, 255), 0.50, "bankgothic", "left", "top" )
end

function tempoMission ()
    destroyElement (veh[source])
end
    
--Primeira parte da Missão

Mfim = createMarker (-2404.80957, -599.06909, 132.64844 -1, "cylinder", 2, 0 ,255 ,0, 255)

function started ()
    veh[source] = (402,-2404.80957, -599.06909, 132.64844,0 ,0 ,0 )
    Bfim = createBlipAttachedTo ( veh[source], 19 )
end
addCommandHandler ( "começar", started )

setTimer(function(source)
    if isPlayerInVehicle ( veh[source] ) then

    else
        outputChatBox ( "Voçê Nao entrou no veiculo a tempo mission failed", getRootElement(), 255, 255, 255, true )
        destroyElement (veh[source])
    end
end, 300000, 0)

--segunda parte da mission

function enterCar (source)
    if veh[source] and isElement(veh[source]) then
        Bfim = createBlipAttachedTo ( veh[source], 19 )
        setElementVisibleTo ( Bfim, root, false )
    else
    end
end
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterCar )

--Terceira parte da missão

function fim (source)
    if veh[source] and isElement(veh[source]) then
        destroyElement (veh[source])
        givePlayerMoney(source,200000)
        setElementVisibleTo ( Bfim, source, false )
        outputChatBox("#00ff00Sua missão foi um sucesso",source,0,0,0,true)
    else
    end
end
addEventHandler("onMarkerHit",Mfim ,fim)

 

Link to comment
On 15/07/2018 at 10:48, Lord Henry said:

Antes de perguntar, sempre verifique se há algum erro no /debugscript 3.

E sua função createText não está sendo chamada em lugar nenhum.

Olá no debugscript 3 não aparece nenhum erro, mas quando executo a missão, quando ele não esta detectando se  o jogador entra no carro, ele apenas destroy o carro quando chega o tempo definido


--Primeira parte da Missão

Mfim = createMarker (-2404.80957, -599.06909, 132.64844 -1, "cylinder", 2, 0 ,255 ,0, 255)

vehicle = createVehicle (402,209.89941, 1905.14233, 17.64063,0 ,0 ,0)


setTimer(function(source)
    if isPlayerInVehicle ( vehicle ) then
        outputChatBox ( "Voçê esta no Vehicle", getRootElement(), 255, 255, 255, true )
    else
        outputChatBox ( "Voçê Nao entrou no veiculo a tempo mission failed", getRootElement(), 255, 255, 255, true )
        destroyElement (veh[source])
    end
end, 5000, 0)

--segunda parte da mission)

function fim (source)
    if vehicle and isElement(vehicle) then
        destroyElement (vehicle)
        givePlayerMoney(source,200000)
        outputChatBox("#00ff00Sua missão foi um sucesso",source,0,0,0,true)
    else
    end
end
addEventHandler("onMarkerHit",Mfim ,fim)

 

Edited by kevincouto6
Link to comment
  • Other Languages Moderators

No seu código existe um timer sem nome com repetição infinita, vc deveria ter feito com apenas 1 repetição.

Quote

setTimer(function(source)
    if isPlayerInVehicle ( vehicle ) then
        outputChatBox ( "Voçê esta no Vehicle", getRootElement(), 255, 255, 255, true )
    else
        outputChatBox ( "Voçê Nao entrou no veiculo a tempo mission failed", getRootElement(), 255, 255, 255, true )
        destroyElement (veh[source])
    end
end, 5000, 0)

 

 

Link to comment

--Primeira parte da Missão

Mfim = createMarker (-2404.80957, -599.06909, 132.64844 -1, "cylinder", 2, 0 ,255 ,0, 255)

vehicle = createVehicle (402,209.89941, 1905.14233, 17.64063,0 ,0 ,0)
local counter = 0

setTimer(function(source)
    for seat, player in pairs(getVehicleOccupants(vehicle)) do
    	counter = counter + 1
	end
    if counter > 0 then
        outputChatBox ( "Voçê esta no Vehicle", getRootElement(), 255, 255, 255, true )
    else
        outputChatBox ( "Voçê Nao entrou no veiculo a tempo mission failed", getRootElement(), 255, 255, 255, true )
        destroyElement (veh[source])
      	
    end
    counter = 0
end, 5000, 1)

--segunda parte da mission)

function fim (source)
    if vehicle and isElement(vehicle) then
        destroyElement (vehicle)
        givePlayerMoney(source,200000)
        outputChatBox("#00ff00Sua missão foi um sucesso",source,0,0,0,true)
    else
    end
end
addEventHandler("onMarkerHit",Mfim ,fim)

O problema de detetar se o jogador entrou no veiculo deve ficar resolvido.( não testado)

Na linha 10. Voce está passando o elemento  vehicle  na função isPlayerInVehicle . Isto é errado, para está função deve passar um elemento de um jogador. Mas como o código deve estar para o lado server ( não está claro no codigo, pois no primeiro  outputChatBox está para todos jogadores mas o segundo apenas para um jogador), a função nao é a certa para este caso .

Link to comment
  • 4 months later...
On 23/07/2018 at 00:14, DaeRoNz said:

 

Saberia me dizer como fazer para funcionar, pois 

--mission six--

Mfim6 = createMarker (-1828.72888, -1627.62219, 23.23001 -1, "cylinder", 2, 0 ,255 ,0, 255)

Bfim6 = createBlipAttachedTo ( Mfim6, 19 )
setElementVisibleTo ( Bfim6, root, false )

veh6 = {}

 -- Recomendo que evite posi��es decimais muito grandes. Use s� at� 3 casas decimais.
localitionveh6 = {
    [1] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [2] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [3] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [4] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [5] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
 -- O primeiro, quinto e sexto valor das posi��es n�o est�o sendo usados. Recomendo que delete-os.
}

i = 1 -- contador global

function inicio6 ()
    if isElement (veh6[client]) then -- Client = localPlayer, somente neste caso.
        destroyElement (veh6[client])
        veh6[client] = nil
    end
    local vx ,vy, vz, vrot = localitionveh6[ i ][ 2 ], localitionveh6[ i ][ 3 ], localitionveh6[ i ][ 4 ], localitionveh6[ i ][ 7 ]
    i = i + 1
    if i > #localitionveh6 then -- se i > 5, ent�o:
        i = 1
    end
    Trabalho = true
    veh6[client] = createVehicle ( 401, vx, vy, vz, 0, 0, vrot )
    setElementVisibleTo (Bfim6, client, true)
    outputChatBox ("#ffff00Drive the vehicle to the checkpoint. Note: You cannot leave the car during the mission.", client, 0, 0, 0, true)
    
    local counter = 0
    setTimer(function(source)
        for seat, player in pairs(getVehicleOccupants(veh6)) do
            counter = counter + 1
        end
   
        if counter > 0 then
            outputChatBox ( "Voçê esta no Vehicle", getRootElement(), 255, 255, 255, true )
        else
            outputChatBox ( "Voçê Nao entrou no veiculo a tempo mission failed", getRootElement(), 255, 255, 255, true )
            destroyElement (veh[source])        
        end
            counter = 0
    end, 5000, 1)

 

Link to comment
  • Moderators

O que está de errado que o código não funciona? Não espere que alguém pegue seu código, teste e te dê corrigido.

Pelo que eu vejo no seu código, tem variáveis que serão compartilhadas em todos jogadores por estarem no lado server.

Link to comment
1 hour ago, DNL291 said:

 

Ops, me desculpe este é o erro 

        WARNING:GUimission/server.lua:439: Bad argument @ 'getVehicleOccupants' [expected vewhicle at argument 1, got table]
        ERROR: GUimission/server.lua:439:bad argument #1 to 'pairs' (table expected, got boolean)

Link to comment
47 minutes ago, Lord Henry said:

No primeiro erro, tente colocar veh6[client] no lugar de veh6.

No segundo erro, faça a mesma coisa. Substitua o veh6 por veh6[client]

Continua aparecendo o mesmo erro

--mission six--

Mfim6 = createMarker (-1828.72888, -1627.62219, 23.23001 -1, "cylinder", 2, 0 ,255 ,0, 255)

Bfim6 = createBlipAttachedTo ( Mfim6, 19 )
setElementVisibleTo ( Bfim6, root, false )

veh6 = {}

 -- Recomendo que evite posi��es decimais muito grandes. Use s� at� 3 casas decimais.
localitionveh6 = {
    [1] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [2] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [3] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [4] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
    [5] = {401, 213.33366, 1871.35400, 13.14063, 0, 0, 270},
 -- O primeiro, quinto e sexto valor das posi��es n�o est�o sendo usados. Recomendo que delete-os.
}

i = 1 -- contador global

function inicio6 ()
    if isElement (veh6[client]) then -- Client = localPlayer, somente neste caso.
        destroyElement (veh6[client])
        veh6[client] = nil
    end
    local vx ,vy, vz, vrot = localitionveh6[ i ][ 2 ], localitionveh6[ i ][ 3 ], localitionveh6[ i ][ 4 ], localitionveh6[ i ][ 7 ]
    i = i + 1
    if i > #localitionveh6 then -- se i > 5, ent�o:
        i = 1
    end
    Trabalho = true
    veh6[client] = createVehicle ( 401, vx, vy, vz, 0, 0, vrot )
    setElementVisibleTo (Bfim6, client, true)
    outputChatBox ("#ffff00Drive the vehicle to the checkpoint. Note: You cannot leave the car during the mission.", client, 0, 0, 0, true)
    
    local counter = 0
    setTimer(function(source)
        for seat, player in pairs(getVehicleOccupants(veh6[client])) do
            counter = counter + 1
        end
   
        if counter > 0 then
            outputChatBox ( "Voçê esta no Vehicle", getRootElement(), 255, 255, 255, true )
        else
            outputChatBox ( "Voçê Nao entrou no veiculo a tempo mission failed", getRootElement(), 255, 255, 255, true )
            destroyElement (veh6[client])        
        end
            counter = 0
    end, 5000, 1)

        WARNING:GUimission/server.lua:439: Bad argument @ 'getVehicleOccupants' [expected vewhicle at argument 1, got table]
        ERROR: GUimission/server.lua:439:bad argument #1 to 'pairs' (table expected, got boolean)

Link to comment
    local counter = 0
    setTimer(function(p)
        for seat, player in pairs(getVehicleOccupants(veh6[p])) do
            counter = counter + 1
        end
   
        if counter > 0 then
            outputChatBox ( "Voçê esta no Vehicle", p, 255, 255, 255, true )
        else
            outputChatBox ( "Voçê Nao entrou no veiculo a tempo mission failed", p, 255, 255, 255, true )
            destroyElement (veh6[p])        
        end
            counter = 0
    end, 5000, 1, client)

 

Link to comment
  • Moderators

Repetindo o que falei no meu post acima, tudo vai precisar ser configurado pra funcionar individualmente já que o código é server-side, e no caso da variável 'i' e 'Trabalho' isso vai gerar erros quando outros jogadores fazerem a mesma coisa. Vale também pros elementos marker e blip que vão precisar ser ocultados e mostrados constantemente.

Link to comment
  • Moderators
9 minutes ago, Lord Henry said:

Eu sinceramente faria uma parte disso client-side. Pra não precisar me preocupar com um jogador interferindo no emprego de outro.

Mas sei lá, o pessoal parece que tem medo de usar triggers.

Isso é o que já falei várias vezes aqui, às vezes precisa ser no lado client que é o ideal para o que vai fazer e vai livrar dessas 'dores de cabeça'. Mas ele prefere fazer do jeito dele em vez de avançar; desse jeito vai aprender de uma forma bem lenta (se eu me lembro bem ele já tá há um tempão pra fazer esses códigos).

Link to comment

Olá denovo estou tentando passar para o lado Client como vcs recomendaram, algumas coisa eu consegui fazer porem exitem alguns erros que não estou conseguindo resolver 

* o veiculo esta dando spawn eu um local totalmente aleatorio

* o timer parou de funcionar, para entrar no veiculo

poderiam me dizer o que fazer, pois quero aprender 

-----------------------------------------------------------------------Client-side--------------------------------------------------------------------

veh6 = {}

localitionveh6 = {
	[1] = {401, 213.3, 1871.3, 13.1, 30, 30, 270},
	[2] = {401, 213.3, 1871.3, 13.1, 30, 30, 270},
	[3] = {401, 213.3, 1871.3, 13.1, 30, 30, 270},
	[4] = {401, 213.3, 1871.3, 13.1, 30, 30, 270},
	[5] = {401, 213.3, 1871.3, 13.1, 30, 30, 270},
}

i = 1 

function inicio6 ()

	if isElement (veh6[client]) then 
		destroyElement (veh6[client])
		veh6[client] = nil
	end
	local vx ,vy, vz, vrot = localitionveh6[ i ][ 2 ], localitionveh6[ i ][ 3 ], localitionveh6[ i ][ 4 ], localitionveh6[ i ][ 7 ]
	i = i + 1
	if i > #localitionveh6 then 
		i = 1
	end
	triggerServerEvent ("iniciaJob6", localPlayer, vx ,vy, vz, vrot	)
	Trabalho = true
	outputChatBox ("Drive the vehicle to the checkpoint. Note: You cannot leave the car during the mission.")
	
    counter = 0
	
    setTimer(function(p)
        for seat, player in pairs(getVehicleOccupants(veh6[p])) do
            counter = counter + 1
        end
  
        if counter > 0 then
            outputChatBox ( "Voçê esta no Vehicle")
        else
            outputChatBox ( "Voçê Nao entrou no veiculo a tempo mission failed")
            destroyElement (veh6[p])        
        end
            counter = 0
	end, 5000, 1, client)
		
end
addCommandHandler ( "go", inicio6 ) 

este é o lado server 

--------------------------------------------------------------------------server----------------------------------------------------------------------------

function callClientFunction (inicio6, vx ,vy, vz, vrot)
	veh6 = createVehicle ( 401, vx, vy, vz, 0, 0, vrot )
end
addEvent ("iniciaJob6", true) 
addEventHandler ("iniciaJob6", getRootElement(), callClientFunction)

 

Edited by kevincouto6
Link to comment
  • Other Languages Moderators

Vc esqueceu que o veículo deve estar na tabela veh6? Passe a tabela pro lado server e crie o veículo como veh6[client].

Outra coisa: Aquelas verificações de isElement do veículo que você colocou no client, também devem estar no lado server.

Edited by Lord Henry
Link to comment

Olá deixei apenas a parte de criar o veiculo agora 

esta é a parte server

function inicio6 ()
    if isElement (veh6[client]) then 
        destroyElement (veh6[client])
        veh6[client] = nil
    end
    local vx ,vy, vz, vrot = localitionveh6[ i ][ 2 ], localitionveh6[ i ][ 3 ], localitionveh6[ i ][ 4 ], localitionveh6[ i ][ 7 ]
    i = i + 1
    if i > #localitionveh6 then 
        i = 1
    end
    Trabalho = true
    veh6[client] = createVehicle ( 401, vx, vy, vz, 0, 0, vrot )
    setElementVisibleTo (Bfim6, client, true)
    outputChatBox ("#ffff00Drive the vehicle to the checkpoint. Note: You cannot leave the car during the mission.", client, 0, 0, 0, true)
    triggerClientEvent (client, "mission6", client,veh6)

end
addEvent ("iniciaJob6", true) 
addEventHandler ("iniciaJob6", getRootElement(), inicio6)

e este o lado server , o primeiro erro que aparece no debbug é  "do" ( expected near )

function partClientSixMission (veh6)	
 
    local counter = 0
    setTimer(function(p)
        for seat, player in pairs??(getVehicleOccupants(veh6[p])) do
            counter = counter + 1
        end
   
        if counter > 0 then
            outputChatBox ( "Voçê esta no Vehicle", p, 255, 255, 255, true )
        else
            outputChatBox ( "Voçê Nao entrou no veiculo a tempo mission failed", p, 255, 255, 255, true )
            destroyElement (veh6[p])        
        end
            counter = 0
    end, 5000, 1)

		local player6 = client
	addEventHandler ( "onClientVehicleExplode", veh6[client], function ()
		if (veh6[player6]) and isElement(veh6[player6]) then
			destroyElement (source)
			takePlayerMoney ( player6, 5000 )
			setElementVisibleTo ( Bfim6, player6, false )
			outputChatBox("Mission failed, your veh6icle blew up.", player6 , 255, 0, 0)
		end
	end)	
	
end
addEvent ("mission6", true)
addEventHandler ("mission6", localPlayer, partClientSixMission)

 

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