Jump to content
  • 0
eKoh

Hourly Reward script is closing the NPC Message box.

Question

Hello guys, today I am having this problem and the problem is the end; instruction executed by the Hourly Reward script I have in my server.

 

Here is the code:

 

 

 

- script hourlypoints -1,{
 
//-- Start of the Script
OnPCLoginEvent:
attachnpctimer ""+strcharinfo(0)+"";
initnpctimer;
end;
//-- Check if Vending (normal or @at)
 
OnTimer3000:
if(checkvending() >= 1 || checkchatting() == 1)
{
dispbottom "AriaRO hourly reward event stopped because you were vending / chatting. Please relog if you wish to start again.";
stopnpctimer;
end;
dispbottom "Chat 1";
}
dispbottom "Chat 2";
end;
 
//OnTimer60000:
OnTimer10000:
set @minute, @minute + 1;
dispbottom "1 minute";
//Check for 1 Minute
if(@minute == 60)
{
set @minute,0;
set .@point_amt, 10; //Points to get every hour (default: 10)
dispbottom "1 Hour";
getitem 20107,10;
dispbottom "You received AriaRO Hourly Ticket by staying ingame for 1 hour";
set @consecutive_hour, @consecutive_hour + 1;
}
 
stopnpctimer;
initnpctimer;
 
end;
 
}
//--End of the Script

 
I've added some dispbottom messages to see where the problem is, and it is from the end; instruction. Look:
 
UE6fFrw.jpg
 
DCyYR7n.jpg
 


 
The problem is, that the end; is that also executes in the NPC script or there is some kind of trouble between scripts. How can I fix this? Or is there a way to detect that a message box is running?

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

I don't think so, but I'll check it with a Virgin source.

 




It seems to be identical. I kind of solved the problem, I've put the 1st timer at the end and also removed the end; instruction so, but the bad thing is that the 1st Timer will execute the 2nd timer too. But there will not be a problem since the 2nd timer is the end of the script.

 

It's not the best solution, this will be bad if I want to implement some kind of script like this in the future.

 

 

 

- script hourlypoints -1,{
 
//-- Start of the Script
OnPCLoginEvent:
attachnpctimer ""+strcharinfo(0)+"";
initnpctimer;
end;
 
//OnTimer60000:
OnTimer10000:
set @minute, @minute + 1;
//Check for 1 Minute
if(@minute == 60)
{
set @minute,0;
set .@point_amt, 10; //Points to get every hour (default: 10)
dispbottom "1 Hour";
getitem 20107,10;
dispbottom "You received AriaRO Hourly Ticket by staying ingame for 1 hour";
set @consecutive_hour, @consecutive_hour + 1;
}
 
stopnpctimer;
initnpctimer;
 
//-- Check if Vending (normal or @at)
 
OnTimer30000:
if(checkvending() >= 1 || checkchatting() == 1)
{
dispbottom "AriaRO hourly reward event stopped because you were vending / chatting. Please relog if you wish to start again.";
stopnpctimer;
end;
}
}

Edited by eKoh

Share this post


Link to post
Share on other sites
  • 0

@@eKoh

 

Try this one:

