Jump to content

main

Members
  • Posts

    112
  • Joined

  • Days Won

    1

Everything posted by main

  1. De nada. O parâmetro hitElement é o elemento que deu hit no marker O parâmetro matchingDimension é um boolean que representa se o elemento está na mesma dimensão do marcador
  2. Tente: function entrar1(hitElement, matchingDimension) if isElement(hitElement) and matchingDimension then if getElementType(hitElement) == "player" and not isPedInVehicle(hitElement) then local acc = getPlayerAccount(hitElement) if acc and not isGuestAccount(acc) then local accName = getAccountName(acc) if isObjectInACLGroup("user."..accName, aclGetGroup(Grupo)) then setElementInterior(hitElement, 10, 246.39647, 110.09633, 1003.22571) setElementDimension(hitElement, 2) else --outputChatBox( "Você não tem permissão!", hitElement, 200, 0, 0, false ) dxMsg(hitElement, "Você não tem permissão para entrar aqui!", "error") end end end end end addEventHandler ("onMarkerHit", entrar, entrar1)
  3. Porque usou o parâmetro thePlayer em todos argumentos das funções e não usou no argumento do isPedInVehicle? O argumento source nesse caso, seria o marker Tente isto: function entrar1 (thePlayer) if isElement(thePlayer) and getElementType(thePlayer) == "player" and not isPedInVehicle(thePlayer) then local acc = getPlayerAccount(thePlayer) if acc and not isGuestAccount(acc) then local accName = getAccountName(acc) if isObjectInACLGroup ("user."..accName, aclGetGroup ( Grupo ) ) then setElementInterior(thePlayer, 10, 246.39647, 110.09633, 1003.22571) setElementDimension(thePlayer, 2) else --outputChatBox( "Você não tem permissão!", thePlayer, 200, 0, 0, false ) dxMsg(thePlayer, "Você não tem permissão para entrar aqui!", "error") end end end end addEventHandler ("onMarkerHit", entrar, entrar1)
  4. @MaligNos desculpe, funcionou sim, eu que estava testando com o freeroam ligado .-. Muito obrigado pela ajuda.
  5. function createPlayerBlip(player) if not player or not isElement(player) or getElementType(player) ~= "player" then return false end local playerTeam = getPlayerTeam(player) if playerTeam then if not blip[player] then blip[player] = createBlipAttachedTo(player, 0, 2, 255, 255, 255, 255) setElementVisibleTo(blip[player], root, false) for _, teamMember in ipairs (getPlayersInTeam(playerTeam)) do setElementVisibleTo(blip[player], teamMember, true) end end end end Tentei deste jeito e não funcionou, estou criando o blip no evento onResourceStart e onPlayerLogin
  6. local blip = {} function createPlayerBlip(player) if not player or not isElement(player) or getElementType(player) ~= "player" then return false end local playerTeam = getPlayerTeam(player) blip[player] = createBlipAttachedTo(player, 0, 2, 255, 255, 255, 255) end Olá, queria saber uma forma eficiente de criar/mostrar o blip somente entre jogadores do team
  7. O_M = createObject(615, -1668.99609375, -2233.56640625, 34.166400909424 -1) M_O = createMarker (-1639.974609375, -2245.53515625, 31.4765625 -1, "cylinder", 1.5, 20, 70, 230, 95 ) function Inicio(source) if isElementWithinMarker(source, M_O) then if O_M and isElement(O_M) then destroyElement(O_M) end end end addEventHandler("onMarkerHit", M_O, Inicio) Tente isto.
  8. Pois é, está tudo normal, acho que está dando algum conflito no servidor que estou utilizando ele, vou tentar resolver isso.
  9. Já sim, o problema é na parte do evento onPlayerWasted
  10. Olá pessoal, estou com um problema no meu sistema de prisão, a tabela que salva o veículo funciona normalmente em todas as partes do script, porém, na função onPlayerWasted a tabela parece que não funciona, não sei se tem algum outro resource dando algum tipo de conflito/bug Segue o código abaixo: local positions = { {x = 1536, y = -1675.5, z = 12}, {x = 2185, y = -1757, z = 12}, {x = 777.6, y = -1387.5, z = 12}, {x = -1568.1, y = 661.18, z = 6}, {x = 2290.18, y = 2420.7, z = 10} } local cadeias = { {-1283.88013, 1200.47180, 13.01935}, {-1283.51514, 1207.08447, 13.02033}, {-1283.46167, 1213.87219, 13.02705}, {-1284.11597, 1220.69495, 13.01871} } local IDS = { [490] = true, [598] = true, [596] = true, [597] = true, [560] = true } local timerArrested = {} function createPrisonMarker(source) for _, v in ipairs(positions) do if isPlayerPolice(source) then if not marker then local marker = createMarker(v.x, v.y, v.z, 'cylinder', 3.0, 10, 10, 10, 255, source) createBlipAttachedTo(marker, 30, 2, 255, 255, 255, 255, 0, 9999, source) end end end end function onResourceStart() for _, player in ipairs(getElementsByType("player")) do createPrisonMarker(player) end end addEventHandler("onResourceStart", resourceRoot, onResourceStart) local carros = {} function onPlayerVehicleEnter(theVehicle, seat, jacked) local idModel = getElementModel(theVehicle) if IDS[idModel] then carros[source] = theVehicle print(carros[source]) -- retorna tabela print(getElementModel(carros[source])) -- retorna id end end addEventHandler('onPlayerVehicleEnter', root, onPlayerVehicleEnter) function onPrender(police, _, target) if isPlayerPolice(police) then local target = getPlayerFromPartialName(target) if not target then return outputChatBox('#bebebeJogador inválido', police, 255, 255, 255, true) end local px, py, pz = getElementPosition(police) local bx, by, bz = getElementPosition(target) local dist = getDistanceBetweenPoints3D(px, py, pz, bx, by, bz) if target == police then return outputChatBox('#bebebeVocê não pode prender a si mesmo', police, 255, 255, 255, true) end if getPlayerWantedLevel(target) == 0 then return outputChatBox('#bebebe Este jogador não está sendo procurado', police, 255, 255, 255, true) end if isPedInVehicle(police) then return outputChatBox('#bebebeVocê não pode prender de dentro da viatura', police, 255, 255, 255, true) end if isPedInVehicle(target) then return outputChatBox('#bebebeVocê não pode prender um bandido enquanto ele estiver dentro de um veículo', police, 255, 255, 255, true) end if dist >= 2.5 then return outputChatBox('#bebebeVocê precisa chegar mais perto para prender', police, 255, 255, 255, true) end if not carros[police] then return outputChatBox('#bebebeEntre na VIATURA e saia para poder prender', police, 255, 255, 255, true) end warpPlayerInVTR(police, target) end end addCommandHandler('prender', onPrender) function onPlayerCommand(command) cancelEvent() end function onMarkerHit(hitElement, d) if hitElement and d then if getElementType(hitElement) == "vehicle" then local police = getVehicleOccupant(hitElement, 0) if carros[police] then local pregados = getAttachedElements(hitElement) for _, preso in ipairs(pregados) do if not isElement(preso) then return end if getElementData(preso, 'navtr') then removeElementData(preso, 'navtr') end setElementData(preso, 'arrested', true) detachElements(preso, hitElement) setPedAnimation(preso) toggleAllControls(preso, true) setPlayerInPrison(preso, "controls") local wanted = getPlayerWantedLevel(preso) local tempo = 30000 * wanted timerArrested[preso] = setTimer(function(p) onSoltar(p) end, tempo, 1, preso) triggerClientEvent(preso, "onClientPlayerArrested", resourceRoot, "add", tempo) local niv = getPlayerWantedLevel(preso) local premio = 1000*niv givePlayerMoney(police, premio) outputChatBox('#bebebeVocê prendeu um procurado nível #00ffff'..niv..'#bebebe e ganhou #00ffff$'..premio..'#bebebe de prêmio', police, 255, 255, 255, true) end end end end end addEventHandler("onMarkerHit", resourceRoot, onMarkerHit) function onPlayerWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) if isElement(source) then onSoltarWasted(source) end end addEventHandler("onPlayerWasted", root, onPlayerWasted) function onSoltarWasted(source) if isPlayerPolice(source) then local vtr = carros[source] print(vtr) -- retorna a tabela print(getElementModel(vtr)) -- da erro e retorna false if vtr and isElement(vtr) then local pregados = getAttachedElements(vtr) for _, preso in ipairs(pregados) do if preso and isElement(preso) then detachElements(preso, vtr) setPedAnimation(preso) if getElementData(preso, "navtr") then removeElementData(preso, "navtr") end removeEventHandler('onPlayerCommand', preso, onPlayerCommand) toggleAllControls(preso, true) local x,y,z = getElementPosition(preso) setElementPosition(preso,x+1.5,y+1.5,z+1) end end end end end function warpPlayerInVTR(police, preso) setElementData(preso, 'navtr', true) addEventHandler('onPlayerCommand', preso, onPlayerCommand) local vtr = carros[police] attachElements(preso, vtr, 0.2, -1.5, 0, 0, 0, 90) takeAllWeapons(preso) toggleAllControls(preso, false) setPedAnimation(preso, 'ped','CAR_dead_LHS') local vrx, vry, vrz = getElementRotation(vtr) setElementRotation(preso, vrx, vry, vrz+83) warpPedIntoVehicle(police, vtr) outputChatBox('#bebebeLeve o preso para a delegacia mais próxima #00ffff(sirenes azuis).', police, 255, 255, 255,true) end function onSoltar(preso) removeEventHandler('onPlayerCommand', preso, onPlayerCommand) removeElementData(preso, 'arrested') setElementDimension(preso, 0) setElementPosition(preso, -1607.02698, 715.03778, 12.53868) toggleControl(preso, "fire", true) toggleControl(preso, "aim_weapon", true) toggleControl(preso, "next_weapon", true) toggleControl(preso, "previous_weapon", true) setPlayerWantedLevel(preso, 0) if timerArrested[preso] then if isTimer(timerArrested[preso]) then killTimer(timerArrested[preso]) end timerArrested[preso] = nil end triggerClientEvent(preso, "onClientPlayerArrested", resourceRoot, "remove") end function onPlayerQuit() local account = getPlayerAccount(source) if account and not isGuestAccount(account) then if timerArrested[source] then if isTimer(timerArrested[source]) then local time = getTimerDetails(timerArrested[source]) setAccountData(account, "jailTime", time) killTimer(timerArrested[source]) else local statusJailTime = getAccountData(account, "jailTime") if statusJailTime then setAccountData(account, "jailTime", false) end end timerArrested[source] = nil end local status = getElementData(source,"arrested") if status then setAccountData(account, "arrested", true) else local statusArrested = getAccountData(account, "arrested") if statusArrested then setAccountData(account, "arrested", false) end end if getElementData(source, "navtr") then setAccountData(account, "jailTime", 180000) setAccountData(account, "arrested", true) end end end addEventHandler("onPlayerQuit", root, onPlayerQuit) function onPlayerLogin(_, account) local status = getAccountData(account, "arrested") if status then setElementData(source, "arrested", true) local tempo = getAccountData(account, "jailTime") timerArrested[source] = setTimer(function(p) onSoltar(p) end, tempo, 1, source) triggerClientEvent(source, "onClientPlayerArrested", resourceRoot, "add", tempo) setPlayerInPrison(source, "controls") end createPrisonMarker(source) end addEventHandler("onPlayerLogin", root, onPlayerLogin) function setPlayerInPrison(source, type) setElementDimension(source, 2) setElementPosition(source, unpack(cadeias[math.random(#cadeias)])) if type == "controls" then toggleControl(source, "fire", false) toggleControl(source, "aim_weapon", false) toggleControl(source, "next_weapon", false) toggleControl(source, "previous_weapon", false) end end local policeACLs = { aclGetGroup("Console"), -- aclGetGroup("FT"), -- aclGetGroup("ROTA"), -- aclGetGroup("CORE"), -- aclGetGroup("CHOQUE"), -- aclGetGroup("EXE"), } function isPlayerPolice(p) local acc = getPlayerAccount(p) if not acc then return false end if isGuestAccount(acc) then return false end local object = getAccountName(acc) for _,group in ipairs(policeACLs) do if isObjectInACLGroup("user."..object,group) then return true end end return false end function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end
  11. Você esqueceu os parâmetros do evento
  12. Testei anexando só um object, ainda não aparece
  13. function createRandomTrash() if old then if marker and isElement(marker) then local attachedElemensts = getAttachedElements(marker) if not attachedElemensts then return end for k, v in ipairs(attachedElemensts) do destroyElement(v) end destroyElement(marker) end end startTime = getRealTime() old = current or 1 current = math.random(1,#lixos) local mx, my, mz = lixos[current][1],lixos[current][2],lixos[current][3] marker = createMarker(mx, my, mz-1, "cylinder", 12, 255, 255, 255, 0) createBlipAttachedTo(marker, 41) local trashObject = createObject(1230, mx, my, mz, 270) local trashObject2 = createObject(1230, mx+1, my+3, mz, 270) local trashObject3 = createObject(1264, mx+1, my, mz, 270) local trashObject4 = createObject(1264, mx-1, my, mz, 270) attachElements(trashObject, marker) attachElements(trashObject2, marker) attachElements(trashObject3, marker) attachElements(trashObject4, marker) local markerArrow = createMarker(mx, my, mz,"arrow", 1.5, 255, 240, 0, 150) attachElements(markerArrow, marker, 0, 0, 6) local px, py, pz = getElementPosition(localPlayer) local dist = math.floor(getDistanceBetweenPoints3D(mx, my, mz,px, py, pz)) timeLeft = setTimer(onClientFaillJob,dist*200,1) end Quando uso a função attachElements com o objeto no marker, o objeto não aparece.
  14. Entendi, isso que precisava saber, obrigado.
  15. Criei uma col usando a função createColCuboid, porém a col está torta Print: https://prnt.sc/m83803
  16. Obrigado pela dica. Eu tenho um sistema de recuperação de senha em PHP(é preciso fazer a hospedagem desse arquivo em algum domínio) que funciona através da função callRemote. Caso o jogador esquecer a senha, ele irá escrever seu nome de usuário e clicar no botão de recuperação, será enviado um e-mail dizendo a senha dele para o e-mail que ele cadastrou na hora que se registrou no servidor. (Isso tudo no próprio painel de login).
  17. Já utilizei essa função a um tempo atrás para a mesma coisa, porém, não usei dessa forma. Muito obrigado @Lord Henry.
  18. function countPlayerAccount(player) local result = 0 local serial = getPlayerSerial(player) for _, account in ipairs(getAccounts()) do if getAccountData(account, "serial") == serial then result = result + 1 end end return result end Fiz essa função há um tempo para não permitir criar mais de 2 contas por serial, porém esse loop do getAccounts() laga o servidor quando executado, qual outra possibilidade de fazer isso?
  19. Verdade @DNL291, não tinha percebido isso, muito obrigado.
  20. function onPlayerBuy(type) if type == "drink" then local money = getPlayerMoney(client) if money >= 200 then local atualDrink = getElementData(client, "thirsty") if atualDrink and atualDrink < 100 then takePlayerMoney(client, 200) setElementData(client, "thirsty", atualDrink + 5) outputChatBox("Drink comprado com sucesso", client, 0, 255, 0) if atualDrink > 100 then -- Essa verificação não é executada setElementData(client, "thirsty", 100) print("ok drink") end else outputChatBox("Você não está com sede", client, 0, 255, 0) playSoundFrontEnd(client, 6) end else outputChatBox("Você não possui dinheiro suficiente", client, 255, 0, 0) playSoundFrontEnd(client, 6) end elseif type == "food" then local money = getPlayerMoney(client) if money >= 400 then local atualFood = getElementData(client, "food") if atualFood and atualFood < 100 then takePlayerMoney(client, 400) setElementData(client, "food", atualFood + 5) outputChatBox("Comida comprada com sucesso", client, 0, 255, 0) if atualFood > 100 then -- Essa verificação não é executada setElementData(client, "food", 100) print("ok food") end else outputChatBox("Você não está com fome", client, 0, 255, 0) playSoundFrontEnd(client, 6) end else outputChatBox("Você não possui dinheiro suficiente", client, 255, 0, 0) playSoundFrontEnd(client, 6) end end end addEvent("onPlayerBuy", true) addEventHandler("onPlayerBuy", resourceRoot, onPlayerBuy) Estava tentando ver uma forma de não deixar o valor da data passar de 100, primeira coisa que veio na cabeça foi essa verificação porém ela não é executada, creio que há também algum cálculo para o valor não passar de 100
×
×
  • Create New...