Jump to content
  • 0

Draw an online player.


Tassadar

Question


  • Group:  Members
  • Topic Count:  52
  • Topics Per Day:  0.02
  • Content Count:  107
  • Reputation:   5
  • Joined:  07/21/16
  • Last Seen:  

Good afternoon. I looked for something like this in the forum but did not find it.
I need a npc that every two hours take the list of the characters online and
make a draw between them and give an item to a winner. It's also important to
make an announcement for everyone on the server: Jonny won the lucky draw.

Thank you for your help.


Portuguese version:
 

Spoiler

Boa tarde. Eu procurei algo assim no fórum mas não encontrei.
preciso de um npc que a cada duas horas pegue a lista dos personagens online e faça um sorteio entre eles e dê um item para um vencedor. É importante também fazer um anúncio para todos no servidor: Jonny ganhou o sorteio da sorte.

Obrigado pela ajuda.

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

-	script	Lucky_Draw	-1,{

OnMinute00:

	.@prize_id = 512;
	.@prize_amt = 5;
	if(gettime(DT_HOUR) % 2 == 0) {
		.@size = getunits(BL_PC,.@players);
		.@winner = .@players[rand(.@size)];
		attachrid .@winner;
		announce strcharinfo(0)+" has won the Lucky Draw ("+F_InsertPlural(.@prize_amt,getitemname(.@prize_id))+").",bc_all;
		if(checkweight(.@prize_id,.@prize_amt))
			getitem .@prize_id,.@prize_amt;
		else
			mail getcharid(0),"Lucky Draw","Prize","Heres the Lucky Draw Prize",0,.@prize_id,.@prize_amt;
	}
	end;

}

 

  • Like 1
Link to comment
Share on other sites

  • 0

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

no reward to the GMs, and no reward to auto-traders, AND if possible no reward to idle players *checkidle()

// F_ShuffleNumbers( <start num>, <last num>, <output array>{, <count>} );
function	script	F_ShuffleNumbers	{
	deletearray getarg(2);
	.@static = getarg(0);
	.@range = getarg(1) +1 - .@static;
	.@count = getarg(3, .@range);
	if (.@range <= 0 || .@count <= 0)
		return 0;
	if (.@count > .@range)
		.@count = .@range;
	for (.@i = 0; .@i < .@range; ++.@i)
		.@temparray[.@i] = .@i;
	for (.@i = 0; .@i < .@count; ++.@i) {
		.@rand = rand(.@range);
		set getelementofarray( getarg(2), .@i ), .@temparray[.@rand] + .@static;
		.@temparray[.@rand] = .@temparray[--.@range];
	}
	return .@count;
}

-	script	sjdfkhsf	FAKE_NPC,{
OnInit:
	.itemid = 501;
	.amount = 10;
//	bindatcmd "test", strnpcinfo(0)+"::OnDebug", 99, 100;
	end;
OnMinute00:
	if ( gettime(DT_HOUR) % 2 ) end;
//OnDebug:
	.@size = getunits( BL_PC, .@aid );
	F_ShuffleNumbers( 0, .@size -1, .@r );
	for ( .@i = 0; .@i < .@size; ++.@i ) {
		attachrid .@aid[.@r[.@i]];
		if ( getgmlevel() < 60 && ( checkvending() & (2|4) ) == 0 ) {
//		if ( getgmlevel() < 60 && ( checkvending() & (2|4) ) == 0 && checkidle() < 60 ) {
			announce strcharinfo(0) +" won the Lucky Draw !!",bc_all;
			mail getcharid(0), "Lucky Draw", "Prize", "Here is the Lucky Draw Prize", 0, .itemid, .amount;
			break;
		}
	}
	end;
}

 

Edited by AnnieRuru
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  52
  • Topics Per Day:  0.02
  • Content Count:  107
  • Reputation:   5
  • Joined:  07/21/16
  • Last Seen:  

On 2/10/2019 at 12:29 AM, AnnieRuru said:

no reward to the GMs, and no reward to auto-traders, AND if possible no reward to idle players *checkidle()


// F_ShuffleNumbers( <start num>, <last num>, <output array>{, <count>} );
function	script	F_ShuffleNumbers	{
	deletearray getarg(2);
	.@static = getarg(0);
	.@range = getarg(1) +1 - .@static;
	.@count = getarg(3, .@range);
	if (.@range <= 0 || .@count <= 0)
		return 0;
	if (.@count > .@range)
		.@count = .@range;
	for (.@i = 0; .@i < .@range; ++.@i)
		.@temparray[.@i] = .@i;
	for (.@i = 0; .@i < .@count; ++.@i) {
		.@rand = rand(.@range);
		set getelementofarray( getarg(2), .@i ), .@temparray[.@rand] + .@static;
		.@temparray[.@rand] = .@temparray[--.@range];
	}
	return .@count;
}

-	script	sjdfkhsf	FAKE_NPC,{
OnInit:
	.itemid = 501;
	.amount = 10;
//	bindatcmd "test", strnpcinfo(0)+"::OnDebug", 99, 100;
	end;
OnMinute00:
	if ( gettime(DT_HOUR) % 2 ) end;
//OnDebug:
	.@size = getunits( BL_PC, .@aid );
	F_ShuffleNumbers( 0, .@size -1, .@r );
	for ( .@i = 0; .@i < .@size; ++.@i ) {
		attachrid .@aid[.@r[.@i]];
		if ( getgmlevel() < 60 && ( checkvending() & (2|4) ) == 0 ) {
//		if ( getgmlevel() < 60 && ( checkvending() & (2|4) ) == 0 && checkidle() < 60 ) {
			announce strcharinfo(0) +" won the Lucky Draw !!",bc_all;
			mail getcharid(0), "Lucky Draw", "Prize", "Here is the Lucky Draw Prize", 0, .itemid, .amount;
			break;
		}
	}
	end;
}

 

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  52
  • Topics Per Day:  0.02
  • Content Count:  107
  • Reputation:   5
  • Joined:  07/21/16
  • Last Seen:  

tks for help. ?

I will test. 

a question to change to 1 hour I have to change here to 1?
 

Quote

OnMinute00:
	if ( gettime(DT_HOUR) % 2 ) end;

If so how do I switch to 30 minutes?

again. tks for help.

Link to comment
Share on other sites

  • 0

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

OnMinute00:
	if ( gettime(DT_HOUR) % 2 ) end;

change into

OnMinute00:
OnMinute30:

 

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