Jump to content
  • 0

Stuck on get item multi random


Question

Posted

Hello, i would like to know if it's possible to make a getitem call the function to get a random item two or more times for the same item, here is an example of the script i was doing, i stuck on it

turbo_room,129,133,4	script	Example	504,{
mes "Kill 1000 Metallings and you will be able to earn randomly 100, 150 or 150 Poring Coins";
next;
switch(select("Leave them to me:Maybe tomorrow...:I ended the mision")) {
next;
case 1:
setquest 80011;
mes "Allright, go get them!";
close;
case 2:
mes "Well... see you next time i guess";
close;
case 3:
if (checkquest (80011,HUNTING) == 2) {
erasequest 80011;
mes "Allright, here is your prize, good luck! i hope you earn a lot of Poring Coins!";
getitem callfunc( "F_Rand", 7539, ), 100; //here, how to add more random options for the same item?
close;
}
else
{
mes "You haven't kill 1000 Metallings, of what are you afraid? go get them!";
close;
}
end;
}

getitem callfunc( "F_Rand", 7539, ), 100;

 

is there a way?

 

thank you so much in advance!

12 answers to this question

Recommended Posts

Posted

yeah i'm sorry for not being clear D:!

 

i want to make that npc give randomly for example, 100, 150 or 200 porings coins

 

i mean, add more randoum results for the same item

 

for example, make on that npc, that after the player completes the quest, the player may be awarded with 100 or 150 or 200 porings coins, more random options for the same item D:

Posted

Here's three different methods:

 

1: Completely random IDs; fixed amounts

.@min_id = 501;		// Minimum item ID
.@max_id = 20000;	// Maximum item ID
.@rand_amt = 2;		// Amount of random items
.@recv_amt = 1;		// Amount to receive

// Loop for each item
for (.@i = 0; .@i < .@rand_amt; .@i++) {
	do {
		// Randomise item ID
		.@id = rand(.@min_id, .@max_id);
	} while (getitemname(.@id) == "null");
	
	// Receive item
	getitem .@id, .@recv_amt;
}

2: Controlled random IDs; fixed amounts

.@rand_amt = 2;	// Amount of random items
.@recv_amt = 1;	// Amount to receive

// Possible items to receive
setarray .@item_id[0], 501, 909, 910;

// Loop for each item
for (.@i = 0; .@i < .@rand_amt; .@i++) {
	do {
		// Randomise index location
		.@loc = rand(getarraysize(.@item_id));
	} while (getitemname(.@item_id[.@loc]) == "null");
	
	// Receive item
	getitem .@item_id[.@loc], .@recv_amt;
}

3: Controlled IDs and corresponding amounts

.@rand_amt = 2;		// Amount of random items

// Possible items to receive (ID, amount)
setarray .@item_id[0], 501, 2, 909, 5, 910, 3;

// Loop for each item
for (.@i = 0; .@i < .@rand_amt; .@i++) {
	do {
		// Randomise index location
		.@loc = rand(getarraysize(.@item_id));
	} while (getitemname(.@item_id[.@loc]) == "null" || .@loc % 2);
	
	// Receive item
	getitem .@item_id[.@loc], .@item_id[.@loc + 1];
}
Posted

I think you'd find your solution with something similar to #3; probably without the for loop, which I added in because I slightly misunderstood your request.

// Possible items to receive (ID, amount)
setarray .@item_id[0], 909, 2, 909, 3, 909, 3;

do {
	// Randomise index location
	.@loc = rand(getarraysize(.@item_id));
} while (getitemname(.@item_id[.@loc]) == "null" || .@loc % 2);

// Receive item
getitem .@item_id[.@loc], .@item_id[.@loc + 1];
Posted

oh allright thank you both for the repply, huh i have many random prizes on the script, i was wondering how to exavtly add it because looks like it's going to work only per npc? i would like to add it to the same npc tha has many random prizes


//incomplete. i was stuck on this parte
case 10:
if (checkquest (80011,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80011;
getitem callfunc( "F_Rand", 673, ), 1;
case 11:
if (checkquest (80012,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80012;
case 12:
if (checkquest (80013,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80013;
case 13:
if (checkquest (80014,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80014;
case 14:
if (checkquest (80015,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80015;
case 15:
if (checkquest (80016,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80016;
case 16:
if (checkquest (80017,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80017;
case 17:
if (checkquest (80018,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80018;
case 18:
if (checkquest (80019,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80019;


 
i would have to att id like this then?
 


 


case 10:
if (checkquest (80011,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80011;
setarray .@item_id[0], 909, 2, 909, 3, 909, 3;
do {
.@loc = rand(getarraysize(.@item_id));
} while (getitemname(.@item_id[.@loc]) == "null" || .@loc % 2);
getitem .@item_id[.@loc], .@item_id[.@loc + 1];
}
else
{
mes "You haven't completed the hunting";
close;
case 11:
if (checkquest (80012,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80012;
setarray .@item_id[0], 909, 2, 909, 3, 909, 3;
do {
.@loc = rand(getarraysize(.@item_id));
} while (getitemname(.@item_id[.@loc]) == "null" || .@loc % 2);
getitem .@item_id[.@loc], .@item_id[.@loc + 1];
}
else
{
mes "You haven't completed the hunting";
close;
case 12:
if (checkquest (80013,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80013;
setarray .@item_id[0], 909, 2, 909, 3, 909, 3;
do {
.@loc = rand(getarraysize(.@item_id));
} while (getitemname(.@item_id[.@loc]) == "null" || .@loc % 2);
getitem .@item_id[.@loc], .@item_id[.@loc + 1];
}
else
{
mes "You haven't completed the hunting";
close;
case 13:
if (checkquest (80014,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80014;
setarray .@item_id[0], 909, 2, 909, 3, 909, 3;
do {
.@loc = rand(getarraysize(.@item_id));
} while (getitemname(.@item_id[.@loc]) == "null" || .@loc % 2);
getitem .@item_id[.@loc], .@item_id[.@loc + 1];
}
else
{
mes "You haven't completed the hunting";
close;
case 14:
if (checkquest (80015,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80015;
setarray .@item_id[0], 909, 2, 909, 3, 909, 3;
do {
.@loc = rand(getarraysize(.@item_id));
} while (getitemname(.@item_id[.@loc]) == "null" || .@loc % 2);
getitem .@item_id[.@loc], .@item_id[.@loc + 1];
}
else
{
mes "You haven't completed the hunting";
close;
case 15:
if (checkquest (80016,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80016;
case 16:
if (checkquest (80017,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80017;
setarray .@item_id[0], 909, 2, 909, 3, 909, 3;
do {
.@loc = rand(getarraysize(.@item_id));
} while (getitemname(.@item_id[.@loc]) == "null" || .@loc % 2);
getitem .@item_id[.@loc], .@item_id[.@loc + 1];
}
else
{
mes "You haven't completed the hunting";
close;
case 17:
if (checkquest (80018,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80018;
setarray .@item_id[0], 909, 2, 909, 3, 909, 3;
do {
.@loc = rand(getarraysize(.@item_id));
} while (getitemname(.@item_id[.@loc]) == "null" || .@loc % 2);
getitem .@item_id[.@loc], .@item_id[.@loc + 1];
}
else
{
mes "You haven't completed the hunting";
close;
case 18:
if (checkquest (80019,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80019;
setarray .@item_id[0], 909, 2, 909, 3, 909, 3;
do {
.@loc = rand(getarraysize(.@item_id));
} while (getitemname(.@item_id[.@loc]) == "null" || .@loc % 2);
getitem .@item_id[.@loc], .@item_id[.@loc + 1];
}
else
{
mes "You haven't completed the hunting";
close;
}
end;

Posted

Uh...I don't even know where to begin helping you in that case, but it could probably be written a lot better. No offence intended. o_o

 

If you're going to have separate random prizes (meaning completely different items and amounts) for each prize, then you might have to stick with what you pasted here; otherwise, if you're going to use the same random set of prizes for all of those, place it outside of the switch.

Posted

oh lol don't worry i don't mind

 

huh i got an idea

 

why not make a function on a different script file that will just randomize the desired items by calling the function? for example something like this:

case 10:
if (checkquest (80011,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80011;
call function that randomize the item id 909 } //the function here is the same as the method #3 and gives the item 909
else
{
mes "You haven't completed the hunting";
close;
case 11:
if (checkquest (80012,HUNTING) == 2) {
mes "Here is your prize!";
erasequest 80012;
call function that randomize the item id 910}} //the function here is the same as the method #3 and gives the item 910
else
{
mes "You haven't completed the hunting";
close;

well the problem would be that i will need a lot of different script text files meaning a lot of functions to be called x_x doesn't that harms the server D:?

Posted

Or you could write a local function and place it at the beginning of your script:

function getranditem {

	// Possible items to receive (ID, amount)
	setarray .@item_id[0], 909, 2, 909, 3, 909, 3;

	do {
		// Randomise index location
		.@loc = rand(getarraysize(.@item_id));
	} while (getitemname(.@item_id[.@loc]) == "null" || .@loc % 2);

	// Receive item
	getitem .@item_id[.@loc], .@item_id[.@loc + 1];
	return;

}

Place this after your header but before anything else in the script starts; then, you can call on this function by writing:

getranditem;
Posted

oh cool o: i did that on a requested script

 

http://rathena.org/board/topic/92414-quest-npc-with-random-prize/

 

 

but i putted it on the end

 

allright so i would just add the call functions on the same script and then call the ones that i want on the getitem call func "name" o:!!!

 

i think i got it now, gonna test it o:! 

 

my brain can't hold anymore @_@ let me get a little rest, i'm going to come back 

Posted

allright than you so much both, going to play a lot with it o:!
 
 

?

getitem 7539, callfunc( "F_Rand", 100, 150, 200 ); //here, how to add more random options for the same item?

 
yeah that part, i wanted to make the random 3 times for the same item but with only 1 prize D:

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