Jump to content

Limite de level


Recommended Posts

--[[



 ################################################
 #                                              #
 #              Script Criado Por               #
 #           FACEBOOK.COM/AIRNEWSCR             #
 #                                              #
 #                                              #
 ################################################



--]]

--------------------------------------------------------------------------------------------

exports [ "scoreboard" ]:addScoreboardColumn ( "Level") 

--------------------------------------------------------------------------------------------

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

function DAR_XP_AIRNEWSCR ( source, cmd, pname, Quantidade )
    if pname and tonumber(Quantidade) then
	    local cliente = getPlayerFromPartialName(pname)
	    if isElement(cliente) then
		    if getElementData ( source, "Console_AirNewSCR" ) == "Sim" then
			    setElementData ( cliente, "Level", Quantidade )
			    exports.Scripts_Dxmessages:outputDx(source, "Você Setou o Level do(a) Jogador(a) "..getPlayerName(cliente).."#ffffff para "..Quantidade.." com Sucesso!", "success")
			    exports.Scripts_Dxmessages:outputDx(cliente, "O(A) Admin "..getPlayerName(source).."#ffffff Setou seu Level para "..Quantidade.." com Sucesso!", "success")
		    end
		else
		    exports.Scripts_Dxmessages:outputDx(source, "O Jogador Não Foi Encontrado", "error")
		end
	end
end
addCommandHandler ( "level", DAR_XP_AIRNEWSCR )

function convertS(s)
	if type(tonumber(s)) == "number" then
		milisegundo = s
		local horas_seg=3600
		local hora = math.floor(milisegundo/horas_seg)
		local minuto = math.floor((milisegundo-(horas_seg*hora))/60)
		local segundo = math.floor((milisegundo-(horas_seg*hora)-(minuto*60)))	
		local tudo = string.format("%02d:%02d:%02d",hora,minuto,segundo)	
		local dia = math.floor(s/86400)
		return hora,minuto,segundo,tudo,dia
	else
		return 0,0,0,0,0		
	end
end

--------------------------------------------------------------------------------------------

function saveData(conta)
	if conta then
		local source = getAccountPlayer(conta)
		local level = getElementData(source,"Level") or 0
		local exp = getElementData(source,"LSys:EXP") or 0
		--local onlinetime = getElementData(source,"LSys:Online") or 0
		--local mins = getElementData(source,"LSys:Mins") or 0
		setAccountData (conta, "Level",level)
		setAccountData (conta, "LSys:EXP",exp)
		--setAccountData (conta, "LSys:Online",onlinetime)
		--setAccountData (conta, "LSys:Mins",mins)
	end
end

--------------------------------------------------------------------------------------------

function loaddata(conta)
	if not (isGuestAccount (conta)) then
		if (conta) then	
			local source = getAccountPlayer(conta)	
			local level = getAccountData(conta,"Level")
			if type(level) == "boolean" or level == nil then
				level = 0
			end
			setElementData (source, "Level", tonumber(level))
			setElementData (source, "LSys:EXP",tonumber(getAccountData(conta,"LSys:EXP")) or 0)
			--setElementData (source, "LSys:Online",tonumber(getAccountData(conta,"LSys:Online")) or 0)
			--setElementData (source, "LSys:Mins",tonumber(getAccountData(conta,"LSys:Mins")) or 0)
		end
	end	
end

--------------------------------------------------------------------------------------------

