Jump to content

O.G Kash

Members
  • Posts

    12
  • Joined

  • Last visited

Posts posted by O.G Kash

  1. 1 hour ago, [M]ister said:
    
    local arr = {
    	{ 2455.423, -2079.331, 12.547 },
    	{ 2458.529, -2078.655, 12.547 },
    	{ 2462.126, -2078.502, 12.547 },
    }
    
    function test ()
        local index = math.random(#arr)
        local x,y,z = table.unpack(arr[index])
        createMarker(x, y, z, "cylinder", 1.5, 50, 100, 255, 100)
    end
    addCommandHandler("teste", test)
    

     

    ta dando esse erro:

    7r6Q0gh.png

  2. Eu havia criado 3 markers, porém queria que eles aparecessem de forma aleatória (que de forma aleatória fosse escolhido qual deles ia ser criado), porém o jeito que eu estava fazendo não dava certo.

    Isso foi o que fiz até agora:

    function randomValue(arr)
    	local tempTable = {}
    	for key, value in pairs(arr) do
    		table.insert(tempTable, value)
    	end
    	return tempTable[math.random(#tempTable)]
    end
    
    local arr = {
    	pos1 = 2455.423, -2079.331, 12.547,
    	pos2 = 2458.529, -2078.655, 12.547,
    	pos3 = 2462.126, -2078.502, 12.547,
    }
    
    function test ()
    	createMarker(randomValue(arr), "cylinder", 1.5, 50,100,255, 100)
    end
    addCommandHandler("teste", test)

    Quando eu do o comando "/teste" (que no caso era pra criar um dos markers), aparece o seguinte erro:

    zmhI6MU.png

  3. Fixei um marker em um veiculo, fui colocar uma função no marker (onMarkerHit) porém não funcionou.

    O que fiz:

    mcarregar = createMarker(-1085.234, -1609.752, 75.367, "cylinder", 2, 255,100,100, 60)
    
    Carregar = true
    Van = createVehicle(482, -1086.357, -1615.635, 76.367, 0, 0, -90)
    mvan = createMarker(0,0,0, "cylinder", 1, 255,100,100, 70)
    
    function carregar ( thePlayer )
    	if Carregar == true then
    		droga = createObject (1578, 0,0,0,0,0,0, true)
    		setPedAnimation(thePlayer, "carry", "crry_prtial", 1, false, true)
    		attachElements ( mvan, Van, 0, -3, -1.2 )
    		attachElements ( droga, thePlayer, 0, 0.4, 0.3)
    		drogac = true
    	end
    end
    addEventHandler("onMarkerHit", mcarregar, carregar)
    
    function drogaca ( player )
    	if drogac == true then
        	setPedAnimation(thePlayer, "carry", "crry_prtial", 1, false, true)
      	end
    end
    addEventHandler("onMarkerHit", mvan, drogaca)

     

  4. Estou querendo fazer com que o comando seja executado apenas dentro de um veículo específico (id 596), porém não está funcionando corretamente, e mesmo que eu esteja dentro do veículo aparece a mensagem que era pra mostrar apenas se eu não estivesse no veículo.

    function verPorte ( player, cmd, name, theVehicle)
      local alvo = findPlayer(name)
      local id = getElementModel(theVehicle)
      if id == 596 then
        if name and getElementData(alvo, "porte") == true then
          outputChatBox("O(a) " ..getPlayerName(alvo).. " possui um porte de arma válido.", player, 255,255,255, true)
          else
          outputChatBox("O(a) " ..getPlayerName(alvo).. " não possui um porte de arma valido.", player, 255,255,255, true)
          end
        else
        outputChatBox("Você não esta em uma viatura policial.", player, 255,255,255, true)
        end
      end
    addCommandHandler("vporte", verPorte)

     

  5. Estou querendo fazer com que o player inicie uma animação e ele fique congelado.

    Isso foi o que eu fiz:

    function anim (player)
      local animation = setPedAnimation (player, "int_house", "wash_up", 10000, true, false, false, false)
      if animation then
        setElementFrozen (player, true)
        setTimer (setElementFrozen, 10000, 1, player, false)
        end
      end
    addEventHandler ("onMarkerHit", m1, anim)

     

  6. Havia criado outro tópico pois queria entender mais da função bindKey, diferente do outro que era algo mais voltado pra apenas uma parte dela, mas acho que eu deveria realmente ter perguntado no meu outro tópico, mesmo assim, obrigado pelas respostas.

  7. Estava fazendo um sistema que em uma parte dele seria preciso utilizar uma bind dentro de um marker para criar um veiculo. Fiz tudo certo, porém, fiz no client-side e acabei sabendo que veículos criados no client-side serviriam apenas para "enfeite", tentei então aprender a como fazer bind no server-side, li na wiki do mta e vi videos relacionados a ela, mas não consegui fazer da maneira correta.

    Ainda estou confuso com a função bindKey, então se tiver alguém que possa me explicar um pouco dela ou pelo menos me ajudar dizendo o que esta de errado no código, ficarei grato.

    local g1 = createMarker (1517.796, -694.59, 92.00, "cylinder", 3.0, 184,0,0, 150)
    
    function buffalo ()
    	bindKey (source, "e", "down",
    function(thePlayer, player)
        if isElementWithinMarker(thePlayer, g1) then
            createVehicle(551, 1517.6644287109,-689.70690917969,94.75)
        end
        end)
    end 
    addEventHandler ("onPlayerLogin", getRootElement(), buffalo)

     

  8. 3 minutes ago, Jonas^ said:
    
    local g1 = createMarker (1517.796, -694.59, 92.00, "cylinder", 3.0, 184,0,0, 150)
    
    addEventHandler ("onClientKey", root, function (btn, press)
        if isElementWithinMarker (localPlayer, g1) and press then
            if btn == "e" then 
                createVehicle (402, 1517.172, -690.4, 94.75, 0, 0, 100)
            end
        end
    end)
    
    • pressOrRelease: This refers to whether they were pressing or releasing the key, true when pressing, false when releasing.

    É necessário verificar se a tecla esta pressionada ou solta.

    Obrigado! Porem ele esta spawnando o veiculo mas não estou conseguindo entrar. É bug do meu mta ou do codigo?

  9. Estou fazendo um sistema que ao passar pelo marker e apertar "e", spawnaria um veiculo, porem esta spawnando 2 veiculos (quando aperta e quando solta a tecla), mas queria que spawnasse apenas quando apertasse.

    O código esta assim: 

    local g1 = createMarker (1517.796, -694.59, 92.00, "cylinder", 3.0, 184,0,0, 150)
    
    addEventHandler ("onClientMarkerHit", g1, function()
    addEventHandler ("onClientKey", root, function (button, press)
    if isElementWithinMarker (localPlayer, g1) then
    	if button == "e" then
            createVehicle ( 402, 1517.172, -690.4, 94.75, 0, 0, 100)
        end 
    end 
    end )
    end )

     

×
×
  • Create New...