Jump to content
  • 0
ADM Ytallo

I need a random item generator can anyone help me?

Question

11 answers to this question

Recommended Posts

  • 0
prontera,141,226,4	script	Maquina de Promoções	2_DROP_MACHINE,{
//debugonly	dispbottom ( "debug :: .len_i " + .len_i + ".itm_a " + .itm_a + ".itm_p " + .itm_p + " ." ) ;
	mes .npc_n$;
	mes "It only cost " + .itm_a + " " + getitemname(.itm_p) + "to use this machine!";
	mes "Would you like to use it?"; next;
	if(select("^0084ff[ • ]^000000 Yes:^CD3278[ • ]^000000 No:^0084ff[ • ]^000000 What can I earn??")&2) {
		if(@menu-2) {
			[email protected]$ = "You can get: ";
			for( [email protected] = 1; [email protected] <=.len_i; [email protected]++ ) {
				[email protected]$ = getitemname(.itm_l[([email protected])]);
				if([email protected]%10&&[email protected]<=.len_i&&[email protected]!=.len_i) {
					[email protected]$ = [email protected]$+((!(([email protected]%10)-9)&&[email protected]<=.len_i)?"and "[email protected]$+".":[email protected]$+", ");
				} else {
					mes .npc_n$;
					if([email protected]<.len_i) {
						mes [email protected]$; [email protected]$ = "You can also get : "[email protected]$+", "; next;
						if(select("Continue:Cancel")&2) close;
					} else {
						mes [email protected]$+"and "[email protected]$+"."; close;
					}
				}
			}
		} else close;
	}
	if (countitem(.itm_p) < .itm_a) {
		mes .npc_n$;
		mes "You do not have "+.itm_a+" "+getitemname(.itm_p);
		close;
	}


	[email protected] = rand(.totalchance);
	[email protected] = 0;

	while ( ( [email protected] -= .it_rates[[email protected]] ) >= 0 ) 
		[email protected]++;

	mes .npc_n$;
    mes "Here it is!";
	delitem .itm_p,.itm_a;
	getitem .itm_l[[email protected]], 1;
	[email protected]$ = getitemname(.itm_l[[email protected]]);
//	dispbottom ("debug :: [email protected]$ " + [email protected]$ + "  .itm_l[[email protected]]" + .itm_l[[email protected]] );
	announce strnpcinfo(0)+": "+strcharinfo(0)+" won ["[email protected]$+"] da Máquina de Promoções!",bc_all|bc_yellow;
	
//debugonly	dispbottom ( " debug :: .it_rates " + .it_rates + "  .totalchance :: " + .totalchance + "  [email protected] :: " + [email protected]) ;
	close;

	OnInit:
		.npc_n$ = "[^ 4B0082 Promotion Kit ^ 000000]"; // NPC Name.
		setarray	.itm_l , 	502, 678, 607 ,608 ,2101 ,1505 ,609;// Item List
		setarray	.it_rates,	15, 16, 17, 18, 19, 20, 21; // ?item?rates?
		.len_i = getarraysize(.itm_l); //item id array size
		.itm_a = 1; //per draw Item cost
		.itm_p = 512; //per draw item ID

		[email protected] = 0;
		while ( .itm_l[[email protected]] ) {
			.totalchance += .it_rates[[email protected]];
			[email protected]++;
		}
}

	

/*choosing rates...
prontera,157,180,5	script	test item_reward#3	100,{
	[email protected] = rand(.totalchance);
	[email protected] = 0;
	while ( ( [email protected] -= .itemchance[[email protected]] ) >= 0 ) [email protected]++;
	getitem .itemid[[email protected]], 1;
	end;
OnInit:
	setarray .itemid, 501,502,503,504,505,506,507,508,509;
	setarray .itemchance, 10,10,10,10,3,10,10,10,10;
	[email protected] = 0;
	while ( .itemid[[email protected]] ) {
		.totalchance += .itemchance[[email protected]];
		[email protected]++;
	}
	end;
}
*/

Tidy up Updated per request.

Edited by utofaery
  • Love 1
Link to comment
Share on other sites

  • 0
prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	[email protected]_id = 7539;
	[email protected] = 1;
	
	if (countitem([email protected]_id) >= [email protected]) {
		delitem [email protected]_id, [email protected];
		getitem F_Rand(501, 502, 503, 504, 505, 506), 1;
	}
	end;
}

 

  • Love 1
