Jump to content

main

Members
  • Posts

    112
  • Joined

  • Days Won

    1

Posts posted by main

  1. 41 minutes ago, KingSCR said:

    Meu amigooo.. que mudança... agora cabe a mim a aprender cada argumento que você usou!

    Obrigado de coração ?

    Como funciona o hitElement e o matchingDimension na função?

    
    function entrar1(hitElement, matchingDimension)
    	if isElement(hitElement) and matchingDimension then
    		if getElementType(hitElement) == "player" and not isPedInVehicle(hitElement) then
    

     

    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. 6 minutes ago, KingSCR said:
    
    function entrar1 (thePlayer)
      if isElement(thePlayer) and getElementType(thePlayer) == "player" 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)
    

     

    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. 17 minutes ago, KingSCR said:

    Olá amigos da comunidade, estou aprendendo um pouco de programação e estou com uma duvida no meu teleporte. Estou tentando usar o "isPedInVehicle" como faço isso?

    Meu código está assim:

    
    local entrar = createMarker(2033.91504, -1402.85449, 16, "cylinder", 2, 255, 0, 0, 50) 
    
    function entrar1 (thePlayer)
        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
    addEventHandler ("onMarkerHit", entrar, entrar1)
    

    Estou tentando bloquear a teleporte com o veiculo usando um if com o "isPedInVehicle"

    
    function entrar1 (thePlayer)
      if not isPedInVehicle ( source ) 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)
    

    Assim penso eu que iria funcionar, mais nãaoo. O que estou fazendo de errado? ?

    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. 14 minutes ago, rOckzinhoMTA said:
    
    CLIENT-SIDE 
    
    function Abrir_Flecca ( )
        if PainelDX == false then
            showCursor ( true )
            playSoundFrontEnd ( 43 )
            PainelDX = true
            addEventHandler ( "onClientRender", getRootElement(), Painel_DX )
        end
    end
    addEvent ( "AbrirFleeca", true)
    addEventHandler ( "AbrirFleeca", root, Abrir_Flecca )
    
    function Fechar_Flecca ( )
        if PainelDX == true then
            showCursor ( false )
            playSoundFrontEnd ( 40 )
            PainelDX = false
            removeEventHandler ( "onClientRender", getRootElement(), Painel_DX )
        end
    end
    addEvent ( "FecharFleeca", true)
    addEventHandler ( "FecharFleeca", root, Fechar_Flecca )
    
    SERVER-SIDE
    
    function Abrir_Painel ( marker, md )
      if md then
        if not isPedInVehicle ( source ) then
          if marker == Painel_Marker then
              triggerClientEvent ( source, "AbrirFleeca", root )
          end
        end
      end
    end
    addEventHandler ( "onPlayerMarkerHit", getRootElement(), Abrir_Painel )
    
    function Fechar_Painel ( marker, md )
      if md then
          if marker == Painel_Marker then
            triggerClientEvent ( source, "FecharFleeca", root )
        end
        end
    end
    addEventHandler ( "onPlayerMarkerLeave", getRootElement(), Fechar_Painel )
    

     

    Talvez esse tópico te ajude: 

     

  5. 42 minutes ago, MainSCR said:
    
    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

    @MaligNos desculpe, funcionou sim, eu que estava testando com o freeroam ligado .-.

    Muito obrigado pela ajuda.

    • Like 1
  6. 10 hours ago, MaligNos said:
    
    setElementVisibleTo(blip[player], root, false)
    for _, teamMember in ipairs (getPlayersInTeam(playerTeam)) do
    	setElementVisibleTo(blip[player], teamMember, true)
    end
    

     

    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

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

  8. 5 hours ago, +[T]rakin said:

    Olá tudo bem estou querendo tirar uma duvida se é possivel fazer uma verificação do objeto que eu criei. Digamos quando eu passa por cima de um marker vai está verificando se o objeto está criado se entao ele vai ser excluido.

    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.

    • Thanks 1
  9. 3 hours ago, MaligNos said:

    Visualmente não vi erro na tabela. Então fui testar e funcionou, dei kill e ele printou o elemento veículo e seu id.

    Obs: Se ficar um tempo fora do veículo o f1 tem um sistema para destruir o veículo, ai vai dar erro. (verificando um veículo que já foi destruído)

    Pois é, está tudo normal, acho que está dando algum conflito no servidor que estou utilizando ele, vou tentar resolver isso.

    • Haha 1
  10. 5 minutes ago, Lord Henry said:

    Substitua as funções onPlayerWasted e onSoltarWasted por essa:

    
    function onPlayerDied(totalAmmo, killer, killerWeapon, bodypart, stealth) -- Não use nome de evento como nome de função.
    	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
    addEventHandler("onPlayerWasted", root, onPlayerDied)
    

     

    Continua a mesma coisa

    • Haha 1
  11. 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

     

    • Haha 1
  12. 12 minutes ago, DNL291 said:

    Tente com apenas um object sendo anexado. Faça um teste anexando só 1 elemento pra ver se funciona, comente a linha 30 e deixe só 1 object. Certifique-se também que os elementos (objets e a marker foram criados sem erros).

    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. 21 minutes ago, MaligNos said:

    Só uma dica também, antes de querer criar essa limitação, seria adequado utilizar métodos eficazes de recuperação de senha, pois constantemente o pessoal acaba se esquecendo de suas senhas (usam o “salvar senha” e em algum tempo limpa o cache e se esquece) e caso não consigam jogar criando uma outra conta, a perda de players seria considerável.

    Exemplos recuperação de senha:

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

  15. 3 hours ago, Lord Henry said:

    Bom, eu uso esse painel de login que também só permite 1 conta por serial. Na parte de registrar contas, ele verifica se já existe uma conta com o serial do jogador que está tentando registrar uma conta. Se tiver, bloqueia o registro e pede para que ele logue nela.

    Em vez de você usar getAccountData que é um pouco pesado de processar, use a função getAccountsBySerial, que retorna todas as contas que possuem o serial específico. Se existe alguma, então cancela o registro do jogador e pede para que ele logue nela.

    
    local myAccounts = getAccountsBySerial (getPlayerSerial (client)) -- myAccounts é uma table com todas as contas que existem com o serial do jogador.
    if myAccounts[1] then -- Se existe o primeiro item da table, então:
    	outputChatBox ("Você já tem uma conta registrada. Logue nela: "..getAccountName(myAccounts[1]), client) -- Manda isso no chat do jogador, informando o login da conta que já existe.
    end
    

     

    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.

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

  17. 2 hours ago, DNL291 said:
    
    local valor = 100
    if valor < 1000 then
      	print( "'valor' + 900: "..tostring((valor + 900)) ) -- saída: 1000
      	if valor >= 1000 then
    		print( "maior ou igual a 1000" )
    	end
    end
    

    Basicamente você está cometendo esse erro, a variável continua retornando o mesmo valor que na primeira checagem, porque ela não foi alterada.

    Correção:

    
    if atualDrink and atualDrink < 100 then
    	local drink_new = (atualDrink + 5) > 100 and 100 or (atualDrink + 5)
    	takePlayerMoney(client, 200)
    	setElementData(client, "thirsty", drink_new)
    	outputChatBox("Drink comprado com sucesso", client, 0, 255, 0)
    else
    	outputChatBox("Você não está com sede", client, 0, 255, 0)
    	playSoundFrontEnd(client, 6)
    end
    

    Ou use math.min:

    
    local drink_new = math.min( atualDrink + 5, 100 )
    

     

    Verdade @DNL291, não tinha percebido isso, muito obrigado.

    • Like 1
  18. 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...