function timecount ( )
	for i, player in ipairs(getElementsByType("player")) do
		local acc = getPlayerAccount(player)
		if acc then
			if not isGuestAccount(acc) then
			    if getElementData ( player, "AirNewSCR_LiberarXP" ) == "Sim" then
				    setElementData ( player, "AirNewSCR_LiberarXP", "Não" )
				    local level = getElementData(player,"Level") or 0 if tonumber(level) == nil then level = 0 end
				    local exp = getElementData(player,"LSys:EXP") or 0 if tonumber(exp) == nil then exp = 0 end
				    --local onlinetime = getElementData(player,"LSys:Online") or 0 if tonumber(onlinetime) == nil then onlinetime = 0 end
				    --local mins = getElementData(player,"LSys:Mins") or 0 if tonumber(mins) == nil then mins = 0 end
				    --if tonumber(mins) == 600 then
					--    setElementData(player,"LSys:Mins",1)
					--end
					if tonumber(exp) >= 19 then
					    setElementData(player,"LSys:EXP",0)
					    setElementData(player,"Level",tonumber(level)+1)
					    --outputChatBox ( "#ffffff[ #82FA58UP #ffffff] - Você Ganhou +1 de Experiência. (".. tonumber(exp)+1 .."/6)", player, 255, 255, 255, true )
					    outputChatBox ( "#ffffff[ #82FA58UP #ffffff] - Você Juntou 100 de Experiência e Ganhou +1 Level ("..tonumber(level)+1 ..")", player, 255, 255, 255, true )
					    playSoundFrontEnd ( player, 45 )
					    --DarSalario (player) -- Efetua os Pagamentos dos Jogadores
					else
					    outputChatBox ( "#ffffff[ #82FA58UP #ffffff] - Você Ganhou +1 de Experiência. (".. tonumber(exp)+1 .."/20)", player, 255, 255, 255, true )
					    setElementData(player,"LSys:EXP",tonumber(exp)+1)
					    --playSoundFrontEnd ( player, 44 )
					end
				    --if tonumber(mins) < 600 then
				    --    setElementData(player,"LSys:Mins",tonumber(mins)+1)
				    --    setElementData(player,"LSys:Online",tonumber(onlinetime)+1)
					--end
		        end
			end
	    end
    end
end
setTimer ( timecount, 1000, 0 )	

--[[function DarSalario (player)

local account = getPlayerAccount (player)
local accname = getAccountName (account)
local Jogador = getPlayerName (player)

EmpregoAtual = getElementData ( player, "Emprego" )

sDesempregado = 300
sEntregadorDeJornal = 500
sPizzaBoy = 600
sMotoristaDeUber = 700
sMecanico = 800
sPetroleiro = 900
sMotoristaDeOnibus = 1000
sPilotoDeAviao = 1100

sPolicial = 10000

SeguroDeVida = getElementData ( player, "Hospital:SeguroDeVida" )
MensalidadeSeguroDeVida = 150

outputChatBox ( "#F9A631~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #F96031Salário #F9A631~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", player, 255, 255, 255, true )

outputChatBox ( "#F96031» #BEE09ALogin da Conta #ffffff: #9ABDE0"..accname.." / #BEE09ANick #ffffff: #9ABDE0"..Jogador.."", player, 255, 255, 255, true )

if EmpregoAtual == "Entregador de Jornal" then
givePlayerMoney ( player, sEntregadorDeJornal )
outputChatBox ( "#F96031» #BEE09AProfissão Atual #ffffff: #9ABDE0"..EmpregoAtual.."", player, 255, 255, 255, true )
outputChatBox ( "#F96031» #BEE09ASalário da Profissão #ffffff: #9ABDE0$"..sEntregadorDeJornal.."", player, 255, 255, 255, true )

elseif EmpregoAtual == "PizzaBoy" then
givePlayerMoney ( player, sPizzaBoy )
outputChatBox ( "#F96031» #BEE09AProfissão Atual #ffffff: #9ABDE0"..EmpregoAtual.."", player, 255, 255, 255, true )
outputChatBox ( "#F96031» #BEE09ASalário da Profissão #ffffff: #9ABDE0$"..sPizzaBoy.."", player, 255, 255, 255, true )

elseif EmpregoAtual == "Motorista de Uber" then
givePlayerMoney ( player, sMotoristaDeUber )
outputChatBox ( "#F96031» #BEE09AProfissão Atual #ffffff: #9ABDE0"..EmpregoAtual.."", player, 255, 255, 255, true )
outputChatBox ( "#F96031» #BEE09ASalário da Profissão #ffffff: #9ABDE0$"..sMotoristaDeUber.."", player, 255, 255, 255, true )

elseif EmpregoAtual == "Mecanico" then
givePlayerMoney ( player, sMecanico )
outputChatBox ( "#F96031» #BEE09AProfissão Atual #ffffff: #9ABDE0"..EmpregoAtual.."", player, 255, 255, 255, true )
outputChatBox ( "#F96031» #BEE09ASalário da Profissão #ffffff: #9ABDE0$"..sMecanico.."", player, 255, 255, 255, true )

elseif EmpregoAtual == "Petroleiro" then
givePlayerMoney ( player, sPetroleiro )
outputChatBox ( "#F96031» #BEE09AProfissão Atual #ffffff: #9ABDE0"..EmpregoAtual.."", player, 255, 255, 255, true )
outputChatBox ( "#F96031» #BEE09ASalário da Profissão #ffffff: #9ABDE0$"..sPetroleiro.."", player, 255, 255, 255, true )

elseif EmpregoAtual == "Motorista de Onibus" then
givePlayerMoney ( player, sMotoristaDeOnibus )
outputChatBox ( "#F96031» #BEE09AProfissão Atual #ffffff: #9ABDE0"..EmpregoAtual.."", player, 255, 255, 255, true )
outputChatBox ( "#F96031» #BEE09ASalário da Profissão #ffffff: #9ABDE0$"..sMotoristaDeOnibus.."", player, 255, 255, 255, true )

elseif EmpregoAtual == "Piloto de Aviao" then
givePlayerMoney ( player, sPilotoDeAviao )
outputChatBox ( "#F96031» #BEE09AProfissão Atual #ffffff: #9ABDE0"..EmpregoAtual.."", player, 255, 255, 255, true )
outputChatBox ( "#F96031» #BEE09ASalário da Profissão #ffffff: #9ABDE0$"..sPilotoDeAviao.."", player, 255, 255, 255, true )

elseif EmpregoAtual == "Policial" then
givePlayerMoney ( player, sPolicial )
outputChatBox ( "#F96031» #BEE09AProfissão Atual #ffffff: #9ABDE0"..EmpregoAtual.."", player, 255, 255, 255, true )
outputChatBox ( "#F96031» #BEE09ASalário da Profissão #ffffff: #9ABDE0$"..sPolicial.."", player, 255, 255, 255, true )

elseif EmpregoAtual == false then
givePlayerMoney ( player, sDesempregado )
outputChatBox ( "#F96031» #BEE09AProfissão Atual #ffffff: #9ABDE0Desempregado", player, 255, 255, 255, true )
outputChatBox ( "#F96031» #BEE09ASalário da Profissão #ffffff: #9ABDE0$"..sDesempregado.."", player, 255, 255, 255, true )

end

if SeguroDeVida == true then
takePlayerMoney ( player, MensalidadeSeguroDeVida )
outputChatBox ( "#F96031» #BEE09AMensalidade do Seguro de Vida #ffffff: #FA5858-$"..MensalidadeSeguroDeVida.."", player, 255, 255, 255, true )
end


outputChatBox ( "#F9A631~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #F96031Salário #F9A631~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", player, 255, 255, 255, true )

end--]]

