Jump to content
  • 0

Hourly points to afk points


Eross

Question


  • Group:  Members
  • Topic Count:  166
  • Topics Per Day:  0.09
  • Content Count:  378
  • Reputation:   12
  • Joined:  04/05/20
  • Last Seen:  

Hi ! I just need help how to lessen the points given whenever a player goes AFK or IDLE .. This is an old Hourly system , I want to just give 1 point to those Afk players . they will continue gaining points while idle but not same as active players who have 5 to 6 points ... Thankyou !
 

-	script	hourlypoints	FAKE_NPC,{
 
OnInit:
    //announce "[30 Minutes Points System]: The system have been reloaded, please relog again to get more points.", bc_all;
    announce "[Hourly Reward System]: Hourly system has been reloaded, please relog again to get more points.", bc_all;
 
    .point_name$ = "Hourly Points";
    .point_amt = 5;    // Normal points gained.
    .dlimit = 900;    // Stop points if afk greater then in seconds. 600s = 10 minutes //43200
    .enable = 1;
    .level = 0;
    .online_time = 3600; // One hour = 3600 seconds
 
    bindatcmd "hourlytime", "hourlypoints::OnAtcommand", 0, 100;
	bindatcmd "hourlypoints", "hourlypoints::OnCheckPoints", 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.";
            }
            else
            {
                sleep2 1000;
 
                @backup_time = .@time_left = #acctick - gettimetick(2);
 
                if (.@time_left <= 0) {
                
					if (vip_status(1)) {
						#HOURLYPOINTS += .point_amt + 1;
						#acctick = gettimetick(2) + .online_time;
					     dispbottom "[Hourly Reward System]: Gained " + .point_amt + " " + .point_name$ + " +1 " + .point_name$ + " [Vip Bonus]. Stay online and gain more points.";

					}
					else {
                    #HOURLYPOINTS += .point_amt;
                    #acctick = gettimetick(2) + .online_time;
                    dispbottom "[Hourly Reward System]: Gained " + .point_amt + " " + .point_name$ + ". Total " + #HOURLYPOINTS + " Hourly Points. Stay online to gain more 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 "[Hourly Reward System]: 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;
OnCheckPoints: 
	dispbottom "[Hourly Reward System]: You have a total of ["+ #HOURLYPOINTS +"] Hourly Points.",0xRRGGBB;
	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 "[Hourly Reward System]: You been idle for " + .@Time$ + ". Please relog again.",0xRRGGBB;
        }
        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 "[Hourly Reward System]: You have [" + .@Time$ + "] left in able to gain a hourly points.",0xRRGGBB;
        }
    }
    end;
}



 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  114
  • Reputation:   4
  • Joined:  08/28/14
  • Last Seen:  

just create another hourly file that do not trigger when afk. like this 
 

-	script	hourlypoints	-1,{
    
OnPointGet:
	//Check for idle.
	while(checkvending() >= 1) {
		if( .@mes$ == "" ) {
			dispbottom set( .@mes$, "The hourly points event stopped because you were vending" );
			set @hourly_points_timer, 0;
		}
		sleep2 .delay;
	}	
	@consecutive_timer++;
	.@time_string$ = Time2Str( @consecutive_timer * ( .timer / 1000 ) );
	dispbottom "You received "+.points+" Hourly Point(s) by staying ingame for "+.@time_string$+".";
	#HOURLYPOINTS = #HOURLYPOINTS + .points;
	dispbottom "Current Balance = "+#HOURLYPOINTS+" Hourly Point(s)";
	@consecutive_bonus++;

	//Check for consecutive timer.
	if(@consecutive_bonus == .cdelay) {
		@consecutive_bonus = 0;
		#HOURLYPOINTS = #HOURLYPOINTS + .cpoints;
		dispbottom "You receive a bonus "+.cpoints+" Hourly Point(s) by playing for "+.@time_string$+" consecutively!!!";
		dispbottom "Current Balance = "+#HOURLYPOINTS+" Hourly Point(s)";
	}
	
OnPCLoginEvent:
	addtimer .timer,"hourlypoints::OnPointGet";
	@hourly_points_timer = gettimetick(2) + ( .timer / 1000 );
	end;
	
OnCmdHour:
	message strcharinfo(0),@hourly_points_timer ? Time2Str( @hourly_points_timer )+" remaining before you get your Hourly Reward(s).":"Something went wrong or you're considered idle at the moment, try relogging!";
	end;

OnInit:
	bindatcmd "hourlypoints","hourlypoints::OnCmdHour"; //@ctr to view time till next point.
	.timer   = 1000*60*60; //Timer in milliseconds. ( Default: 1000*60*60 [ = 1 Hour ] )
	.cdelay  = 10;          //Delay before receiving the consecutive bonus. ( Default: 3 [ { ~ 3 Hours } *Using default timer ] )
	.cpoints = 3;         //Points gained for consecutive time online. ( Default: 10 )
	.points  = 1;          //Normal points gained. ( Default: 1 )
	.delay   = 216000;       //Delay for idle re-check check. ( Default: 1000 [ = 1 Second ] )
	.idle    = 360*10;       //Player is idle after not moving for this many seconds. ( Default: 60*5 [ = 5 Minutes ] )
}


not my script just found somewhere else I just remove the function that check idle players tho still cancel hourly when vending.

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