Jump to content
  • 0

ps.setqf mais get_time()


Karbust

Question

  • VIP

Hi guys

 

I'm here with a problem in a function

 

To ban I have this:

pc.setqf("ban1dia", get_time()+1*60*60*24)

But if I want retire the ban before the times up how I can do?

 

I have this to take retire the ban:

					pc.setqf("ban1dia", 0)
					pc.setqf("ban2dias", 0)
					pc.setqf("ban7dias", 0)
					pc.setqf("ban15dias", 0)
					pc.setqf("ban30dias", 0)
					pc.setqf("banperma", 0)
					mysql_query("INSERT INTO log.log_desban_nickname (id, gm, player, razao, data) VALUES ('', '"..name.."', '".. player_name .."', '".. razao .."', '"..data1.."');")
					set_quest_state("bans","ban")
				end

And this is the login:

		when login begin
			if get_time() < pc.getqf("ban1dia") then
				return
			elseif get_time() > pc.getqf("ban1dia") then
				say("Personagem Banida durante 1 dia")
				say("[DELAY value; 1000]. . . . .[/DELAY]")
				command("quit")
			end

The problem is: I can't retire the ban :S

 

Someone can help me please?

 

Thanks to all

QJ0orbR.png

Metin2 Icon Database

Link to comment

5 answers to this question

Recommended Posts

  • 0

If you set the "ban1dia" to 0, then get_time() > 0 always will be true.

Try

when login begin
    if get_time() < pc.getqf("ban1dia") then
        say("Personagem Banida durante 1 dia")
        say("[DELAY value; 1000]. . . . .[/DELAY]")
        command("quit")
    end
  • Love 1

$ uptime
1:26AM  up 732 days,  8:29, 1 user, load averages: 0.38, 0.31, 0.22

$ uname -srp
FreeBSD 9.1-RELEASE amd64

Link to comment
  • 0

 

If you set the "ban1dia" to 0, then get_time() > 0 always will be true.

Try

when login begin
    local ban1dia = pc.getqf("ban1dia")
    if get_time() < ban1dia then
        return
    elseif ban1dia ~= 0 and (get_time() > ban1dia) then
        say("Personagem Banida durante 1 dia")
        say("[DELAY value; 1000]. . . . .[/DELAY]")
        command("quit")
    end

if is in that way it will still be wrong becuase ur making if get_time() < ban1dia then the ban is in going on and if get_time() > ban1dia the ban stopps.

 

so he has to make like this 

 if get_time() > ban1dia then
        return
    elseif ban1dia ~= 0 and (get_time() < ban1dia) then
        say("Personagem Banida durante 1 dia")
        say("[DELAY value; 1000]. . . . .[/DELAY]")
        command("quit")

 

  • Love 1
Link to comment
  • 0

Ok, i did some logical mistake. Above code edited and must work.

 

ban1dia is the timestamp, when ban will expire. If current timestamp is lowerthen ban1dia, ban is active...

$ uptime
1:26AM  up 732 days,  8:29, 1 user, load averages: 0.38, 0.31, 0.22

$ uname -srp
FreeBSD 9.1-RELEASE amd64

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


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.