--[[

--------------------------------------------------------------------------------------------

function meulevel(source)
	triggerClientEvent(source,"SHOW.WINDOW.LEVELSYS",source,true)
end
addCommandHandler("meulevel",meulevel)

--------------------------------------------------------------------------------------------

function restart()
	for index, player in ipairs(getElementsByType("player")) do
		bindKey(player, "F2", "down", meulevel)
	end
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), restart)

--------------------------------------------------------------------------------------------

function entrar()
	bindKey(source, "F2", "down", meulevel)
end
addEventHandler("onPlayerJoin", getRootElement(), entrar)

--------------------------------------------------------------------------------------------

function fechar(player)
	for index, player in ipairs(getElementsByType("player")) do
		unbindKey(player, "F2", "down", meulevel)
	end
end
addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), fechar)

--]]

------------------------------------------------------------------------------------------------------

addEventHandler("onPlayerLogin", root,
  function( _, acc )
	setTimer(loaddata,1000,1,acc)
  end
)

--------------------------------------------------------------------------------------------

function startScript ( res )
	if res == getThisResource() then
		for i, player in ipairs(getElementsByType("player")) do
			local acc = getPlayerAccount(player)
			if not isGuestAccount(acc) then
				loaddata(acc)			
			end
		end
	end
end
addEventHandler ( "onResourceStart", getRootElement(), startScript )

--------------------------------------------------------------------------------------------

function stopScript( res )
    if res == getThisResource() then
		for i, player in ipairs(getElementsByType("player")) do
			local acc = getPlayerAccount(player)
			if not isGuestAccount(acc) then
				saveData(acc)	
			end
		end
	end
end 
addEventHandler ( "onResourceStop", getRootElement(), stopScript )

--------------------------------------------------------------------------------------------

function deslogar(acc)
	cancelEvent ()
end
addEventHandler("onPlayerLogout",getRootElement(),deslogar)

--------------------------------------------------------------------------------------------

function sair ( quitType )
	local acc = getPlayerAccount(source)
	if not (isGuestAccount (acc)) then
		if acc then
			saveData(acc)
		end
	end
end
addEventHandler ( "onPlayerQuit", getRootElement(), sair )

--------------------------------------------------------------------------------------------

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...