Jump to content
  • 0
nasagnilac

Hourly Points Request

Question

I have a problem in my Hourly Points System.
 

Here's my script. My problem is the idle. Im not sure if it really works and stop the timer. and when it reach the 60 minutes player don't get any reward points. Please help me thnx



-	script	hourlypoints	FAKE_NPC,{

OnInit:
	set .point_name$,"reward points";
	set .point_amt, 3; //Normal points gained.
	set .dlimit, 600; //Stop points if afk greater then in seconds.
	set .enable,1;
	set .level,0;
	bindatcmd "ht","hourlypoints::OnDoTimer",0,100;		// Admin reset command
end;


OnDoTimer:
if(BaseLevel >= .level){
		set .@m,#timetick % 3600 / 60;
		set .@s,#timetick % 60;
		set .@m$, (60-.@m)+" minute"+((.@m <= 1)?"":"s");
		set .@s$, (60-.@s)+" second"+((.@s <= 1)?"":"s");
		set .@time$,""+.@m$+" "+.@s$+"";
		if(#idle){
			dispbottom "You been idle for 10 minutes. Please relog again.";
		}else{
			dispbottom "You have [ "+.@time$+" ] left in able to gain a reward points.";
		}
}
end;



OnPCLoginEvent:
if(BaseLevel >= .level){
	set #idle,0;
	while(.enable && #idle == 0){
		if(checkvending() >= 1 && checkidle() >= .dlimit || checkchatting() == 1 && checkidle() >= .dlimit || checkidle() >= .dlimit) {
            		dispbottom "The hourly points event haulted because you were vending, chatting, or idle.";
					set #idle,1;
					set #acctick,gettimetick(2);
					set #timetick,#timetick + (gettimetick(2) - #acctick);
					end;
		}else{ 
			set #acctick,gettimetick(2);
			sleep2 1000;
			set #timetick,#timetick + (gettimetick(2) - #acctick);
		
			set .@h,#timetick % 86400 / 3600 / 24;
			set .@m,#timetick % 3600 / 60;
			set .@s,#timetick % 60;

			set .@h$, .@h+" hour"+((.@h <= 1)?"":"s");
			set .@m$, .@m+" minute"+((.@m <= 1)?"":"s");
			set .@s$, .@s+" second"+((.@s <= 1)?"":"s");
			set .@time$,""+.@h$+" "+.@m$+" "+.@s$+"";
			if(.@m >= 60){
				set #RP,#RP + .point_amt;
				dispbottom "Gained "+.point_amt+" "+.point_name$+". Total "+#RP+" points.";
				set #timetick,0;
			}else if(.@m == 15 && .@s == 0 || .@m == 30 && .@s == 0 || .@m == 45 && .@s == 0){
				dispbottom "You spend a total of [ "+.@time$+" ] playing.";
			}
		}

	}
}	
end;


OnPCLogoutEvent:
	if(BaseLevel >= .level){
		if(.enable){
					set #acctick,gettimetick(2);
					set #timetick,#timetick + (gettimetick(2) - #acctick);
		}
	}
end;


}
 

 

 

 

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0
Hey there, did a quick test and I fixed a few things that were causing the problem, now the prize is being delivered and the time the player stay online is saving also, can have some problems, still needs more testing.
And have a little problem, if you use '@reloadscript', the function 'while' in event 'OnPCLoginEvent:' stop the time count, but if players relog, time count back again.
 
Sorry for my english, I only understand a little of english.  :)
 

 

 

 


