Jump to content
  • 0

Lucky Player Event


Bringer

Question


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.04
  • Content Count:  740
  • Reputation:   47
  • Joined:  03/12/14
  • Last Seen:  

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 

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  249
  • Reputation:   72
  • Joined:  10/20/12
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

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 :))

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.04
  • Content Count:  740
  • Reputation:   47
  • Joined:  03/12/14
  • Last Seen:  

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 ?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  61
  • Topics Per Day:  0.02
  • Content Count:  911
  • Reputation:   166
  • Joined:  11/27/14
  • Last Seen:  

You should add the idle player also ^_^ in your conditional statement 

Edited by Poring King
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...