Jump to content
  • 0
Sign in to follow this  
Helena

How to not attach a timer to a character (using +x hours)

Question

Hi hercules! :)

 

Could a kind scripter please be of help? I'm trying to attach a timer to the server and not to one character. I know how onclock and onminute work, but I am specifically looking for a script that will give a 2x drop bonus for the 24 hours after something was achieved.

 

I tried using sleep2 as well, but the unfortunate problem I run into is that as soon as the character logs off before (in this samples case) 10 seconds have passed, the bonus would just remain while I really want it to wear off whether the character is online or not.

 

Help is much appreciated! :)

 

 

[Etc...]announce "The server will now have the drop rates increased to 2x for the coming 24 hours!",bc_all;	setbattleflag("item_rate_common", 200 );	dispbottom "Setting to 2x";	sleep2 10000; // not the accurate time	atcommand "@reloadbattleconf";	end;
Edited by Helena

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi hercules! :)

 

Could a kind scripter please be of help? I'm trying to attach a timer to the server and not to one character. I know how onclock and onminute work, but I am specifically looking for a script that will give a 2x drop bonus for the 24 hours after something was achieved.

 

I tried using sleep2 as well, but the unfortunate problem I run into is that as soon as the character logs off before (in this samples case) 10 seconds have passed, the bonus would just remain while I really want it to wear off whether the character is online or not.

 

Help is much appreciated! :)

 

 

 

[Etc...]announce "The server will now have the drop rates increased to 2x for the coming 24 hours!",bc_all;	setbattleflag("item_rate_common", 200 );	dispbottom "Setting to 2x";	sleep2 10000; // not the accurate time	atcommand "@reloadbattleconf";	end;

 

 

try this
-	xxxxx	xxx,{	........................	........................	announce "The server will now have the drop rates increased to 2x for the coming 24 hours!",bc_all;    	setbattleflag("item_rate_common", 200 );    	dispbottom "Setting to 2x";	$ExpireTime = gettimetick(2)+86400;//--->24 hours = 60*60*24 = 86400 seconds	end;OnInit:	if($ExpireTime && gettimetick(2) < $ExpireTime) { 		setbattleflag("item_rate_common", 200 );		end;	}OnMinute1:  OnMinute2:  OnMinute3:  OnMinute4:  OnMinute5:  OnMinute6:  OnMinute7:  OnMinute8:  OnMinute9:  OnMinute10:OnMinute11: OnMinute12: OnMinute13: OnMinute14: OnMinute15: OnMinute16: OnMinute17: OnMinute18: OnMinute19: OnMinute20:OnMinute21: OnMinute22: OnMinute23: OnMinute24: OnMinute25: OnMinute26: OnMinute27: OnMinute28: OnMinute29: OnMinute30:OnMinute31: OnMinute32: OnMinute33: OnMinute34: OnMinute35: OnMinute36: OnMinute37: OnMinute38: OnMinute39: OnMinute40:OnMinute41: OnMinute42: OnMinute43: OnMinute44: OnMinute45: OnMinute46: OnMinute47: OnMinute48: OnMinute49: OnMinute50:OnMinute51: OnMinute52: OnMinute53: OnMinute54: OnMinute55: OnMinute56: OnMinute57: OnMinute58: OnMinute59: OnMinute0:	if($ExpireTime && gettimetick(2) >= $ExpireTime) { //--->Judging if the time is expired or not per minute		$ExpireTime = 0 ;		setbattleflag("item_rate_common", 100 );	}	end;}
Edited by Angelmelody

Share this post


Link to post
Share on other sites
  • 0

 

Hi hercules! :)

 

Could a kind scripter please be of help? I'm trying to attach a timer to the server and not to one character. I know how onclock and onminute work, but I am specifically looking for a script that will give a 2x drop bonus for the 24 hours after something was achieved.

 

I tried using sleep2 as well, but the unfortunate problem I run into is that as soon as the character logs off before (in this samples case) 10 seconds have passed, the bonus would just remain while I really want it to wear off whether the character is online or not.

 

Help is much appreciated! :)

 

 

[Etc...]announce "The server will now have the drop rates increased to 2x for the coming 24 hours!",bc_all;	setbattleflag("item_rate_common", 200 );	dispbottom "Setting to 2x";	sleep2 10000; // not the accurate time	atcommand "@reloadbattleconf";	end;

 