-    script    hourlypoints    FAKE_NPC,{
 
OnInit:
    set .point_name$,"reward points";
    set .point_amt, 3; //Normal points gained.
    set .dlimit, 600; //Stop points if afk greater then in seconds.
    set .enable,1;
    set .level,0;
    bindatcmd "ht","hourlypoints::OnDoTimer",0,100;        // Admin reset command
end;
 
 
OnDoTimer:
if(BaseLevel >= .level){
        set .@m,#timetick % 3600 / 60;
        set .@s,#timetick % 60;
        set .@m$, (60-.@m)+" minute"+((.@m <= 1)?"":"s");
        set .@s$, (60-.@s)+" second"+((.@s <= 1)?"":"s");
        set .@time$,""+.@m$+" "+.@s$+"";
        if(#idle){
            dispbottom "You been idle for sometime. Please relog again.";
        }else{
            dispbottom "You have [ "+.@time$+" ] left in able to gain a reward points.";
        }
}
end;
 
OnPCLoginEvent:
if(BaseLevel >= .level){
    set #idle,0;
    set #acctick, (#timetick) ? (gettimetick(2) - #timetick) : gettimetick(2); // BackUP online time
 
    while(.enable)
    {
        if(checkvending() >= 1 || checkchatting() == 1 || checkidle() >= .dlimit) {
                    dispbottom "The hourly points event haulted because you were vending, chatting, or idle.";
                    set #idle,1;
                    set #acctick,0;
                    set #timetick,0;
        }else{ 
            sleep2 1000;
            set #timetick, gettimetick(2) - #acctick;
        
            set .@h,#timetick % 86400 / 3600 / 24;
            set .@m,#timetick % 3600 / 60;
            set .@s,#timetick % 60;
 
            set .@h$, .@h+" hour"+((.@h <= 1)?"":"s");
            set .@m$, .@m+" minute"+((.@m <= 1)?"":"s");
            set .@s$, .@s+" second"+((.@s <= 1)?"":"s");
            set .@time$,""+.@h$+" "+.@m$+" "+.@s$+"";
            if(.@m >= 60){
                set #RP,#RP + .point_amt;
                dispbottom "Gained "+.point_amt+" "+.point_name$+". Total "+#RP+" points.";
                set #acctick,gettimetick(2);
            }else if(.@m == 15 && .@s == 0 || .@m == 30 && .@s == 0 || .@m == 45 && .@s == 0){
                dispbottom "You spend a total of [ "+.@time$+" ] playing.";
            }
        }
 
        if (#idle)
            break;
    }
}    
end;
 
}

 

 

Share this post


Link to post
Share on other sites
  • 0

Looks like this one is better but still don't receive any points if I set it to 60 minutes.

 



-	script	hourlypoints	FAKE_NPC,{

OnInit:
	set .point_name$,"reward points";
	set .point_amt, 3; //Normal points gained.
	set .dlimit, 180; //Stop points if afk greater then in seconds.
	set .enable,1;
	set .level,0;
	bindatcmd "ht","hourlypoints::OnDoTimer",0,100;		// Admin reset command
end;


OnDoTimer:
if(BaseLevel >= .level){
		set m,#timetick % 3600 / 60;
		set s,#timetick % 60;
		set m$, (60-m)+" minute"+((m <= 1)?"":"s");
		set s$, (60-s)+" second"+((s <= 1)?"":"s");
		set time$,""+m$+" "+s$+"";
		if(#idle){
			dispbottom "You been idle for 3 minutes. Please relog again.";
		}else{
			dispbottom "You have [ "+time$+" ] left in able to gain a reward points.";
		}
}
end;



OnPCLoginEvent:
if(BaseLevel >= .level){
	set #idle,0;
	while(.enable){
		if(checkvending() >= 1 && checkidle() >= .dlimit || checkchatting() == 1 && checkidle() >= .dlimit || checkidle() >= .dlimit) {
            		dispbottom "The hourly points event haulted because you were vending, chatting, or idle.";
			set #idle,1;
			set #acctick,gettimetick(2);
			set #timetick,#timetick + (gettimetick(2) - #acctick);
			break;
		} 
			set #acctick,gettimetick(2);
			sleep2 1000;
			set #timetick,#timetick + (gettimetick(2) - #acctick);
		
			set h,#timetick % 86400 / 3600 / 24;
			set m,#timetick % 3600 / 60;
			set s,#timetick % 60;

			set h$, h+" hour"+((h <= 1)?"":"s");
			set m$, m+" minute"+((m <= 1)?"":"s");
			set s$, s+" second"+((s <= 1)?"":"s");
			set time$,""+h$+" "+m$+" "+s$+"";
			if(m >= 60){
				set #RP,#RP + .point_amt;
				dispbottom "Gained "+.point_amt+" "+.point_name$+". Total "+#RP+" points.";
				set #timetick,0;
			}else if(m == 15 && s == 0 || m == 30 && s == 0 || m == 45 && s == 0){
				dispbottom "You spend a total of [ "+time$+" ] playing.";
			}	

	}
}	
end;


OnPCLogoutEvent:
	if(BaseLevel >= .level){
		if(.enable){
					set #acctick,gettimetick(2);
					set #timetick,#timetick + (gettimetick(2) - #acctick);
		}
	}
end;


}
 

Share this post


Link to post
Share on other sites
  • 0

I redid all the code, I think it is now ok, at least here in my tests works fine...

If have problems, I'll try help you.

:)

 

 

 

 

