Jump to content

[M]ister

Members
  • Posts

    444
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by [M]ister

  1. Deve funcionar:

    -- SERVER
    local garageCarCube = createMarker ( -1903.9000244141, 283.5, 39.5, "cylinder", 4, 127, 127, 127, 100 )
    
    addEventHandler ( "onMarkerHit", garageCarCube,
        function ( hitElement, matchingDimension )
            if ( matchingDimension and getElementType ( hitElement ) == "player" ) then
                local theVehicle = getPedOccupiedVehicle ( hitElement )
                if ( theVehicle ) then
                    if ( hitElement == getVehicleController ( theVehicle ) ) then
                        for _, vehicle in ipairs ( getElementsWithinColShape ( getElementColShape ( source ), "vehicle" ) ) do
                            if ( vehicle ~= theVehicle and getVehicleController ( vehicle ) ) then
                                return
                            end
                        end
                        triggerClientEvent ( hitElement, "onGarageEnter", resourceRoot )
                    end
                end
            end
        end
    )
    -- CLIENTE
    addEvent ( "onGarageEnter", true ) 
    addEventHandler ( "onGarageEnter", resourceRoot,
        function ()
            if ( not guiGetVisible( painelBlip ) ) then 
                guiGridListClear ( gridcor )
                guiSetVisible ( painelBlip, true )
                showCursor ( true )
                refreshColors ()
            end
        end
    )

     

  2. On 18/06/2020 at 15:50, Lord Henry said:

    @[M]isterPra pegar o carro de volta vc vai precisar criar um colShape ou um marker ao redor do carro, dai quando o jogador entrar nesse marker, ativa um bindKey com a tecla de entrada no veículo, que vai remover o ped do veículo e depois dar um setControlState no jogador pra fazer ele entrar no veículo (que agora dará certo). Depois de entrar no veículo (onVehicleEnter), destroi o marker e também desativa essa bind que não é mais necessária.

    Boa! Estou sem MTA se alguém tentar favor deixar o feedback. A mágica então seria o setControlState, pois mesmo depois de remover o ped ainda não era possível entrar no veículo através do 'F'.

  3. O melhor seria criar um sistema de download personalizado, exemplo: https://community.multitheftauto.com/?p=resources&s=details&id=18186

    Para ter um pouco de noção do que foi baixado e o que falta mantendo o sistema de download nativo, daria para percorrer no lado servidor os resources ativos getResources, identificando e salvando numa tabela os arquivos que são baixados pelo cliente com seus respectivos tamanhos. E mandar para o lado do cliente ficar verificando se os arquivos já foram baixados fileExists e os que faltam.

  4. 1 hour ago, Gaimo said:

    A primeira dúvida é a váriavel valorAtual ela está fora da função haircut e é serverside, se um jogador alterar o valor dela, vai alterar o valor da váriavel (valorAtual) de todos?

    Como estou pensando em fazer para cobrar o jogador, criar uma váriavel paid, quando o jogador entrar no marker de entrada, salvar o corte atual dele, e quando ele sair verificar se paid é == true se for mantem o corte se não volta para o que foi salvo quando ele entrou, seria isso? Alguma sugestão?

    1. Sim, faça no lado cliente, mantenha server side apenas o addPedClothes, getPlayerMoney e takePlayerMoney

    2. Acho ok... mas seria bom ao menos informar o valor do corte ao jogador. E deve-se também atualizar o "corte atual" após cada compra com sucesso.

    • Thanks 1
  5. 21 minutes ago, SrPattif said:

    Existe sim um fator a ser creditado, que é basicamente o autor do script...

    Como assim?

    Se você fez um sistema de ID's, o crédito é seu, pois foi você quem o criou...

    Ideia é uma coisa, código é outra... certamente se você fez um script de ID você tem total direito sobre ele, mas nem por isso poderá julgar demais servidores que surgem com algo similar (código diferente mas mesma ideia).

  6. A ideia de "ID" nos jogadores não pode ser creditada a ninguém, é algo bem antigo e comum de se pensar. Se o código foi feito do zero sem cópias parciais/integrais de scripts de terceiros não vejo problema.
    O script em questão utiliza a lógica de "IDs Fixos", sendo que o GangWar/Terra possuíam "IDs Temporários" (não existia nem getAccountID), suponha-se então uma não relação entre os códigos.

  7. addEventHandler("onPlayerChangeNick", root,
        function(_, nick)
            if (removeHex(nick):len() == 0) then
                outputChatBox("Nick inválido!", source, 255, 0, 0)
                cancelEvent(true)
            end
        end
    )
    addEventHandler("onPlayerConnect", root,
        function(nick)
            if (removeHex(nick):len() == 0) then
                cancelEvent(true, "Nick inválido!")
            end
        end
    )
    
    function removeHex(str)
        while(str:find("#%x%x%x%x%x%x")) do
            str = str:gsub("#%x%x%x%x%x%x","")
        end
        return str
    end

     

    • Like 1
  8. Havia hospedado um serviço do tipo a um tempo, provavelmente ainda funcione:

    local emailConfig = {
    	name = "", -- NOME
    	user = "", -- E-MAIL (GMAIL)
    	pass = "", -- SENHA (GMAIL)
    	link = "http://site.mtabrasil.com.br/email/enviarEmail.php"
    }
    addCommandHandler( "teste",
        function(thePlayer, _, sendTo)
            local postData = toJSON(
                {
                    to = sendTo,
                    subject = "E-mail teste",
                    text = "<p>Olá</p>",
                    
                    name = emailConfig.name,
                    user = emailConfig.user,
                    pass = emailConfig.pass
                }
            )
            fetchRemote(emailConfig.link, returns, postData)
        end
    )
    
    function returns(msg, num)
    	if msg == "ERROR" or num ~= 0 then
    		outputDebugString("Erro no envio do e-mail! (verifique o script e/ou página web)", 2)
    	end
    end

    No caso foi feito para funcionar com conta do gmail, pois ajuda que não cai em caixas de spam/lixeira.

    Deve-se habilitar na conta do gmail o "uso de dispositivos menos seguros" e não recomendo usar sua conta pessoal, crie uma nova só para esta finalidade.

    • Thanks 1
  9. Você definindo uma variável chamada "root", você está sobrescrevendo a variável de mesmo nome pre-definida pelo MTA que seria a raiz de todos elementos (LINK), impossibilitando seu uso caso necessite.

    Marker = createMarker(2193.9870605469, -1000.0881958008, 62.851928710938 - 1, "cylinder", 2, 117, 254, 0, 255)
    MarkerF = createMarker(2603.4150390625, -1918.1767578125, 13.549844741821 - 1, "cylinder", 2, 0, 255, 0, 255)
    
    setElementVisibleTo(MarkerF, root, false)
    
    trab = createBlipAttachedTo(Marker, 42)
    setElementVisibleTo(Bfim, source, true)
    
    Bfim = createBlipAttachedTo(MarkerF, 19)
    setElementVisibleTo(Bfim, root, false)
    
    veh = {}
    skins = {}
    function inicio(thePlayer)
        if isElementWithinMarker(thePlayer, Marker) then
            if veh[thePlayer] and isElement(veh[thePlayer]) then
                destroyElement(veh[thePlayer])
                veh[thePlayer] = nil
            end
            x, y, z = getElementPosition(thePlayer)
            Trabalho = true
            veh[thePlayer] = createVehicle(459, 2192.45703125, -1007.572265625, 64.420482635498, 0, 0, 81.835632324219)
            skins[thePlayer] = getElementModel(thePlayer)
            setPedSkin(thePlayer, 280)
            setElementVisibleTo(Bfim, thePlayer, true)
            setElementVisibleTo(MarkerF, thePlayer, true)
            warpPedIntoVehicle(thePlayer, veh[thePlayer])
            outputChatBox("#ff00ff-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
            outputChatBox("#ffb200Você Pegou o Trabalho de Vendedor de Drogas,", thePlayer, 0, 0, 0, true)
            outputChatBox("#ffb200Leve as drogas, para os local indicado,", thePlayer, 0, 0, 0, true)
            outputChatBox("#ffb200A ser entregada, ganhara 8000R$", thePlayer, 0, 0, 0, true)
            outputChatBox("#ff00ff-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
        end
    end
    addEventHandler("onMarkerHit", Marker, inicio)
    
    function fim(thePlayer)
        if veh[thePlayer] and isElement(veh[thePlayer]) then
            destroyElement(veh[thePlayer])
            givePlayerMoney(thePlayer, 8000)
            setPedSkin(thePlayer, "skinp", skins[thePlayer] or 0)
            setElementVisibleTo(Bfim, thePlayer, false)
            setElementVisibleTo(MarkerF, thePlayer, false)
            outputChatBox("#ff00ff-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
            outputChatBox("#ffb200Você Entregou todas as encomendas,", thePlayer, 0, 0, 0, true)
            outputChatBox("#ffb200E Recebeu 8000R$ de Pagamento!", thePlayer, 0, 0, 0, true)
            outputChatBox("#ff00ff-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
        else
        end
    end
    addEventHandler("onMarkerHit", MarkerF, fim)
    
    function sair(thePlayer)
        if (veh[thePlayer]) and isElement(veh[thePlayer]) then
            setElementVisibleTo(Bfim, thePlayer, false)
            setElementVisibleTo(MarkerF, thePlayer, false)
            destroyElement(veh[thePlayer])
            setPedSkin(thePlayer, "skinp", skins[thePlayer] or 0)
            outputChatBox("#ffb200-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
            outputChatBox("#00ff00Voce perdeu seu trabalho, Pois saiu do carro!", thePlayer, 0, 0, 0, true)
            outputChatBox("#ffb200-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
        else
        end
    end
    addEventHandler("onVehicleExit", getRootElement(), sair)
    
    addEventHandler("onPlayerQuit", root,
        function()
            if (veh[source]) and isElement(veh[source]) then
                destroyElement(veh[source])
                veh[source] = nil
            end
            if (skins[source]) then
                skins[source] = nil
            end
        end
    )

     

  10. Logado como administrador, execute os seguintes comandos no console (F8):

    start runcode
    srun for _, jogador in ipairs(getElementsByType("player")) do removeElementData (jogador, "Bank:Caixa") end
    srun for _, conta in ipairs(getAccounts()) do setAccountData(conta, "Bank:Caixa", false) end
    stop runcode

    Dica: faça com o resource desligado.

  11. 21 hours ago, O.G Kash said:

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

    zmhI6MU.png

    Troque o trecho "table.unpack" por apenas "unpack". O MTA roda a versão 5.1 de Lua, sendo que o unpack só foi alterado para table.unpack na v5.2.

    2 hours ago, Lord Henry said:

    A função unpack não funciona dessa maneira. Ela serve para "desempacotar" uma table em valores separados. Ex:

    E como foi usado ?

    2 hours ago, Lord Henry said:
    
    local arr = {
        {2455.423, -2079.331, 12.547}, -- Item 1 da table arr
        {2458.529, -2078.655, 12.547}, -- Item 2 da table arr
        {2462.126, -2078.502, 12.547}, -- E assim por diante.
    }
    
    function test () -- Exemplo com unpack:
        local x, y, z = unpack (arr, math.random (#arr)) -- Desempacota um item aleatório da table arr. Atribuindo seus valores nas variáveis.
        createMarker (x, y, z, "cylinder", 1.5, 50, 100, 255, 100)
    end
    addCommandHandler ("teste", test)

     

    Ali estamos trabalhando com array multidimensional, fazendo unpack na tabela raiz retornara as tabelas filhas, e não os elementos "desempacotados" dessa sub-tabela.

    local x, y, z = unpack (arr, math.random (#arr))
    É igual à:
    x = arr[math.random(#arr))
    y = arr[math.random(#arr)+1)
    ... arr[#arr]

     

  12. Tente:

    function adicionarCorp(thePlayer, _, id)
        if (isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin"))) then
            if (setElementData(getPlayerID(tonumber(id)), "INT:BTS", true)) then
                outputChatBox("[INT]: #ffffffVocê colocou o jogador [ID]:"..id.." na corporação!", thePlayer,255,255,255, true)
            end
        end
    end
    addCommandHandler("corp", adicionarCorp)
    
    function removeCorp(thePlayer, _, id)
        if (isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin"))) then
            if (removeElementData(getPlayerID(tonumber(id)), "INT:BTS")) then
                outputChatBox("[INT]: #ffffffVocê removeu o jogador [ID]:"..id.." da corporação!", thePlayer,255,255,255, true)
            end
        end
    end
    addCommandHandler("rcorp", removeCorp)

    Obs: getPlayerID não é uma função nativa do MTA, espero que esteja importando/incluindo no seu código.

    • Thanks 1
×
×
  • Create New...