try this
-	xxxxx	xxx,{	........................	........................	announce "The server will now have the drop rates increased to 2x for the coming 24 hours!",bc_all;    	setbattleflag("item_rate_common", 200 );    	dispbottom "Setting to 2x";	$ExpireTime = gettimetick(2)+86400;//--->24 hours = 60*60*24 = 86400 seconds	end;OnInit:	if($ExpireTime && gettimetick(2) < $ExpireTime) { 		setbattleflag("item_rate_common", 200 );		end;	}OnMinute1:  OnMinute2:  OnMinute3:  OnMinute4:  OnMinute5:  OnMinute6:  OnMinute7:  OnMinute8:  OnMinute9:  OnMinute10:OnMinute11: OnMinute12: OnMinute13: OnMinute14: OnMinute15: OnMinute16: OnMinute17: OnMinute18: OnMinute19: OnMinute20:OnMinute21: OnMinute22: OnMinute23: OnMinute24: OnMinute25: OnMinute26: OnMinute27: OnMinute28: OnMinute29: OnMinute30:OnMinute31: OnMinute32: OnMinute33: OnMinute34: OnMinute35: OnMinute36: OnMinute37: OnMinute38: OnMinute39: OnMinute40:OnMinute41: OnMinute42: OnMinute43: OnMinute44: OnMinute45: OnMinute46: OnMinute47: OnMinute48: OnMinute49: OnMinute50:OnMinute51: OnMinute52: OnMinute53: OnMinute54: OnMinute55: OnMinute56: OnMinute57: OnMinute58: OnMinute59: OnMinute0:	if($ExpireTime && gettimetick(2) >= $ExpireTime) { //--->Judging if the time is expired or not per minute		$ExpireTime = 0 ;		setbattleflag("item_rate_common", 100 );	}	end;}

 

Thank you! I wonder why you're not a script mod yet, you're so helpful. :)

 

Can I ask something else? (its a part of the same script)

 

this part works good, it copies and pastes data from one SQL table in another, and the script then reads the new/custom table. But sadly when I truncate the custom 'votegoal' table, it keeps fetching data from the other (cp) table. Basically, I just want it to insert each entry once while not touching/truncating the other cp table (otherwise all players will get their vote points and blocking time nullified). :(

 

Is that too complex or even possible to do? (sorry if the below is a mess, I'm not good with sql xD) Thanks so much!

 

 

OnPCLoginEvent:	if(getgroupid() > 90){query_sql("INSERT IGNORE INTO `votegoal` SELECT * FROM `cp_v4p_votelogs`");set .@nb, query_sql("SELECT `rtid`, `account_id` FROM `votegoal`", .@VoteGoal, .@account_id );	announce "Vote Goal: "+ .@nb * 2 +" / 1000",bc_self; // *2 cause votes give 2 points. if(.@nb && .@VoteGoal == 1){ // Like above, server only fetches 1 points while site gives 2 point per vote, so if we want goal of 250, put > 499//	query_sql("TRUNCATE TABLE `votegoal`");
Edited by Helena

Share this post


Link to post
Share on other sites
  • 0

@1 -  By default initnpctimer does not have a player attached so you can just use that if you choose to.

 

@2 -

TRUNCATE TABLE `table_name`

is used when you want to delete all the data from the given table, without deleting the table from the schema.

You shouldn't have any issues of table mix ups, since you can't have the same table name in the same schema.

 

So, if `votegoal` isn't the table you want to TRUNCATE, then perhaps a different table is what you need to do?

 

Additionally, if you're having issues, where `votegoal` is the name of a table inside 2 different schemas, and this is the problem, you should be able to specify which schema to truncate from:

query_sql("TRUNCATE database.schema `table_name`");

Share this post


Link to post
Share on other sites
  • 0

 

@1 -  By default initnpctimer does not have a player attached so you can just use that if you choose to.

 

@2 -

TRUNCATE TABLE `table_name`

is used when you want to delete all the data from the given table, without deleting the table from the schema.

You shouldn't have any issues of table mix ups, since you can't have the same table name in the same schema.

 

So, if `votegoal` isn't the table you want to TRUNCATE, then perhaps a different table is what you need to do?

 

Additionally, if you're having issues, where `votegoal` is the name of a table inside 2 different schemas, and this is the problem, you should be able to specify which schema to truncate from:

query_sql("TRUNCATE database.schema `table_name`");

 

Thank you! :)

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...
Sign in to follow this  

×
×
  • Create New...

Important Information

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