-
Posts
3,987 -
Joined
-
Last visited
-
Days Won
181
Everything posted by Lord Henry
-
Tente assim: mCarregamento = createMarker(-2253.13, 2387.62, 3.95, "cylinder", 2, 255, 0, 0, 255, getRootElement()) balsa = createVehicle (454, -2224.43, 2432.65, 2.14, 0, 0, 45) obj1 = {} mObjeto = {} bObjeto = {} mEntrega = {} bEntrega = {} function criarObjeto (thePlayer) if getPedOccupiedVehicle(thePlayer) then return end if thePlayer and isElement(thePlayer) and getElementType(thePlayer) == "player" then if not getElementData (thePlayer, "criar.objeto") or getElementData (thePlayer, "criar.objeto") ~= 1 then if source == mCarregamento then setElementData (thePlayer, "criar.objeto", 1) obj1[thePlayer] = createObject(964, -2260.14, 2382.28, 3.90, 0, 0, 0, true) setObjectScale (obj1, 0.5) ox, oy, oz = getElementPosition(obj1) mObjeto[thePlayer] = createMarker (ox, oy, oz, "cylinder", 2.5, 255, 0, 0, 0, thePlayer) bObjeto[thePlayer] = createBlipAttachedTo (mObjeto, 0, 2, 255, 0, 0, 255, 0, 999, thePlayer) setElementData (mObjeto[thePlayer], "owner", thePlayer) -- SETA O PLAYER COMO DONO DAQUELE MARKER, assim só funciona pra esse player. end end end end addEventHandler ("onMarkerHit", mCarregamento, criarObjeto) function carregarObjeto (thePlayer) if getElementData (source, "owner") then -- Se o marker tem um dono, então: if getElementData (source, "owner") ~= thePlayer then return end -- Se o elemento que colidiu no marker não for o player dono dele, nada acontece. if getPedOccupiedVehicle (thePlayer) then return end if thePlayer and isElement(thePlayer) and getElementType(thePlayer) == "player" then if not getElementData(thePlayer, "carregando.objeto") or getElementData(thePlayer, "carregando.objeto") ~= 1 then if source == mObjeto[thePlayer] then destroyElement (bObjeto[thePlayer]) setElementData (thePlayer, "carregando.objeto", 1) setPedAnimation (thePlayer, "CARRY", "liftup", 1.0, false) setTimer(function() setElementData (thePlayer, "caixa.armas", 1) setPedAnimation (thePlayer, nil) setPedAnimation (thePlayer, "CARRY", "crry_prtial", 4.1, true, true, true) attachElements (obj1, thePlayer, 0, 0.5, 0.3) toggleControl (thePlayer, "jump", false) toggleControl (thePlayer, "fire", false) toggleControl (thePlayer, "sprint", false) toggleControl (thePlayer, "crouch", false) toggleControl (thePlayer, "enter_exit", false) destroyElement (mObjeto[thePlayer]) mEntrega[thePlayer] = createMarker(-2230.40, 2438.80, 1.49, "cylinder", 2, 255, 0, 0, 255, thePlayer) setElementData (mEntrega[thePlayer], "owner", thePlayer) bEntrega[thePlayer] = createBlipAttachedTo(mEntrega, 0, 2, 255, 0, 0, 255, 0, 999, thePlayer) end, 1000, 1) end end end end end addEventHandler ("onMarkerHit", getRootElement(), carregarObjeto) function entregarObjeto(thePlayer) if getElementData (source, "owner") then -- Se o marker tem um dono, então: if getElementData (source, "owner") ~= thePlayer then return end -- Se o elemento que colidiu no marker não for o player dono dele, nada acontece. if getPedOccupiedVehicle (thePlayer) then return end if thePlayer and isElement (thePlayer) and getElementType (thePlayer) == "player" then if getElementData (thePlayer, "caixa.armas") and getElementData (thePlayer, "caixa.armas") ~= 0 then if source == mEntrega[thePlayer] then setPedAnimation (thePlayer, "CARRY", "liftup", 1.0, false) setTimer (function () setPedAnimation (thePlayer, "CARRY", "crry_prtial", 4.1, true, true, true) toggleControl (thePlayer, "jump", true) toggleControl (thePlayer, "fire", true) toggleControl (thePlayer, "sprint", true) toggleControl (thePlayer, "crouch", true) toggleControl (thePlayer, "enter_exit", true) destroyElement (mEntrega[thePlayer]) destroyElement (bEntrega[thePlayer]) print("01") end, 1000, 1) attachElements (obj1[thePlayer], balsa, 0, 0, 0.3) setElementData (thePlayer, "caixa.armas", 0) setElementData (thePlayer, "criar.objeto", 0) setElementData (thePlayer, "carregando.objeto", 0) end end end end end addEventHandler ("onMarkerHit", getRootElement(), entregarObjeto) Não testei. Mas deve funcionar.
-
Não. O MTA só é compatível com SQLite ou com MySQL.
-
Essas patentes são colocadas por ACL Group, né? São várias facções diferentes ou só uma?
- 1 reply
-
- scoreboard
- nivel
-
(and 2 more)
Tagged with:
-
Cara, isso é programação. Se você já souber Lógica de Programação, então basta estudar a Wiki do MTA. Caso contrário, estude Lógica de Programação e Algoritmos antes de tentar programar algo.
-
Pra desativar o HUD e Radar originais, use setPlayerHudComponentVisible.
-
[AJUDA] Ponto de Spawn de acordo com a localização
Lord Henry replied to dener189's topic in Programação em Lua
Você disse que já sabe que é preciso usar a função getDistanceBetweenPoints3D. Isso já é um excelente começo. Usando ela e um FOR para verificar a distância entre cada ponto, você consegue determinar qual deles tem a menor distância e fazer o jogador nascer lá. A lógica funciona assim: Você tem uma variável local que será 9999 e outra variável que será o ID da menor posição possível. A primeira variável irá guardar a distância do primeiro elemento ao passar pelo FOR, a segunda irá guardar o ID 1, depois no segundo elemento, se a distância dele for menor do que a distância guardada nessa variável, então atualiza a variável com essa distância e a segunda variável passa a ser o ID 2, e vai fazendo isso com todos os demais itens dessa lista de posições. Ao final desse FOR, a primeira variável estará com a menor distância entre todos os elementos e a segunda variável estará com o ID da menor distância entre eles. Dai é só vc fazer o player nascer na posição desse ID. (Sei que ficou difícil de entender, quando eu chegar em casa eu faço um exemplo com comentários pra ficar fácil de entender) -
Sempre tive esse mesmo problema, hauahuahaua. Meus resources funcionam perfeitamente em server local, mas dai quando eu coloco em server público, entope de erros e bugs. -------------- Quanto ao seu primeiro problema, sugiro que crie os markers client-side e dai verifique se o hitElement == localPlayer. Caso não queira fazer isso, então sete uma data no marker identificando o jogador que criou aquele marker como "dono" usando setElementData no marker, então crie uma condição que verifica se o hitElement == getElementData do marker. O primeiro jeito tem melhor desempenho, mas você precisa tomar cuidado ao fazer o triggerClientEvent e depois o triggerServerEvent ao colidir naquele marker. Quanto ao seu segundo problema, primeiro resolva o problema anterior antes de pensar em implementar ele. Mas já vou logo adiantando que você precisará criar uma table com todas as posições de caixas, por exemplo assim: boxPositions = { [1] = {-1200.62, 522, 10}, -- Coordenadas x, y, z. [2] = {-1222.22, 530, 10}, [3] = {-1224, 515, 10}, }
-
[AJUDA] Ponto de Spawn de acordo com a localização
Lord Henry replied to dener189's topic in Programação em Lua
Não entendi direito o que você quer. Você quer que o jogador nasça num hospital mais próximo depois de morrer? Em vez de nascer num ponto aleatório. -
Da próxima vez, não crie outro post igual na sessão geral. E também não precisa colocar fonte grande com negrito, isso é considerado spam. Agora em relação ao seu problema, eu faria um pickup customizado usando createPickup e depois usaria o evento onPickupUse pra fazer esse pickup funcionar. Mas como você provavelmente quer fazer mais do que 1 pickup, então é melhor colocá-los em uma table e com um pequeno loop, verificar se o pickup usado é um deles. Fiz um exemplo genérico, um pickup está no hospital 1 de LS e o outro está no hospital 2 de LS. E cada pickup ao ser usado dá um colete e uma pistola com 100 de munição ao jogador. No entanto, o jogador pode usar várias vezes o pickup se quiser mais munição, o pickup respawna após 5 segundos. loots = { [1] = createPickup (2022, -1402, 17, 3, 1279, 5000, 1), [2] = createPickup (1173, -1319, 15.5, 3, 1279, 5000, 1), } addEventHandler ("onPickupUse", getRootElement(), function (thePlayer) for i, pickup in ipairs (loots) do if source == pickup then giveWeapon (thePlayer, 22, 100, true) setPedArmor (thePlayer, 100) break end end end)
-
Difícil entender. Os scripts não possuem indentação.
- 1 reply
-
- 1
-
Então há erro no seu triggerServerEvent. Verifique se os parâmetros declarados depois do localPlayer existem e se estão corretos.
-
Existe algum erro no /debugscript 3? Já tentou colocar um outputChatBox na função startAnim pra saber se ela chega a ser executada?
-
O primeiro outputChatBox não precisa. Além disso vc está deixando brecha pro cara ficar floodando o chat com essa mensagem se ele ficar usando o comando várias vezes. E o segundo outputChatBox faltou vc colocar sourcePlayer antes do 255. E também só tem 1 TAB no início da linha, e não 2.
-
Pois é, ahuahauhaua Normalmente eu nunca passo código pronto, pois isso desestimula o usuário a ir buscar informações na Wiki. Mas como eu deixei o código comentado, ele pode estudar o código também.
-
Sim. Os triggers exigem que vc crie um evento compartilhado usando addEvent e depois anexe esse evento na função que vc quer que ele execute usando addEventHandler.
-
Ta ae: client.lua local x, y = guiGetScreenSize () -- x e y recebem a resolução da tela do jogador. local rendering = false -- variável que indica se a imagem está sendo renderizada ou não, para evitar que bugue ao usar o comando enquanto já está renderizando a imagem. local minutos = 15 -- Quantos minutos o jogador deve esperar para perder a TAG de Punheteiro function pornRender () -- Essa função é chamada a cada frame. dxDrawImage (0, 0, x, y, "nude.png", 0, 0, 0, tocolor(255,255,255,255), true) -- Desenha a imagem 'nude.png' na tela inteira do jogador. end addEvent ("verPunheta", true) addEventHandler ("verPunheta", getRootElement(), function () -- Função que inicia o render da imagem. if not rendering then -- Se a imagem já não está sendo renderizada, então: rendering = true -- Ela é considerada renderizada agora. addEventHandler ("onClientRender", getRootElement(), pornRender) -- Inicia o render da imagem a cada frame. setTimer (stopRender, 15000, 1) -- Daqui a 15 segundos, executa a função stopRender uma única vez. if isTimer (pornTimer) then -- Se já existe o timer para tirar a TAG do jogador, então: resetTimer (pornTimer) -- Reinicia esse timer. else -- Se não existe o timer, então: pornTimer = setTimer (function () -- Cria o timer. triggerServerEvent ("cancelaTag", localPlayer) end, minutos * 60000, 1) -- Daqui a 15 minutos, executa o evento "cancelaTag" no server, que irá remover a TAG. end end end) function stopRender () -- Função que cancela o render da imagem. if rendering then -- Se a imagem está sendo renderizada, então: rendering = false -- Ela não é mais considerada renderizada. removeEventHandler ("onClientRender", getRootElement(), pornRender) -- Cancela o render da imagem e ela some da tela. A função pornRender para de ser executada a cada frame. end end server.lua function Punha (sourcePlayer) if isGuestAccount (getPlayerAccount(sourcePlayer)) then return end -- Impede que o comando funcione para jogadores deslogados. triggerClientEvent (sourcePlayer, "verPunheta", sourcePlayer) -- Executa o evento "verPunheta" do client.lua if not isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(sourcePlayer)), aclGetGroup ("Punha")) then -- Se o jogador não tem a TAG, então: aclGroupAddObject (aclGetGroup("Punha"), "user."..getAccountName (getPlayerAccount (sourcePlayer))) -- Coloca TAG de punheteiro nele. end end addCommandHandler ("punheta", Punha) -- Comando que executa a função Punha addEvent ("cancelaTag", true) addEventHandler ("cancelaTag", getRootElement(), function () if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(client)), aclGetGroup ("Punha")) then -- Se o jogador tem a TAG, então: aclGroupRemoveObject (aclGetGroup("Punha"), "user."..getAccountName (getPlayerAccount (client))) -- Remove a TAG de punheteiro dele. end end)
-
A verificação deverá ser feita no client.
-
Pra fazer com grandes períodos de tempo, recomendo que use uma variável chamada minutos e multiplique ela por 60 mil no timer. E vc fez errado, pois vc está colocando funções server-side em um script client-side. Assim não irá funcionar. Ali no código, tudo que está laranja, só funciona server-side. E tudo que está em vermelho, só funciona client-side. Os que estão em azul funcionam em ambos.
-
No caso pra fazer um anúncio, dai seria mais interessante. Mas tenha em mente que a imagem irá distorcer de acordo com a resolução do jogador. Eu não fiz escala proporcional na imagem. Por exemplo: Se a imagem tem dimensões de 800x600 pixels (4:3) mas a tela do jogador tem resolução 1366x768 pixels (proporção 16:9), a imagem ficará esticada horizontalmente. Coloca o aclGroupAddObject após o rendering = true e coloca o aclGroupRemoveObject após o rendering = false na função stopRender.
-
Realmente um script bem tosco e desnecessário. Mas vamos lá. local x, y = guiGetScreenSize () -- x e y recebem a resolução da tela do jogador. rendering = false -- variável que indica se a imagem está sendo renderizada ou não, para evitar que bugue ao usar o comando enquanto já está renderizando a imagem. function pornRender () -- Essa função é chamada a cada frame. dxDrawImage (0, 0, x, y, "nude.png", 0, 0, 0, tocolor(255,255,255,255), true) -- Desenha a imagem 'nude.png' na tela inteira do jogador. end function startRender (cmd) -- Função que inicia o render da imagem. if not rendering then -- Se a imagem já não está sendo renderizada, então: rendering = true -- Ela é considerada renderizada agora. addEventHandler ("onClientRender", getRootElement(), pornRender) -- Inicia o render da imagem a cada frame. setTimer (stopRender, 15000, 1) -- Daqui a 15 segundos, executa a função stopRender uma única vez. end end addCommandHandler ("punheta", startRender) -- Comando que executa a função startRender: /punheta function stopRender () -- Função que cancela o render da imagem. if rendering then -- Se a imagem está sendo renderizada, então: rendering = false -- Ela não é mais considerada renderizada. removeEventHandler ("onClientRender", getRootElement(), pornRender) -- Cancela o render da imagem e ela some da tela. A função pornRender para de ser executada a cada frame. end end
-
[Ajuda] Criar veiculo freezado em cima de outro
Lord Henry replied to +[T]rakin's topic in Programação em Lua
De nada. -
Cara, o balanceamento dai é com você. Você é quem tem que saber quais armas devem dar mais dano e quais devem dar menos. Vou dar um exemplo de como aumentar o dano da Colt 45, que por padrão tem dano de 25. setWeaponProperty (22, "poor", "damage", 50) Nesse caso, aumentei o dano dela pra 50. 22 é o ID da arma, os IDs estão disponíveis em Weapons. "poor" é o nível de habilidade do jogador nessa arma, por padrão os jogadores não possuem habilidades de armas, a não ser que você crie um script que faça isso. "damage" é a propriedade cujo valor você quer alterar, no caso é o dano da arma. 50 é o novo valor da propriedade. Se você quer saber qual o valor padrão do dano de uma determinada arma, use getWeaponProperty. Funciona exatamente da mesma forma, porém você não coloca o parâmetro do valor.
-
Da próxima vez, poste na sessão destinada a divulgação de serviços de hospedagem.
-
[Ajuda] Criar veiculo freezado em cima de outro
Lord Henry replied to +[T]rakin's topic in Programação em Lua
Além disso você anexou o caminhão no carro, quando na verdade deveria ser ao contrário. PMarker = createMarker (1203.865234375, -1285.80859375, 12.38519859314, "cylinder", 2, 255, 0, 0, 255) -- Vermelho FMarker = createMarker (1200.0888671875, -1352.7841796875, 12.402050018311, "cylinder", 2, 0, 255, 0, 255) -- Verde FBlip = createBlip (1203.865234375, -1285.80859375, 13.38519859314, 42) setBlipVisibleDistance (FBlip, 200) -- 150 é a distancia perfeita veh = {} vehQuebrado = {} function inicio (hitElement) -- Função do primeiro marker if getElementType (hitElement) == "player" and not getPedOccupiedVehicle (hitElement) then local accName = getAccountName (getPlayerAccount(hitElement)) if isObjectInACLGroup ("user."..accName, aclGetGroup ("Moderator")) then -- Somente moderadores podem usar esse emprego? if veh[hitElement] and isElement (veh[hitElement]) then destroyElement (veh[hitElement]) veh[hitElement] = nil end if vehQuebrado[hitElement] and isElement (vehQuebrado[hitElement]) then destroyElement (vehQuebrado[hitElement]) vehQuebrado[hitElement] = nil end x, y, z = getElementPosition (hitElement) Trabalho = true FBlip = createBlipAttachedTo (FMarker, 19) -- Bandeira veh[hitElement] = createVehicle (578, 1188.9052734375, -1278.16015625, 13.288257598877, 0, 0, 90.505493164063) -- Caminhão setElementVisibleTo (FBlip, hitElement, true) -- Mostra o blip quando começa o trabalho warpPedIntoVehicle (hitElement, veh[hitElement]) -- Transporta o jogador para dentro do caminhão vehQuebrado[hitElement] = createVehicle (422, 1186.9052734375, -1278.16015625, 13.288257598877, 0, 0, 90.505493164063) -- Caminhonete setElementCollisionsEnabled (vehQuebrado[hitElement], false) -- Desabilita a colisão da caminhonete pra não bugar a câmera. attachElements (vehQuebrado[hitElement], veh[hitElement], 0, -2, 0.8) outputChatBox ("[Emprego] Bem-Vindo ao emprego #00ccff[Reboque]", hitElement, 255, 255, 255, true) -- triggerClientEvent (hitElement, "texto", root) else outputChatBox ("[#ff0000AVISO#00ccff] #ff0000Você não pode fazer seus corres aqui!", hitElement, 0, 204, 255, true) end end end addEventHandler ("onMarkerHit", PMarker, inicio) -
[Ajuda] Criar veiculo freezado em cima de outro
Lord Henry replied to +[T]rakin's topic in Programação em Lua
Isso acontece pois você setou coordenadas no attachElements relativas ao mundo. Mas você deveria ter declarado a posição relativa entre o veículo e o caminhão.