Jump to content
  • 0

help VIP Script


Limestone

Question


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  647
  • Reputation:   16
  • Joined:  11/21/11
  • Last Seen:  

guys! can you help me fix my script? urgent. need help :(

here's my script

http://pastebin.com/raw.php?i=egyMJJpS

@problem:

how can i add a npc that checks all registered premium users. and what day/hour/minute/seconds their premium will be expired.

only gm 99 can check all registered premium users.

thank you so much!

Link to comment
Share on other sites

8 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  60
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   219
  • Joined:  11/22/11
  • Last Seen:  

#PremiumUser

all kind of this variable will be recorded in to table `global_reg_value`,

you just need to use query_sql to pick up them where `str` is '#PremiumUser' and `value` bigger than zero .

Edited by goddameit
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  647
  • Reputation:   16
  • Joined:  11/21/11
  • Last Seen:  

can you give me a sample (too noob in scripting) :3

Edited by AnnieRuru
move to script request
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

query_sql "UPDATE login SET `group_id`=0 WHERE account_id="+getcharid(3);

I don't think this is the correct way to change a gm group

unless ask the player to relog after using the item

like atcommand "@kick "+ strcharinfo(0) or something to refresh the group db

perhaps use @adjgroup

-	script	lasdlkasdla	-1,{
OnInit:
   .page = 2;
   bindatcmd "list_premium", strnpcinfo(0)+"::Onaaa", 99, 100;
   end;
Onaaa:
   query_sql "select count(1) from global_reg_value where str = '#PremiumUser'", .@total;
   while (1) {
       .@nb = query_sql( "select account_id as a, ( select name from `char` where account_id = a limit 1 ), value from global_reg_value where str = '#PremiumUser' limit "+ .page +" offset "+ .@currentpage * .page, .@aid, .@name$, .@value );
       mes "current page no."+( .@currentpage +1 )+". total "+ ( .@total / .page +1 ) +" pages";
       for ( .@i = 0; .@i < .@nb; .@i++ )
           mes ( .@currentpage * .page + .@i +1 ) +". "+ .@name$[.@i] +" ["+ .@aid[.@i] +"] -> "+ .@value[.@i];
       next;
       if ( select( "next", "previous" ) == 1 ) {
           if ( .page * ( .@currentpage +1 ) < .@total )
               .@currentpage++;
           else {
               mes "end of page";
               close;
           }
       }
       else {
           if ( .@currentpage )
               .@currentpage--;
           else {
               mes "start of the page";
               close;
           }
       }
   }
   close; // doesn't reach    
}

just make for fun ...

EDIT: lol ... post up the wrong script

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  647
  • Reputation:   16
  • Joined:  11/21/11
  • Last Seen:  

Thank you Annie. Working Great, but im confused with this? can you explain what is this?

2z8n38j.jpg

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:  

It's the time in seconds of #PremiumUser variable.

Use callfunc("Time2Str",<your value>); to display in days/hour/min/secs

Edited by Capuche
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

//	~~~~~ show time left in days, hours, minutes and seconds ~~~~~
function	script	timeleft__	{
if ( ( .@left = getarg(0) ) <= 0 ) return getarg(0);
.@day = .@left / 86400;
.@hour = .@left % 86400 / 3600;
.@min = .@left % 3600 / 60;
.@sec = .@left % 60;
if ( .@day )
	return .@day +" day "+ .@hour +" hour";
else if ( .@hour )
	return .@hour +" hour "+ .@min +" min";
else if ( .@min )
	return .@min +" min "+ .@sec +" sec";
else
	return .@sec +" sec";
}

-	script	lasdlkasdla	-1,{
OnInit:
.page = 2;
bindatcmd "list_premium", strnpcinfo(0)+"::Onaaa", 99, 100;
end;
Onaaa:
query_sql "select count(1) from global_reg_value where str = '#PremiumUser'", .@total;
while (1) {
	.@nb = query_sql( "select account_id as a, ( select name from `char` where account_id = a limit 1 ), value from global_reg_value where str = '#PremiumUser' limit "+ .page +" offset "+ .@currentpage * .page, .@aid, .@name$, .@value );
	mes "current page no."+( .@currentpage +1 )+". total "+ ( .@total / .page +1 ) +" pages";
	for ( .@i = 0; .@i < .@nb; .@i++ )
		mes ( .@currentpage * .page + .@i +1 ) +". "+ .@name$[.@i] +" ["+ .@aid[.@i] +"] -> "+ callfunc( "timeleft__", .@value[.@i] - gettimetick(2) ) ;
	next;
	if ( select( "next", "previous" ) == 1 ) {
		if ( .page * ( .@currentpage +1 ) < .@total )
			.@currentpage++;
		else {
			mes "end of page";
			close;
		}
	}
	else {
		if ( .@currentpage )
			.@currentpage--;
		else {
			mes "start of the page";
			close;
		}
	}
}
close; // doesn't reach	
}

to be honest ... that Time2Str is made after my timeleft__ function ...

my timeleft__ function made together with itemlist function made 4 years ago

but Time2Str function only added 2 years ago

and its display method doesn't suit my taste ( I think it display according to official ? )

if the .@Time_Left is at 86402

my timeleft__ function display "1 day 0 hour"

Time2Str display "1 day, 2 seconds", without telling anything about hour or minute

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  647
  • Reputation:   16
  • Joined:  11/21/11
  • Last Seen:  

thank you annie :3

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