Jump to content
  • 0

Modify my script :)


leertaste

Question


  • Group:  Members
  • Topic Count:  41
  • Topics Per Day:  0.01
  • Content Count:  137
  • Reputation:   1
  • Joined:  02/02/13
  • Last Seen:  

I've got this script:

prontera,149,129,5	script	TotalTimeOnline	857,{
	mes "For your account, you have been online a total of:";
	mes callsub(S_SecToTime, @login_time ? (#secs_online + (gettimetick(2)-@login_time)) : #secs_online);
	close;

S_SecToTime:
	set .@seconds, getarg(0);
	
	set .@seconds, .@seconds - set(.@weeks, .@seconds / 604800)*604800;
	set .@str$, .@str$ + .@weeks+((.@weeks==1) ? " week":" weeks")+", ";
	
	set .@seconds, .@seconds - set(.@days, .@seconds / 86400)*86400;
	set .@str$, .@str$ +  .@days+((.@days==1) ? " day":" days")+", ";
	
	set .@seconds, .@seconds - set(.@hours, .@seconds / 3600)*3600;
	set .@str$, .@str$ +  .@hours+((.@hours==1) ? " hour":" hours")+", ";
	
	set .@seconds, .@seconds - set(.@mins, .@seconds / 60)*60;
	set .@str$, .@str$ +  .@mins+((.@mins==1) ? " min":" mins")+", and ";
	
	set .@str$, .@str$ +  .@seconds+((.@seconds==1) ? " second":" seconds");
	
	return .@str$;

OnPCLoginEvent:
	set @login_time, gettimetick(2);
	end;
OnPCLogoutEvent:
	if (@login_time)
		set #secs_online, #secs_online + (gettimetick(2)-@login_time);
	end;
}

What I want:

- Edit that you can watch your character based online time and account based online time
- Edit a ranking list of top 5 online CHARACTERS, everybody of them will get another reward (via mail) (each sunday)
(for example 1. will get 501 2. will get 502, and so on)

- gm level 5 and above will not listed in ranking
- gm menu to reset the ranking

thaaaaaanks <3

Edited by leertaste
Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

function	script	timeleft__	{
function s;
	if ( ( .@left = getarg(0) ) <= 0 ) return getarg(0);
	.@week = .@left / 86400 * 7;
	.@day = .@left / 86400;
	.@hour = .@left % 86400 / 3600;
	.@min = .@left % 3600 / 60;
	.@sec = .@left % 60;
	if( .@week )
		return .@week +" week"+ s( .@week ) + .@day +" day"+ s( .@day ) + .@hour +" hour"+ s( .@hour );
	else if ( .@day )
		return .@day +" day"+ s( .@day ) + .@hour +" hour"+ s( .@hour );
	else if ( .@hour )
		return .@hour +" hour"+ s(.@hour) + .@min +" min" +s( .@min );
	else if ( .@min )
		return .@min +" min"+ s( .@min ) + .@sec +" sec"+ s( .@sec );
	else
		return .@sec +" sec"+ s( .@sec );

function s { return ( getarg(0) > 1 ? "s " : " " ); }
}

prontera,149,129,5	script	TotalTimeOnline	857,{
	query_sql "SELECT value FROM time_online WHERE char_id = "+ getcharid(0) +" LIMIT 1", .@time_char;
	query_sql "SELECT value FROM time_online WHERE account_id = "+ getcharid(3) +" LIMIT 1", .@time_account;

	mes "^FF6600Time device^000000";
	mes "My Game's Time.";
	mes "- Account online since: ^777777"+ callfunc( "timeleft__", .@time_account + gettimetick(2) - @login_time ) +"^000000.";
	mes "-----------------------------------";
	mes "- Character online since: ^777777"+ callfunc( "timeleft__", .@time_char + gettimetick(2) - @login_time ) +"^000000.";
	next;
	if ( select( "^777777~ Top 5 accounts online.", ( getgmlevel() > 10 ? "~ Reset Ranking" : "" ), "~ Cancel^000000" ) == 3 ) close;
	else if( @menu == 2 ) {
		if( select( "^777777~ Reset The character ranking.", "~ Reset The account time", "~ Cancel^000000" ) == 3 ) close;
		else if( @menu == 2 ) {
			.@choice_reset$ = "account time";
			.@var_name$ = "account_id";
		}
		else {
			.@choice_reset$ = "character ranking";
			.@var_name$ = "char_id";
		}
		mes "^FF6600Time device^000000";
		mes "Are you sure to reset the "+ .@choice_reset$ +" ?";
		next;
		if( select( "^777777~ No", "~ Yes^000000" ) == 1 ) close;
		mes "^FF6600Time device^000000";
		mes .@choice_reset$ +" reset.";
		query_sql "DELETE FROM `time_online` WHERE `time_online`."+ escape_sql( .@var_name$ ) +" > 0";
		close;
	}
	.@size = query_sql( "SELECT `char`.`name`, `value` FROM `time_online` LEFT JOIN `char` ON `time_online`.`char_id` = `char`.`char_id` WHERE time_online.`char_id` > 0 ORDER BY `value` DESC LIMIT 5", .@name$, .@value );
	if( .@size ) {
		.@origin = getcharid(3);
		mes "^FF6600Time device^000000";
		for( .@i = 0; .@i < .@size; .@i++ ) {
			if( attachrid( getcharid( 3,.@name$[.@i] ) ) ) {
				.@value[.@i] = .@value[.@i] + gettimetick(2) - @login_time;
				attachrid( .@origin );
			}
			mes "^777777"+ ( .@i +1 ) +"/^000000 "+ .@name$[.@i] +": ^FF0000"+ callfunc( "timeleft__", .@value[.@i] ) +"^000000";
		}
	}
	close;

OnPCLoginEvent:
	if( getgmlevel() >= 5) end;
	set @login_time, gettimetick(2);
	end;
OnPCLogoutEvent:
	if ( @login_time && getgmlevel() < 5 ) {// @login_time must be empty for gm but just in case
		query_sql "INSERT INTO `time_online` VALUES ( "+ getcharid(0) +", 1, 0 ) ON DUPLICATE KEY UPDATE value = value + "+ ( gettimetick(2) - @login_time );
		query_sql "INSERT INTO `time_online` VALUES ( 0, 1, "+ getcharid(3) +" ) ON DUPLICATE KEY UPDATE value = value + "+ ( gettimetick(2) - @login_time );
	}
	end;
OnSun0000:
	.@size = query_sql( "SELECT `char`.`char_id`, `char`.`account_id` FROM `char` LEFT JOIN `time_online` ON `time_online`.`char_id` = `char`.`char_id` WHERE time_online.`char_id` > 0 ORDER BY `value` DESC LIMIT "+ getarraysize( .reward_ID ), .@char_id, .@account_id );
	for( .@i = 0; .@i < .@size; .@i++ ) {
		query_sql("INSERT INTO `mail` (send_name,dest_id,title,message,nameid,amount,identify,zeny,time) "+
					"VALUES ('no-reply',"+ .@char_id[.@i] +",'Reward Online',"+
				  "'"+ escape_sql( .message$ ) +"',"+ .reward_ID[.@i] +","+ .reward_amount[.@i] +",0,"+ .reward_zeny[.@i] +",UNIX_TIMESTAMP(NOW()))");
		if ( isloggedin( .@account_id[.@i], .@char_id[.@i] ) )
			message rid2name( .@account_id[.@i] ),"You've got mail! Please re-login to update your mailing list.";
	}
	end;
OnInit:
	.message$ = "Here your reward for being in the top 5 of the character online this week !";
	setarray .reward_ID, 501, 502, 503;
	setarray .reward_amount, 1, 1, 1;
	setarray .reward_zeny, 0, 0, 0;
	end;
}

 

 

SQL part

CREATE TABLE IF NOT EXISTS `time_online` (
  `char_id` int(11) unsigned NOT NULL DEFAULT '0',
  `value` varchar(1000) NOT NULL DEFAULT '0',
  `account_id` int(11) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`char_id`,`account_id`),
  KEY `account_id` (`account_id`),
  KEY `char_id` (`char_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

Set your option here:

OnInit:
	.message$ = "Here your reward for being in the top 5 of the character online this week !";
	setarray .reward_ID, 501, 502, 503;
	setarray .reward_amount, 1, 1, 1;
	setarray .reward_zeny, 0, 0, 0;
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  96
  • Topics Per Day:  0.02
  • Content Count:  554
  • Reputation:   14
  • Joined:  09/24/12
  • Last Seen:  

Sir... im using this script but it seem like 
all player and GM are online with same weeks,day,hour...
Why is that happen?
110968 week 15814 days 7 hour.. All the same... player either staff also look like this... 
Why?

Reset timing also did not work...

Edited by CheckMate
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

GM are online with same weeks,day,hour...

GM level above 5 are not in the ranking that's why the npc display this weird value.

 

If you want a time value for the gm + not a time ranking for gm comment under OnPCLoginEvent

// if( getgmlevel() >= 5) end;
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  34
  • Reputation:   1
  • Joined:  07/04/13
  • Last Seen:  

NOT WORKING PLESE UPDATE YOUR SCRIPT SIR ^_^

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