Jump to content
  • 0

Give 1 ygg box to all the online players(except vendor) every 15 mins


Question

Posted (edited)

guys, the script below is a lucky pick for every 15 mins for only one person,

but how can i edit it into all the online players?

thanks master scripters!!!

- script AutoFunEvent -1,{


OnMinute15:
OnMinute30:
OnMinute45:
OnMinute00:
while(1)
{
 query_sql "select account_id from `char` where online = 1 order by rand() limit 1", .@aid;
 attachrid .@aid;
 if(CheckVending())
 {
  DetachRID();
  continue;
 }
 announce strcharinfo(0) +" has won the Rychi Lucky Pick Event!!!", 0;
 getitem 607,1
 break;
}
end;
}


dear master scripters,

how can i have an auto reward to all the players online every 5 minutes except for the vendors?

Edited by Mysterious
Topic Merged - Please use [CODEBOX] for content longer than 10 lines.

13 answers to this question

Recommended Posts

Posted
-	script	itemall	-1,{
OnMinute00:
OnMinute15:
OnMinute30:
OnMinute45:
freeloop 1;
while ( getusers(1) > .@count ) {
	.@nb = query_sql("select account_id from `char` where online = 1 limit 128 offset "+ .@count, .@aid );
	.@i = 0;
	while ( .@i < .@nb ) {
		if ( attachrid(.@aid[.@i]) )
			if ( !checkvending() && !checkchatting() )
				getitem "Yggdrasilberry_Box", 1;
		.@i++;
	}
	.@count += 128;
}
freeloop 0;
end;
}

Posted

@Annie - There really isn't a need for attachrid in this case, since your already doing a sql_query. You can simply pull the player's name as well.