-    script    hourlypoints    FAKE_NPC,{
 
OnInit:
    announce "[Hourly Points System]: The system have been reloaded, please relog again to get more points.", bc_all;
 
    .point_name$ = "reward points";
    .point_amt = 3;    // Normal points gained.
    .dlimit = 600;    // Stop points if afk greater then in seconds. 600s = 10 minutes
    .enable = 1;
    .level = 0;
    .online_time = 3600; // One hour = 3600 seconds
 
    bindatcmd "ht", "hourlypoints::OnAtcommand", 0, 100;
    end;
 
OnPCLoginEvent:
    if (BaseLevel >= .level)
    {
        #idle = 0;
        @backup_time = 0;
 
        if (!#acctick || #acctick > .online_time)
            #acctick = gettimetick(2) + .online_time;
        else
            #acctick += gettimetick(2);
 
        while(.enable)
        {
            @idle_time = checkidle();
 
            if (checkvending() >= 1 || checkchatting() == 1 || @idle_time >= .dlimit)
            {
                #acctick += @idle_time; // Add idle time
                #idle = 1;
                dispbottom "The hourly points event haulted because you were vending, chatting, or idle.";
                dispbottom "Please relog again.";
            }
            else
            {
                sleep2 1000;
 
                @backup_time = .@time_left = #acctick - gettimetick(2);
 
                if (.@time_left <= 0)
                {
                    #RP += .point_amt;
                    #acctick = gettimetick(2) + .online_time;
                    dispbottom "Gained " + .point_amt + " " + .point_name$ + ". Total " + #RP + " points.";
                }
                else
                {
                    .@time_left = .online_time - .@time_left;
                    .@Time$ = "";
                    .@Minutes = .@time_left / 60;
                    .@time_left -= (.@Minutes * 60);
 
                    if (.@Minutes > 1)
                        .@Time$ += .@Minutes + " minutes, ";
                    else if (.@Minutes > 0)
                        .@Time$ += .@Minutes + " minute, ";
 
                    if (.@time_left > 1 || .@time_left == 0)
                        .@Time$ += .@time_left + " seconds";
                    else if (.@time_left == 1)
                        .@Time$ += .@time_left + " second";
 
                    if (.@Minutes == 15 && .@time_left == 0 || .@Minutes == 30 && .@time_left == 0 || .@Minutes == 45 && .@time_left == 0)
                        dispbottom "You spend a total of [" + .@Time$ + "] playing.";
                }
            }
 
            if (#idle)
                break;
        }
    }
    end;
 
OnPCLogoutEvent:
    // BackUP online time
    if (BaseLevel >= .level)
    {
        if (@backup_time)
            #acctick = @backup_time;
    }
    end;
 
OnAtcommand:
    if (BaseLevel >= .level)
    {
        if (#idle)
        {
            .@Time$ = "";
            .@Minutes = @idle_time / 60;
            .@time_left = @idle_time - (.@Minutes * 60);
 
            if (.@Minutes > 1)
                .@Time$ += .@Minutes + " minutes, ";
            else if (.@Minutes > 0)
                .@Time$ += .@Minutes + " minute, ";
 
            if (.@time_left > 1 || .@time_left == 0)
                .@Time$ += .@time_left + " seconds";
            else if (.@time_left == 1)
                .@Time$ += .@time_left + " second";
 
            dispbottom "You been idle for " + .@Time$ + ". Please relog again.";
        }
        else
        {
            .@time_left = @backup_time;
            .@Time$ = "";
            .@Minutes = .@time_left / 60;
            .@time_left -= (.@Minutes * 60);
 
            if (.@Minutes > 1)
                .@Time$ += .@Minutes + " minutes, ";
            else if (.@Minutes > 0)
                .@Time$ += .@Minutes + " minute, ";
 
            if (.@time_left > 1 || .@time_left == 0)
                .@Time$ += .@time_left + " seconds";
            else if (.@time_left == 1)
                .@Time$ += .@time_left + " second";
 
            dispbottom "You have [" + .@Time$ + "] left in able to gain a reward points.";
        }
    }
    end;
}

 

 

Share this post


Link to post
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.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.