Link to comment
Share on other sites

  • 0
12 hours ago, Emistry said:
prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	[email protected]_id = 7539;
	[email protected] = 1;
	
	if (countitem([email protected]_id) >= [email protected]) {
		delitem [email protected]_id, [email protected];
		getitem F_Rand(501, 502, 503, 504, 505, 506), 1;
	}
	end;
}

 

help me with this script

I want this npc to randomly give me items and I want to set the rate..!

https://pastebin.com/MaWCq2D5

Edited by Emistry
Link to comment
Share on other sites

  • 0
4 hours ago, YtalloNv said:

this NPC is giving random items. I want to set the rate of each item, is it possible?
 

maquina_surpresa.txt

Hello, can you use code function ?
Sorry but.. its better for us to see the codes clearly rather than download it as a MUST.

Link to comment
Share on other sites

  • 0
On 11/10/2018 at 2:11 AM, Chaos92 said:

Olá, você pode usar a função de código?
Desculpe, mas .. é melhor para nós para ver os códigos claramente ao invés de baixá-lo como uma obrigação.

I want to be able to control the rate of items on this NPC

prontera,141,226,4    script    Maquina de Promoções    2_DROP_MACHINE,{
    mes .npc_n$;
    mes "Apenas "+.itm_a+" "+.itm_n$+" para usar essa maquina!";
    mes "Você gostaria de usar?"; next;
    if(select("^0084ff[ • ]^000000 Sim:^CD3278[ • ]^000000 Não:^0084ff[ • ]^000000 O que posso ganhar?")&2) {
        if(@menu-2) {
            set [email protected]$, "Pode ganhar: ";
            for(set([email protected],1);[email protected]<=.len_i;set([email protected],[email protected]+1)) {
                set [email protected]$, getitemname(.itm_l[([email protected])]);
                if([email protected]%10&&[email protected]<=.len_i&&[email protected]!=.len_i) {
                    set [email protected]$, [email protected]$+((!(([email protected]%10)-9)&&[email protected]<=.len_i)?
                            "and "[email protected]$+".":[email protected]$+", ");
                } else {
                    mes .npc_n$;
                    if([email protected]<.len_i) {
                        mes [email protected]$; set [email protected]$, "Você também pode ganhar: "[email protected]$+", "; next;
                        if(select("Seguir:Fechar")&2) close;
                    } else {
                        mes [email protected]$+"and "[email protected]$+"."; close;
                    }
                }
            }
        } else close;
    }
    if (countitem(.itm_p) < .itm_a) {
        mes .npc_n$;
        mes "Você não tem "+.itm_a+" "+.itm_n$;
        close;
    }
    mes .npc_n$;
    mes "Aqui está!";
    delitem .itm_p,.itm_a;
    set [email protected], .itm_l[rand(.len_i-1)];
    if(compare(.itm_a$,""[email protected])) announce strnpcinfo(0)+": "+strcharinfo(0)+" Obteve ["+getitemname([email protected])+"] da Máquina de Promoções!",bc_all|bc_yellow;
    getitem [email protected],1;
    close;

    OnInit:
        set         .npc_n$,    "[^4B0082Maquina de Promoções^000000]"; //Nome NPC.
        setarray    .itm_l ,    502, 678, 607 ,608 ,2101 ,1505 ,609;// Lista de Itens
        set         .itm_a$,    "1505";//IDs de item nesta cadeia são anunciados.
        set         .len_i ,    getarraysize(.itm_l); //Comprimento da matriz.
        set         .itm_a ,    1; //Custo do NPC.
        set         .itm_p ,    7608; //Item usado como moeda.
        set         .itm_n$,    getitemname(.itm_p); //Nome do item.
}

up

Link to comment
Share on other sites

  • 0
prontera,157,180,5	script	test item_reward#3	2_VENDING_MACHINE1,{
	if ( !countitem(.itemuse) ) {
		mes "A "+ getitemname(.itemuse) +" is needed to use this machine";
		close;
	}
	delitem .itemuse, 1;
	[email protected] = rand(.totalchance);
	for ( [email protected] = 0; ( [email protected] -= .itemchance[[email protected]] ) >= 0; [email protected] );
	getitem .itemid[[email protected]], 1;
	end;
OnInit:
	.itemuse = 7539; // poring coin
	setarray .itemid, 501,502,503,504,505,506,507,508,509;
	setarray .itemchance, 10,10,10,10,3,10,10,10,10;
	for ( [email protected] = 0; .itemid[[email protected]]; [email protected] )
		.totalchance += .itemchance[[email protected]];
	end;
}

 