-	script	hourlypoints	-1,{	OnReInit:	OnPCLoginEvent:		addtimer 1000, strnpcinfo( 3 ) + "::OnCheck";		set @checkCoolDown, gettimetick( 2 ) + 60;		end;	OnCheck:		// If player sells or chats.		if( checkvending() || checkchatting() )     {			// Display message that the event stopped.			dispbottom "AriaRO hourly reward event stops as long as you are vending / chatting and your idle time won't be counted torwards your reward.";		} else {			// If the check cooldown ran out.			if( gettimetick( 2 ) >= @checkCoolDown ) {				// Add one minute.				set @minutes,  @minutes + 1;								// If the minutes sum to one hour.				if( @minutes == 60 ) {					// Reset minutes.					set @minutes, 0;					// Hand out reward and display a message					getitem .rewardId, .rewardAmt;					dispbottom "You received AriaRO Hourly Ticket by staying ingame for 1 hour";					// Add one hour of online time.					set @hours, @hours + 1;				}								// Set the cooldown of the check to 1 minute.				set @checkCoolDown, gettimetick( 2 ) + 60;				}		}				// Reset the timer.		addtimer 3000, strnpcinfo( 3 ) + "::OnCheck";	end;	OnInit:		// Set reward id.		set .rewardId, 20107;			// Set amount of the reward.		set .rewardAmt, 10;				query_sql( "SELECT `account_id` FROM `char` WHERE `online` = 1", .@accountIds );				for( set .@i, 0; .@i < getarraysize( .@accountIds ); set .@i, .@i + 1 ) {			if( attachrid( .@accountIds[ .@i ] ) )		            doevent strnpcinfo( 3 ) + "::OnReInit";		}	end;} 

 

The one you used had 3 issues:

1. You forgot that you need to clean the NPC-Timers on player logout manually.

2. The npc would stop on script reload.

3. Because of it's design it needed to stop the whole execution once a player was idle and a relog had to be done.

 

This version doesn't have any of those issues, so you should give it a try.

Edited by Winterfox

Share this post


Link to post
Share on other sites
  • 0

Try this

-    script    hourlypoints    -1,{    end;OnInit:    .check = 1;        // how many second script will check on player    .timer = 1000;    // don't touch this    .counter = .check * .timer;    if (query_sql("SELECT `account_id` FROM `char` WHERE `online` = 1", .@accountIds )) {        for(.@i = 0; .@i < getarraysize(.@accountIds); .@i++) {            if (attachrid(.@accountIds[.@i]))                addtimer .counter, strnpcinfo(0)+"::OnCheck"; // Re-attaching timer to player on load        }    }    end;OnPCLoginEvent:    addtimer .counter, strnpcinfo(0)+"::OnCheck";    end;OnCheck:    if(checkvending() || checkchatting()) { // end timer script when player open chat room or vending        dispbottom "AriaRO hourly reward event stopped because you were vending / chatting. Please relog if you wish to start again.";        end;    }    Seconds += .check; // Player timer counter, no reset upon opening chat room, vending or loged out, continue where it left    if (Seconds >= 3600) { // 1 Hour = 3600 Seconds        Seconds = 0;        dispbottom "You received AriaRO Hourly Ticket by staying ingame for 1 hour";        getitem 20107, 10;    }    addtimer .counter, strnpcinfo(0)+"::OnCheck"; // Re-attaching timer to player    end; }
Edited by Litro

Share this post


Link to post
Share on other sites
  • 0

 

Try this

-	script	hourlypoints	-1,{	end;OnInit:	.check = 1; // how many second script will check on player	.timer = 1000; // don't touch this	.counter = .check * .timer;	end;OnPCLoginEvent:	addtimer .counter, strnpcinfo(0)+"::OnCheck";	end;OnCheck:	if(checkvending() || checkchatting()) { // end timer script when player open chat room or vending		dispbottom "AriaRO hourly reward event stopped because you were vending / chatting. Please relog if you wish to start again.";		end;	}	Seconds += .check; // Player timer counter, no reset upon opening chat room, vending or login out, continue where it left	if (Seconds >= 3600) { // 1 Hour = 3600 Seconds		Seconds = 0;		dispbottom "You received AriaRO Hourly Ticket by staying ingame for 1 hour";		getitem 20107, 10;		addtimer .counter, strnpcinfo(0)+"::OnCheck"; // Re-attaching timer to player	}	end; }

This won't work since once the user was idle the whole script will get halted also your timer won't be reset once the hour check failed for the first time and

if you fixed both you would still have the problem that you get the reward every hour without taking into account the delay induced by the afk time.

 

Also you will lose the connection to your timer on script reload, so you need to re-attach all online players after the reload.

@@eKoh

 

Since i am not sure hof that model shall work i recoded the first one i did and added a second version.

 

This one counts the seconds you are not idle and issues the reward every time you reach a non idle time of 1 hour:

-	script	hourlypoints	-1,{	end;	OnInit:		// Config Area //		// Set reward id.		set .rewardId, 20107;			// Set amount of the reward.		set .rewardAmt, 10;				// Interval in which the script gets updated in seconds.		set .updateInterval, 1;				// Time you need to be activly online to gain a reward in seconds.		set .rewardTime, 3600;		// NOCONFIG AREA //		set .updateInterval, .updateInterval * 1000;				query_sql( "SELECT `account_id` FROM `char` WHERE `online` = 1", .@accountIds );				for( set .@i, 0; .@i < getarraysize( .@accountIds ); set .@i, .@i + 1 ) {			if( attachrid( .@accountIds[ .@i ] ) )		            doevent strnpcinfo( 3 ) + "::OnReInit";		}	end;	OnReInit:	OnPCLoginEvent:		addtimer .updateInterval, strnpcinfo( 3 ) + "::OnCheck";	end;	OnCheck:		// If player sells or chats.		if( checkvending() || checkchatting() )     {			// Display message that the event stopped.			dispbottom "AriaRO hourly reward event stops as long as you are vending / chatting and your idle time won't be counted torwards your reward.";		} else {			set @seconds, .updateInterval / 1000;			// If the check cooldown ran out.			if( @seconds >= .rewardTime ) {					// Reset seconds.					set @seconds, 0;					// Hand out reward and display a message					getitem .rewardId, .rewardAmt;					dispbottom "You received AriaRO Hourly Ticket by staying ingame for 1 hour";	            }		}				// Reset the timer.		addtimer .updateInterval, strnpcinfo( 3 ) + "::OnCheck";	end;} 

This one resets everytime you go idle so that you have to be 1 hour active nonstop to gain a reward:

-	script	hourlypoints	-1,{	end;	OnInit:		// Config Area //		// Set reward id.		set .rewardId, 20107;			// Set amount of the reward.		set .rewardAmt, 10;				// Interval in which the script gets updated in seconds.		set .updateInterval, 1;				// Time you need to be activly online to gain a reward in seconds.		set .rewardTime, 3600;		// NOCONFIG AREA //		set .updateInterval, .updateInterval * 1000;				query_sql( "SELECT `account_id` FROM `char` WHERE `online` = 1", .@accountIds );				for( set .@i, 0; .@i < getarraysize( .@accountIds ); set .@i, .@i + 1 ) {			if( attachrid( .@accountIds[ .@i ] ) )		            doevent strnpcinfo( 3 ) + "::OnReInit";		}	end;	OnReInit:	OnPCLoginEvent:		addtimer .updateInterval, strnpcinfo( 3 ) + "::OnCheck";	end;	OnCheck:		// If player sells or chats.		if( checkvending() || checkchatting() )     {			// Display message that the event stopped.			dispbottom "AriaRO hourly reward event stops as long as you are vending / chatting and your idle time won't be counted torwards your reward.";			set @seconds, 0;		} else {			set @seconds, .updateInterval / 1000;			// If the check cooldown ran out.			if( @seconds >= .rewardTime ) {					// Reset seconds.					set @seconds, 0;					// Hand out reward and display a message					getitem .rewardId, .rewardAmt;					dispbottom "You received AriaRO Hourly Ticket by staying ingame for 1 hour";	            }		}				// Reset the timer.		addtimer .updateInterval, strnpcinfo( 3 ) + "::OnCheck";	end;} 
Edited by Winterfox

Share this post


Link to post
Share on other sites
  • 0

This won't work since once the user was idle the whole script will get halted also your timer won't be reset once the hour check failed for the first time and

if you fixed both you would still have the problem that you get the reward every hour without taking into account the delay induced by the afk time.

 

Also you will lose the connection to your timer on script reload, so you need to re-attach all online players after the reload.

 

the first script provided by @@eKoh thereis nothing to check if player idle or not right ? or maybe i was misunderstood the different of idle and opening chat room to chitchat with other or opening vending without auto trade (although in this state you can still chitchating too) if it was to check idle herc emulator have checkidle() commands, if player opening vending and chat room there will be notice dispbottom to tell them again they need to relog-in to be in effect of script,

 

yeah you right after the first check, timer will stop since i put it in the One Hour bracket condition, I should put it after the closing bracket (Fixed script above), this will fix the two problem

 

for the reloading script i didn't think until there and thanks for the input

Share this post


Link to post
Share on other sites
  • 0
I do not suggest you use this system, it consumes a lot of processing of your server, causing immense and annoying lags. This script will cause you more harm than good.
I say this because I had a server with an average of 80 players who broke after removing it from the server.

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.