Jump to content
  • 0

Limited time atcommand


Zeromaru

Question


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  3
  • Reputation:   0
  • Joined:  01/30/12
  • Last Seen:  

I've use bindatcmd to create a limited time @autoloot

this is my script

 

-    script    ATLsetTick    -1,{
OnInit:
    bindatcmd "atlt",strnpcinfo(3)+"::OnAtlt";
    end;
OnPCLoginEvent:
    if (gettimetick(2) < #atl_expire) {
        attachnpctimer strcharinfo(0);
        initnpctimer strnpcinfo(3);
    }
    end;
OnAtlt:
    set #atl_expire, gettimetick(2) + 20;
    announce "You have 20 second to use @atl",bc_blue|bc_self;
    attachnpctimer strcharinfo(0);
    initnpctimer strnpcinfo(3);
    end;
OnTimer1000:
    if ((#atl_expire - gettimetick(2)) == 10)
        announce "10 sec left.",bc_blue|bc_self;
    else if ((#atl_expire - gettimetick(2)) == 5)
        announce "5 sec left.",bc_blue|bc_self;
    else if (gettimetick(2) > #atl_expire) {
        if (atl_check == 1) {
            atcommand "@autoloot";
            set atl_check, 0;
        }
        announce "timeout.",bc_self,0xFF0000;
        stopnpctimer strnpcinfo(3);
        detachnpctimer strnpcinfo(3);
    }
    initnpctimer strnpcinfo(3);
    end;
}

-    script    ATLCheck    -1,{
OnInit:
    bindatcmd "atl",strnpcinfo(3)+"::OnAtl";
    end;
OnPCLogoutEvent:
    set atl_check, 0;
    end;
OnAtl:
    if (gettimetick(2) > #atl_expire) {
        announce "You don't have permission.",bc_self,0xFF0000;
    }
    else {
        atcommand "@autoloot";
        if (atl_check == 0)
            set atl_check, 1;
        else if (atl_check == 1)
            set atl_check, 0;
    }
    end;
}

 

it's work fine but when script end and stop the timer it always show error in console like this

post-1939-0-48328800-1411883895_thumb.png

how i fix this?

Link to comment
Share on other sites

1 answer to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

Something like this?

-	script	autoloottimer	-1,{
OnInit:
bindatcmd "@autoloot",strnpcinfo(3)+"::OnAutoloot";
.timer = 20; //Seconds timer lasts.
end;

OnAutoloot:
if( autoloottimer > gettimetick(2) ){ dispbottom "You can't use this yet."; }
atcommand "@autoloot";
addtimer 1000,strnpcinfo(3)+"::OnTimer";
announce "You have "+ .timer +" seconds to use @autoloot",bc_blue|bc_self;
end;

OnTimer:
altimer++;
if( altimer == 10 ) {
	announce "10 seconds left.",bc_blue|bc_self; }
if( altimer == 15 ) {
	announce "15 seconds left.",bc_blue|bc_self; }
if( autoloottimer < gettimetick(2) || altimer >= .timer ) {
	altimer = 0;
	autoloottimer = 0;
	atcommand "@autoloot";
	announce "Timeout.",bc_blue|bc_self;
	end; }

addtimercount strnpcinfo(3)+"::OnTimer",1000;	
end;

OnPCLoginEvent:
if( autoloottimer > gettimetick(2) ) {
	addtimer 1000,strnpcinfo(3)+"::OnTimer";
	}
end;
}

It'd be better to use addtimer in this case, since it'll eliminate the need to attach/deatch/reinitiate the timer over and over again.

I made a sample script that should do what you wanted, but using the command: @autoloot   to trigger it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...