- script itemall -1,{
OnMinute00:
OnMinute15:
OnMinute30:
OnMinute45:
freeloop 1;
while ( getusers(1) > .@count ) {
 .@nb = query_sql("select account_id, name from `char` where online = 1 limit 128 offset "+ .@count, .@aid,.@name$ );
 .@i = 0;
 while ( .@i < .@nb ) {
 if ( !checkvending( .@name$[.@i] ) && !checkchatting( .@name$[.@i] )
 getitem "Yggdrasilberry_Box", 1,.@aid[.@i];
  .@i++;
 }
 .@count += 128;
}
freeloop 0;
end;
}

This is only since you are already running the script for online players. However, I do see why you used attachrid. It's because someone may log out....The more I think about it, your way is more efficient lol.

Posted (edited)

its been sometime someone able to criticize my scripts ... hehehe ...

however I think your method is more efficient

-	script	itemall	-1,{
OnInit:
for ( .@i = 2000004; .@i >= 2000000; .@i-- ) {
	query_sql "select name from `char` where account_id = "+ .@i +" limit 1", .@name$;
	announce checkvending( .@name$ ) +" "+ readparam(bVit, .@name$), 0; // success to loop through even offline
	getitem 501, 1, .@i; // also success to loop through even offline
}
}

certain kinds of script commands that can optionally specify a player name field

these kinds of script commands can continue to loop through even if the player is offline if specified a player name/account_id field

EDIT:

on 2nd thought ... now I think mine more efficient ...

because its from the source

	if(script_hasdata(st,2))
	sd = map_nick2sd(script_getstr(st,2));
else
	sd = script_rid2sd(st);

I used attachrid already, so it just called out script_rid2sd

but your map_nick2sd has to search through every online player with a specified name...

I mean, my script just attachrid once and script_rid2sd 3 times ( checkchatting() checkvending() getitem )

but your script parse map_nick2sd 3 times in the source ...

Edited by AnnieRuru
Posted

I see... I just assumed that if the player logged off in the 1 second it'd take the script to run, you'd get an error for him onto being online. But if specifying a name for certain commands stops this error, then I guess your right lol.

Posted

thanks for the quick response master scrpters, how can i edit this into vending only, ?

if ( !checkvending( .@name$[.@i] ) && !checkchatting( .@name$[.@i] )

how can i delete the checkchatting?

Posted (edited)

By... Deleting it along with the & &.... You seriously should look into script_commands.txt, especially if you are a server owner.

Edit: @Annie - I guess your right lol. While mine may look more efficient at first glance... it sure a heck isnt lol.

Edited by GmOcean
Posted

hmmmmm,, so this will be our final script master scripters?

- script itemall -1,{

OnMinute00:

OnMinute15:

OnMinute30:

OnMinute45:

freeloop 1;

while ( getusers(1) > .@count ) {

.@nb = query_sql("select account_id, name from `char` where online = 1 limit 128 offset "+ .@count, .@aid,.@name$ );

.@i = 0;

while ( .@i < .@nb ) {

if ( !checkvending( .@name$[.@i] ) && !checkchatting( .@name$[.@i] )

getitem "Yggdrasilberry_Box", 1,.@aid[.@i];

.@i++;

}

.@count += 128;

}

freeloop 0;

end;

}

Posted (edited)

@buda, though script request section is a place ask for a script, but we usually don't make this kind of simple edit

I strongly suggest you should hire a scripter by posting in this area, so you can assign someone to help organize your server

here you go ... simple edit

-	script	itemall	-1,{
OnMinute00:
OnMinute15:
OnMinute30:
OnMinute45:
freeloop 1;
while ( getusers(1) > .@count ) {
	.@nb = query_sql("select account_id from `char` where online = 1 limit 128 offset "+ .@count, .@aid );
	.@i = 0;
	while ( .@i < .@nb ) {
		if ( attachrid(.@aid[.@i]) )
			if ( !checkvending() )
				getitem "Yggdrasilberry_Box", 1;
		.@i++;
	}
	.@count += 128;
}
freeloop 0;
end;
}

EDIT: for below...

suddenly feel lazy to do this request ... x.x

Edited by AnnieRuru
Posted (edited)

Thanks Master Anie and Master Ocean... Please come at my house on December 25! i will treat you both! hahaahahah

thanks for your efforts, i hope we can fix the final script, cuz it is not working

I have a thought, can we convert the hourly points to ygg berry every 15 minutes?

Includes: online players and AFK player

Excludes: Vending players

//===== Hourly Points Script =========================================
//===== By: ==========================================================
//= nostafu
//===== Current Version: =============================================
//= 1.3
//===== Compatible With: =============================================
//= Any eAthena Version
//===== Description: =================================================
//= Get Points every successful hours of gameplay, you cannot get
//= the points even if you miss a second or a minute. A player will
//= get a very big bonus if they played 12 hours consecutively
//= or without logging out of the game. If the player is vending
//= the script will then stop.
//====================================================================
- script Hourly Points -1,{

//--Start of the Script
OnPCLoginEvent:
attachnpctimer ""+strcharinfo(0)+"";
initnpctimer;
end;

OnTimer30000:
//Check if Vending (normal or @at)
if(checkvending() >= 1 || checkchatting() == 1) {
dispbottom "Your Hourly Points have stopped because you were vending / chatting. Please relog if you wish to start again.";
stopnpctimer;
end;
}
//Check if Idle
getmapxy( .@map$, .@x, .@y, 0 );
if(@map$ == .@map$ && @x == .@x && @y == .@y) {
set @afk, @afk + 1;
}
//If move timer resets
else {
set @afk, 0;
}
set @map$, .@map$; set @x, .@x; set @y, .@y;
//Idle Check for 30 Minutes
if(@afk == 30) {
dispbottom "Your Hourly Points have stopped because you were idle for 30 minutes. Please relog if you wish to start again.";
stopnpctimer;
end;
}
end;

OnTimer60000:
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)
set #KAFRAPOINTS, #KAFRAPOINTS + .@point_amt;
dispbottom "You received "+.@point_amt+" Hourly Points by staying in Rychi Infinity Ragnarok Online Server for 1 hour.";
dispbottom "Current Balance = "+#KAFRAPOINTS+" Hourly Points";
set @consecutive_hour, @consecutive_hour + 1;
}
//Check for 12 hours consecutive
if(@consecutive_hour == 12) {
set @consecutive_hour,0;
set .@cpoint_amt, 50; //Points to get for 12 Consecutive hours (default: 50)
set #KAFRAPOINTS, #KAFRAPOINTS + .@cpoint_amt;
dispbottom "You received "+.@cpoint_amt+" Hourly Points in playing for 12 consecutive hours.";
dispbottom "Current Balance = "+#KAFRAPOINTS+" Hourly Points";
}
stopnpctimer;
initnpctimer;
end;

}
//--End of the Script

Edited by AnnieRuru
use [codebox] if the script > 10 lines

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...