Jump to content
  • 0

Question

Posted
Spoiler

-	script	AutoPickEvent	-1,{
 
OnMinute00: 
	while(1)
	{
	query_sql "select account_id from `char` where online = 1 order by rand() limit 1", .@aid;
	attachrid .@aid;
	if ( getgmlevel() < 100 && !checkvending() ) {
	DetachRID();
	continue;
  	}
	announce strcharinfo(0) +" won 1 Hourly Coin in Lucky Pick Event.",0,0x00FF00;
	getitem 31060,1;
	break;
	}
	end;
}

 

Error on my Map Server 

 

5 answers to this question

Recommended Posts

  • 0
Posted (edited)

Try to avoid using freeloop. The infinity loop is caused by a wrong condition:

if ( getgmlevel() < 100 && !checkvending() ) {
	DetachRID();
	continue;
}

This will detach every non GM (needs at least level 100) and non vending player. Better would be:

if ( getgmlevel() > 0 || // ignores GMs
	 checkvending()   || // ignores Vender
     checkweight(32000,1) == 0 || // Checkweight failed
	 checkidle() > 60 ) { // ignores AFK-Player (should also include venders)

I just had a look in an own script. It's pretty much the same, but differs from the time (not every hour at minute zero). And it just waits ten seconds, if it fails.



OnMinute00:
//Damit das ein wenig interessanter wird, wird der Coin nicht genau zur vollen
//Stunde ausgeteilt, sondern irgendwann innerhalb dieser Stunde.
	stopnpctimer;
	initnpctimer;
	setnpctimer(rand(0,3540000));
	end;
OnTimer3545000:
	stopnpctimer;
	query_sql "SELECT `account_id` FROM `char` WHERE `online` = '1' ORDER BY RAND() LIMIT 0,1",.@accid;
	if( getarraysize(.@accid) != 1 ) end;
	attachrid .@accid[0]; //Player attached
	if( checkweight(32000,1) == 0 || checkidle() > 60 || getgmlevel() > 0 )
	{
		setnpctimer(3535000); //Evtl. Wird in 10 Sekunden jemand gefunden, der nicht afk ist.
		startnpctimer;
		end;
	}
	getitem 32000,1;
	switch(rand(17)) {
		case 0: announce "["+strcharinfo(0)+"] ist ein richtiger Glückspilz und findet einen Coin hinter "+((Sex)?"seinem":"ihrem")+" Sofa.",b_all; break;
// [...]

(Sorry in German, but you'll get the point)

Edited by Jey
  • Upvote 2
  • 0
Posted

Try Using Freeloop something like this

-	script	AutoPickEvent	-1,{
 
OnMinute00: 
	freeloop(1);
	{
	query_sql "select account_id from `char` where online = 1 order by rand() limit 1", .@aid;
	attachrid .@aid;
	if ( getgmlevel() < 100 && !checkvending() ) {
	DetachRID();
	continue;
  	}
	announce strcharinfo(0) +" won 1 Hourly Coin in Lucky Pick Event.",0,0x00FF00;
	getitem 31060,1;
	break;
	}
	freeloop(0);
	end;
}

 

  • Upvote 1
  • 0
Posted
23 minutes ago, Jey said:

Try to avoid using freeloop. The infinity loop is caused by a wrong condition:


if ( getgmlevel() < 100 && !checkvending() ) {
	DetachRID();
	continue;
}

This will detach every non GM (needs at least level 100) and non vending player. Better would be:


if ( getgmlevel() > 0 || // ignores GMs
	 checkvending()   || // ignores Vender
     checkweight(32000,1) == 0 || // Checkweight failed
	 checkidle() > 60 ) { // ignores AFK-Player (should also include venders)

I just had a look in an own script. It's pretty much the same, but differs from the time (not every hour at minute zero). And it just waits ten seconds, if it fails.




OnMinute00:
//Damit das ein wenig interessanter wird, wird der Coin nicht genau zur vollen
//Stunde ausgeteilt, sondern irgendwann innerhalb dieser Stunde.
	stopnpctimer;
	initnpctimer;
	setnpctimer(rand(0,3540000));
	end;
OnTimer3545000:
	stopnpctimer;
	query_sql "SELECT `account_id` FROM `char` WHERE `online` = '1' ORDER BY RAND() LIMIT 0,1",.@accid;
	if( getarraysize(.@accid) != 1 ) end;
	attachrid .@accid[0]; //Player attached
	if( checkweight(32000,1) == 0 || checkidle() > 60 || getgmlevel() > 0 )
	{
		setnpctimer(3535000); //Evtl. Wird in 10 Sekunden jemand gefunden, der nicht afk ist.
		startnpctimer;
		end;
	}
	getitem 32000,1;
	switch(rand(17)) {
		case 0: announce "["+strcharinfo(0)+"] ist ein richtiger Glückspilz und findet einen Coin hinter "+((Sex)?"seinem":"ihrem")+" Sofa.",b_all; break;
// [...]

(Sorry in German, but you'll get the point)

i see thanks for the info :))

  • 0
Posted
10 hours ago, Jey said:

Try to avoid using freeloop. The infinity loop is caused by a wrong condition:


if ( getgmlevel() < 100 && !checkvending() ) {
	DetachRID();
	continue;
}

This will detach every non GM (needs at least level 100) and non vending player. Better would be:


if ( getgmlevel() > 0 || // ignores GMs
	 checkvending()   || // ignores Vender
     checkweight(32000,1) == 0 || // Checkweight failed
	 checkidle() > 60 ) { // ignores AFK-Player (should also include venders)

I just had a look in an own script. It's pretty much the same, but differs from the time (not every hour at minute zero). And it just waits ten seconds, if it fails.




OnMinute00:
//Damit das ein wenig interessanter wird, wird der Coin nicht genau zur vollen
//Stunde ausgeteilt, sondern irgendwann innerhalb dieser Stunde.
	stopnpctimer;
	initnpctimer;
	setnpctimer(rand(0,3540000));
	end;
OnTimer3545000:
	stopnpctimer;
	query_sql "SELECT `account_id` FROM `char` WHERE `online` = '1' ORDER BY RAND() LIMIT 0,1",.@accid;
	if( getarraysize(.@accid) != 1 ) end;
	attachrid .@accid[0]; //Player attached
	if( checkweight(32000,1) == 0 || checkidle() > 60 || getgmlevel() > 0 )
	{
		setnpctimer(3535000); //Evtl. Wird in 10 Sekunden jemand gefunden, der nicht afk ist.
		startnpctimer;
		end;
	}
	getitem 32000,1;
	switch(rand(17)) {
		case 0: announce "["+strcharinfo(0)+"] ist ein richtiger Glückspilz und findet einen Coin hinter "+((Sex)?"seinem":"ihrem")+" Sofa.",b_all; break;
// [...]

(Sorry in German, but you'll get the point)

Spoiler

-	script	AutoPickEvent	-1,{
 
OnMinute00: 
	while(1)
	{
	query_sql "select account_id from `char` where online = 1 order by rand() limit 1", .@aid;
	attachrid .@aid;
if ( getgmlevel() > 0 || // ignores GMs
	 checkvending() ) {   || // ignores Vender
	DetachRID();
	continue;
  	}
	announce strcharinfo(0) +" won 1 Hourly Coin in Lucky Pick Event.",0,0x00FF00;
	getitem 31060,1;
	//set #HourlyPoints,#HourlyPoints+100;
	//dispbottom "You got 100 Hourly Points";
	break;
	}
	end;
}

 

should be like this ?

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