Add announce on random box

nuna

New member
Messages
136
Points
0
Emulator
hello how can i add announce on specific item if get and make it have amount value?

function script boxrandom {
setarray .@reward, 607, 60,
612, 10,
611, 10,
608, 10,
678, 5,
675, 5;
set .@size, getarraysize( .@reward );
for( set .@i, 1; .@i < .@size; .@i += 2 ) {
.@percent[.@i] = .@total + .@reward[.@i];
.@total += .@reward[.@i];
}
.@r = rand( .@total +1 );
for( set .@i, 1; .@i < .@size; .@i += 2 )
if( .@percent[.@i] > .@r )
break;
getitem .@reward[ .@i-1 ], 1;
end;
}


how can i add also on what amount per item? example since 612 - id name and 10 is the chance. please help me to make it 612,1->amount,10->chance

Example i want the id number 678 if get to be announce" char name got 1x Poison bottle "

 
Try this:

function script loot_crate {
.@index = getarrayindex(getarg(0));
.@size = getarraysize(getarg(0));

for (.@i = .@index; .@i < .@size - .@index; .@i += 3) {
for (.@e = 0; .@e < getelementofarray(getarg(0), .@i + 2); ++.@e) {
.@loot[.@count++] = .@i;
}
}

.@rand = .@loot[rand(.@count)];
getitem(getelementofarray(getarg(0), .@rand), getelementofarray(getarg(0), .@rand + 1));

announce(sprintf("Player %s obtained %ix %s from a loot crate!"
strcharinfo(PC_NAME),
getelementofarray(getarg(0), .@rand + 1),
getitemname(getelementofarray(getarg(0), .@rand))),
getarg(1, bc_all));

return true;
}




And in your NPC do something like this:

Code:
MAP,X,Y,DIR	script	NAME	SPRITE,{

	mes("Hello");
	next();
	loot_crate(.rewards, bc_all);
	mes("Goodbye!");
	close;

OnInit:
	setarray(.rewards,
		// Item,           Amount, Chance
		Yggdrasilberry,    1,      60,
		Portable_Furnace,  1,      10,
		Spectacles,        1,      10,
		Seed_Of_Yggdrasil, 1,      10,
		Poison_Bottle,     1,      5,
		Silver_Coin,       1,      5);
}
 
Back
Top