btw this script is call "lotti girl"
https://rathena.org/board/search/?&amp;q=lotti&amp;search_and_or=and&amp;sortby=relevancy
a lot of results return from it

Edited by AnnieRuru
Link to comment
Share on other sites

  • 0
On 2/9/2019 at 8:17 PM, utofaery said:
prontera,141,226,4	script	Maquina de Promoções	2_DROP_MACHINE,{
//debugonly	dispbottom ( "debug :: .len_i " + .len_i + ".itm_a " + .itm_a + ".itm_p " + .itm_p + " ." ) ;
	mes .npc_n$;
	mes "It only cost " + .itm_a + " " + getitemname(.itm_p) + "to use this machine!";
	mes "Would you like to use it?"; next;
	if(select("^0084ff[ • ]^000000 Yes:^CD3278[ • ]^000000 No:^0084ff[ • ]^000000 What can I earn??")&2) {
		if(@menu-2) {
			[email protected]$ = "You can get: ";
			for( [email protected] = 1; [email protected] <=.len_i; [email protected]++ ) {
				[email protected]$ = getitemname(.itm_l[([email protected])]);
				if([email protected]%10&&[email protected]<=.len_i&&[email protected]!=.len_i) {
					[email protected]$ = [email protected]$+((!(([email protected]%10)-9)&&[email protected]<=.len_i)?"and "[email protected]$+".":[email protected]$+", ");
				} else {
					mes .npc_n$;
					if([email protected]<.len_i) {
						mes [email protected]$; [email protected]$ = "You can also get : "[email protected]$+", "; next;
						if(select("Continue:Cancel")&2) close;
					} else {
						mes [email protected]$+"and "[email protected]$+"."; close;
					}
				}
			}
		} else close;
	}
	if (countitem(.itm_p) < .itm_a) {
		mes .npc_n$;
		mes "You do not have "+.itm_a+" "+getitemname(.itm_p);
		close;
	}


	[email protected] = rand(.totalchance);
	[email protected] = 0;

	while ( ( [email protected] -= .it_rates[[email protected]] ) >= 0 ) 
		[email protected]++;

	mes .npc_n$;
    mes "Here it is!";
	delitem .itm_p,.itm_a;
	getitem .itm_l[[email protected]], 1;
	[email protected]$ = getitemname(.itm_l[[email protected]]);
//	dispbottom ("debug :: [email protected]$ " + [email protected]$ + "  .itm_l[[email protected]]" + .itm_l[[email protected]] );
	announce strnpcinfo(0)+": "+strcharinfo(0)+" won ["[email protected]$+"] da Máquina de Promoções!",bc_all|bc_yellow;
	
//debugonly	dispbottom ( " debug :: .it_rates " + .it_rates + "  .totalchance :: " + .totalchance + "  [email protected] :: " + [email protected]) ;
	close;

	OnInit:
		.npc_n$ = "[^ 4B0082 Promotion Kit ^ 000000]"; // NPC Name.
		setarray	.itm_l , 	502, 678, 607 ,608 ,2101 ,1505 ,609;// Item List
		setarray	.it_rates,	15, 16, 17, 18, 19, 20, 21; // ?item?rates?
		.len_i = getarraysize(.itm_l); //item id array size
		.itm_a = 1; //per draw Item cost
		.itm_p = 512; //per draw item ID

		[email protected] = 0;
		while ( .itm_l[[email protected]] ) {
			.totalchance += .it_rates[[email protected]];
			[email protected]++;
		}
}

	

/*choosing rates...
prontera,157,180,5	script	test item_reward#3	100,{
	[email protected] = rand(.totalchance);
	[email protected] = 0;
	while ( ( [email protected] -= .itemchance[[email protected]] ) >= 0 ) [email protected]++;
	getitem .itemid[[email protected]], 1;
	end;
OnInit:
	setarray .itemid, 501,502,503,504,505,506,507,508,509;
	setarray .itemchance, 10,10,10,10,3,10,10,10,10;
	[email protected] = 0;
	while ( .itemid[[email protected]] ) {
		.totalchance += .itemchance[[email protected]];
		[email protected]++;
	}
	end;
}
*/

Tidy up Updated per request.

Have you removed the control of items to be announced have to add dinovo and leave the control of fees!

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

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.