Jump to content
  • 0

I need a random item generator can anyone help me?


ADM Ytallo

Question


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  98
  • Reputation:   3
  • Joined:  09/02/18
  • Last Seen:  

the player will put a ticket on the machine, and it will give 1 random iten
 

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  228
  • Reputation:   19
  • Joined:  10/27/12
  • Last Seen:  

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) {
			.@mes$ = "You can get: ";
			for( .@a = 1; .@a <=.len_i; .@a++ ) {
				.@itm$ = getitemname(.itm_l[(.@a-1)]);
				if(.@a%10&&.@a<=.len_i&&.@a!=.len_i) {
					.@mes$ = .@mes$+((!((.@a%10)-9)&&.@a<=.len_i)?"and "+.@itm$+".":.@itm$+", ");
				} else {
					mes .npc_n$;
					if(.@a<.len_i) {
						mes .@mes$; .@mes$ = "You can also get : "+.@itm$+", "; next;
						if(select("Continue:Cancel")&2) close;
					} else {
						mes .@mes$+"and "+.@itm$+"."; close;
					}
				}
			}
		} else close;
	}
	if (countitem(.itm_p) < .itm_a) {
		mes .npc_n$;
		mes "You do not have "+.itm_a+" "+getitemname(.itm_p);
		close;
	}


	.@rand = rand(.totalchance);
	.@i = 0;

	while ( ( .@rand -= .it_rates[.@i] ) >= 0 ) 
		.@i++;

	mes .npc_n$;
    mes "Here it is!";
	delitem .itm_p,.itm_a;
	getitem .itm_l[.@i], 1;
	.@gitem$ = getitemname(.itm_l[.@i]);
//	dispbottom ("debug :: .@gitem$ " + .@gitem$ + "  .itm_l[.@i]" + .itm_l[.@i] );
	announce strnpcinfo(0)+": "+strcharinfo(0)+" won ["+.@gitem$+"] da Máquina de Promoções!",bc_all|bc_yellow;
	
//debugonly	dispbottom ( " debug :: .it_rates " + .it_rates + "  .totalchance :: " + .totalchance + "  .@rand :: " + .@rand) ;
	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

		.@i = 0;
		while ( .itm_l[.@i] ) {
			.totalchance += .it_rates[.@i];
			.@i++;
		}
}

	

/*choosing rates...
prontera,157,180,5	script	test item_reward#3	100,{
	.@rand = rand(.totalchance);
	.@i = 0;
	while ( ( .@rand -= .itemchance[.@i] ) >= 0 ) .@i++;
	getitem .itemid[.@i], 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;
	.@i = 0;
	while ( .itemid[.@i] ) {
		.totalchance += .itemchance[.@i];
		.@i++;
	}
	end;
}
*/

Tidy up Updated per request.

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

  • 0

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  436
  • Reputation:   167
  • Joined:  12/12/17
  • Last Seen:  

Here

rAthena has very sophisticated functions. please use them.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  98
  • Reputation:   3
  • Joined:  09/02/18
  • Last Seen:  

4 hours ago, pajodex said:

Aqui

A rena tem funções muito sofisticadas. por favor use-os.

It does not fit the way I have there.
 

 

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	.@ticket_id = 7539;
	.@amount = 1;
	
	if (countitem(.@ticket_id) >= .@amount) {
		delitem .@ticket_id, .@amount;
		getitem F_Rand(501, 502, 503, 504, 505, 506), 1;
	}
	end;
}

 

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  98
  • Reputation:   3
  • Joined:  09/02/18
  • Last Seen:  

12 hours ago, Emistry said:

prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	.@ticket_id = 7539;
	.@amount = 1;
	
	if (countitem(.@ticket_id) >= .@amount) {
		delitem .@ticket_id, .@amount;
		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

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  98
  • Reputation:   3
  • Joined:  09/02/18
  • Last Seen:  

este NPC está dando itens aleatórios. Eu quero definir a taxa de cada item, é possível?
 

 

Edited by YtalloNv
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  49
  • Topics Per Day:  0.01
  • Content Count:  1529
  • Reputation:   234
  • Joined:  08/03/12
  • Last Seen:  

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

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  98
  • Reputation:   3
  • Joined:  09/02/18
  • Last Seen:  

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 .@mes$, "Pode ganhar: ";
            for(set(.@a,1);.@a<=.len_i;set(.@a,.@a+1)) {
                set .@itm$, getitemname(.itm_l[(.@a-1)]);
                if(.@a%10&&.@a<=.len_i&&.@a!=.len_i) {
                    set .@mes$, .@mes$+((!((.@a%10)-9)&&.@a<=.len_i)?
                            "and "+.@itm$+".":.@itm$+", ");
                } else {
                    mes .npc_n$;
                    if(.@a<.len_i) {
                        mes .@mes$; set .@mes$, "Você também pode ganhar: "+.@itm$+", "; next;
                        if(select("Seguir:Fechar")&2) close;
                    } else {
                        mes .@mes$+"and "+.@itm$+"."; 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 .@get, .itm_l[rand(.len_i-1)];
    if(compare(.itm_a$,""+.@get)) announce strnpcinfo(0)+": "+strcharinfo(0)+" Obteve ["+getitemname(.@get)+"] da Máquina de Promoções!",bc_all|bc_yellow;
    getitem .@get,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

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

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;
	.@r = rand(.totalchance);
	for ( .@i = 0; ( .@r -= .itemchance[.@i] ) >= 0; ++.@i );
	getitem .itemid[.@i], 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 ( .@i = 0; .itemid[.@i]; ++.@i )
		.totalchance += .itemchance[.@i];
	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
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  98
  • Reputation:   3
  • Joined:  09/02/18
  • Last Seen:  

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) {
			.@mes$ = "You can get: ";
			for( .@a = 1; .@a <=.len_i; .@a++ ) {
				.@itm$ = getitemname(.itm_l[(.@a-1)]);
				if(.@a%10&&.@a<=.len_i&&.@a!=.len_i) {
					.@mes$ = .@mes$+((!((.@a%10)-9)&&.@a<=.len_i)?"and "+.@itm$+".":.@itm$+", ");
				} else {
					mes .npc_n$;
					if(.@a<.len_i) {
						mes .@mes$; .@mes$ = "You can also get : "+.@itm$+", "; next;
						if(select("Continue:Cancel")&2) close;
					} else {
						mes .@mes$+"and "+.@itm$+"."; close;
					}
				}
			}
		} else close;
	}
	if (countitem(.itm_p) < .itm_a) {
		mes .npc_n$;
		mes "You do not have "+.itm_a+" "+getitemname(.itm_p);
		close;
	}


	.@rand = rand(.totalchance);
	.@i = 0;

	while ( ( .@rand -= .it_rates[.@i] ) >= 0 ) 
		.@i++;

	mes .npc_n$;
    mes "Here it is!";
	delitem .itm_p,.itm_a;
	getitem .itm_l[.@i], 1;
	.@gitem$ = getitemname(.itm_l[.@i]);
//	dispbottom ("debug :: .@gitem$ " + .@gitem$ + "  .itm_l[.@i]" + .itm_l[.@i] );
	announce strnpcinfo(0)+": "+strcharinfo(0)+" won ["+.@gitem$+"] da Máquina de Promoções!",bc_all|bc_yellow;
	
//debugonly	dispbottom ( " debug :: .it_rates " + .it_rates + "  .totalchance :: " + .totalchance + "  .@rand :: " + .@rand) ;
	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

		.@i = 0;
		while ( .itm_l[.@i] ) {
			.totalchance += .it_rates[.@i];
			.@i++;
		}
}

	

/*choosing rates...
prontera,157,180,5	script	test item_reward#3	100,{
	.@rand = rand(.totalchance);
	.@i = 0;
	while ( ( .@rand -= .itemchance[.@i] ) >= 0 ) .@i++;
	getitem .itemid[.@i], 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;
	.@i = 0;
	while ( .itemid[.@i] ) {
		.totalchance += .itemchance[.@i];
		.@i++;
	}
	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...