Jump to content

Dias VIP


Recommended Posts

Posted

Opa.. Bom dia/tarde/noite
Tenho um script de ativar VIP e  Queria ajuda para Setar o VIP em ( x ) Dias 

Comando_VIP = "ativar"
Grupo = "Console" -- Grupo no Painel P ( Manage ACL )

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_VIP_AirNewSCR ( source, cmd, player, VIP, Dinheiro )
    if getElementData ( source, "Console_AirNewSCR" ) == "Sim" then
	    if player and VIP then
            local Jogador = getPlayerFromPartialName ( player )
            if Jogador then
		        if not isGuestAccount ( getPlayerAccount ( Jogador ) ) then
			        local Conta = getAccountName ( getPlayerAccount ( Jogador ) )
					if VIP == "Prata" then
					    if isObjectInACLGroup ("user."..Conta, aclGetGroup ( "Prata" ) ) then
					    	aclGroupRemoveObject ( aclGetGroup( VIP ), "user."..Conta )
			                return outputChatBox ( "* Erro: Esse Jogador já é VIP Prata", source, 255, 255, 255, true )
					    end
					elseif VIP == "Ouro" then
					    if isObjectInACLGroup ("user."..Conta, aclGetGroup ( "Ouro" ) ) then
					    	aclGroupRemoveObject ( aclGetGroup( VIP ), "user."..Conta )
			                return outputChatBox ( "* Erro: Esse Jogador já é VIP Ouro", source, 255, 255, 255, true )
					    end
					elseif VIP == "Esmeralda" then
					    if isObjectInACLGroup ("user."..Conta, aclGetGroup ( "Esmeralda" ) ) then
					    	aclGroupRemoveObject ( aclGetGroup( VIP ), "user."..Conta )
			                return outputChatBox ( "* Erro: Esse Jogador já é VIP Esmeralda", source, 255, 255, 255, true )
					    end
					elseif VIP == "Diamante" then
					    if isObjectInACLGroup ("user."..Conta, aclGetGroup ( "Diamante" ) ) then
					    	aclGroupRemoveObject ( aclGetGroup( VIP ), "user."..Conta )
			                return outputChatBox ( "* Erro: Esse Jogador já é VIP Diamante", source, 255, 255, 255, true )
					    end
					end
					if VIP == "Prata" or VIP == "Ouro" or VIP == "Esmeralda" or VIP == "Diamante" then
					    --return outputChatBox ( "* Erro: Esse VIP não existe!", source, 255, 255, 255, true )
					--end
			        aclGroupAddObject ( aclGetGroup( VIP ), "user."..Conta )
					Musica_Selecionada = math.random ( 1, 3 )
					triggerClientEvent ( root, "AirNewSCR_Ativar_VIP", root, Musica_Selecionada, VIP )
					if Musica_Selecionada == 1 then
						--outputChatBox ( "Arquivos/Rae_Sremmurd_Black_Beatles_ft_Gucci_Mane.mp3", source )
						Musica_Tocando = "XXXTENTACION - MoonLight"
						Bonus = 0
					elseif Musica_Selecionada == 2 then
						--outputChatBox ( "Arquivos/Post_Malone_Congratulations_ft_Quavo.mp3", source )
						Musica_Tocando = "Old Town Road"
						Bonus = 50
					elseif Musica_Selecionada == 3 then
						--outputChatBox ( "XXXTENTACION_Look_At_Me.mp3", source )
						Musica_Tocando = "FUNK DO MICKEY MOUSE"
						Bonus = 100
					end
					setElementData ( root, "Ultimo_Ativador", getPlayerName(Jogador) )
					setElementData ( root, "VIP_do_Ultimo_Ativador", VIP )
					outputChatBox ( " ", root )
					outputChatBox ( " ", root )
					outputChatBox ( "=======================================================", root, 255, 255, 255, true )
					outputChatBox ( "* O(A) Jogador(a) "..getPlayerName(Jogador).." #ffffffAtivou um Plano VIP "..VIP, root, 255, 255, 255, true )
					if Bonus == 0 then
						outputChatBox ( "* Muito Obrigado(a) pela compra do vip em nosso server", root, 255, 255, 255, true )
						if Dinheiro ~= false then
						    givePlayerMoney ( Jogador, 0 )
						    givePlayerMoney ( Jogador, 0 )
						end
					elseif Bonus == 50 then
						outputChatBox ( "* Muito Obrigado(a) pela compra do vip em nosso server", root, 255, 255, 255, true )
						if Dinheiro ~= false then
						    givePlayerMoney ( Jogador, 0 )
						    givePlayerMoney ( Jogador, 0 )
						end
					elseif Bonus == 100 then
					    outputChatBox ( "* Muito Obrigado(a) pela compra do vip em nosso server", root, 255, 255, 255, true )
						if Dinheiro ~= false then
						    givePlayerMoney ( Jogador, 0 )
						    givePlayerMoney ( Jogador, 0 )
						end
					end
					outputChatBox ( "* Musica Tocando: "..Musica_Tocando, root, 255, 255, 255, true )
					outputChatBox ( "=======================================================", root, 255, 255, 255, true )
					outputChatBox ( " ", root )
					outputChatBox ( " ", root )
					outputDebugString ( "[ Ativação ] - O(A) Admin "..getPlayerName(source).." Ativou um VIP para o(a) Jogador(a) "..getPlayerName(Jogador).."!" )
					outputDebugString ( "[ Ativação ] - Bonus do VIP Gerado: "..Bonus.."%" )
					setTimer ( function()
		                restartResource ( getThisResource ( ) ) -- Reinicia o Mod Automaticamente!
						outputDebugString ( "[ AirNewSCR ] - Resource 'Scripts_AtivarVIP' Reiniciado Automaticamente! " )
	                end, 15000, 1 )
			    end
			end
	        else
	            outputChatBox ( "* Erro: Jogador não encontrado!", source, 255, 255, 255, true )
            end
		end
	end
