Jump to content

  •  

Photo

Hourly Points Request


  • Please log in to reply
7 replies to this topic

#1 GM Fenrir™

GM Fenrir™

    Advanced Member

  • Members
  • PipPipPip
  • 91 posts
  • Github:gmblank

Posted 27 March 2016 - 01:14 PM

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;


}
 

 

 

 


#2 Cretino

Cretino

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts

Posted 27 March 2016 - 03:19 PM

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

Spoiler



#3 GM Fenrir™

GM Fenrir™

    Advanced Member

  • Members
  • PipPipPip
  • 91 posts
  • Github:gmblank

Posted 28 March 2016 - 09:40 AM

Thnx. I will try this one.



#4 Cretino

Cretino

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts

Posted 28 March 2016 - 02:54 PM

If have some problem, say here and I try help you.



#5 GM Fenrir™

GM Fenrir™

    Advanced Member

  • Members
  • PipPipPip
  • 91 posts
  • Github:gmblank

Posted 29 March 2016 - 09:38 AM

Some of my players said that they still dint get any reward points.



#6 GM Fenrir™

GM Fenrir™

    Advanced Member

  • Members
  • PipPipPip
  • 91 posts
  • Github:gmblank

Posted 29 March 2016 - 06:46 PM

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;


}
 


#7 Cretino

Cretino

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts

Posted 29 March 2016 - 09:23 PM

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.

:)

 

Spoiler



#8 GM Fenrir™

GM Fenrir™

    Advanced Member

  • Members
  • PipPipPip
  • 91 posts
  • Github:gmblank

Posted 30 March 2016 - 04:58 AM

looks like it works. I will update you again if there is a problem thnx.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users


This topic has been visited by 90 user(s)