end
addCommandHandler ( Comando_VIP, Dar_VIP_AirNewSCR )

function Verificar_Emprego_Atual ( )
	for i, player in ipairs(getElementsByType("player")) do
		local acc = getPlayerAccount(player)
		if acc and not isGuestAccount(acc) then
			local accName = getAccountName (acc)
			if isObjectInACLGroup ("user."..accName, aclGetGroup ( Grupo ) ) then
			    setElementData ( player, "Console_AirNewSCR", "Sim" )
			else
			    setElementData ( player, "Console_AirNewSCR", "Não" )
			end
		end
	end
end
setTimer ( Verificar_Emprego_Atual, 1500, 0 )

-- By AirNewSCR 
Spoiler

 

 

Posted

Obtenha o timestamp atual com getRealTime().timestamp em seguida, some com a quantidade de segundos do tempo VIP e salve na conta do jogador.

A verificação do fim do VIP será comparando o timestamp atual (getRealTime().timestamp) com o do VIP do jogador.

Segue um código de exemplo:

local vip_segundos = 30000 -- tempo de vip em segundos

addCommandHandler("darvip", function( p,_, thePlayer)
	thePlayer = thePlayer and getPlayerFromName(thePlayer) or false
	if thePlayer then
		-- armazenar na conta o timestamp de duração do vip
		setAccountData( getPlayerAccount(thePlayer), "tempo:vip", getRealTime().timestamp + vip_segundos )
	end
end)

-- verificação do vip das contas
setTimer(function()
	for i,player in pairs(getElementsByType("player")) do
		local vip = getAccountData(getPlayerAccount(player), "tempo:vip") -- obter tempo de vip na conta
		
		if type(vip) == "number" then -- verificar se existe na conta, isto é, se consta o vip
			if getRealTime().timestamp - vip < 0 then -- verifica se o timestamp (segundos atuais) é maior que o tempo de vip
			
				outputChatBox("O seu pacote VIP expirou", player) -- notifica o jogador
				setAccountData(getPlayerAccount(player), "tempo:vip", false) -- remove da conta o vip
			end
		end
	end
end, 1000, 1)

 

  • Thanks 1

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

Quando eu gastei meu tempo para explicar como programar para o VIP funcionar e expirar com os dias, não foi pensando em dar o código para copy&paste. Se você entender minha explicação acima tenho certeza que não será difícil adicionar ao seu código.

Please do not PM me with scripting related question nor support, use the forums instead.

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