Egg custom error

Like it~*

New member
Messages
175
Points
0
Hello, I'm trying to create a custom egg, but I'm having problems ...
1st - I can not put numbers that are not integers. Ex: 0.1, 5.2, 4.3 etc ...
2nd - Would like you to always win an item, regardless of the percentage. Eg: when opening the egg, the message "dispbottom" would never appear. There was no prize in this egg. ";", Since there will always be an item, the player will never open the egg and will not win anything.
3th - Announce upon receiving an item with a low percentage eg chance of getting an item = 0.1;%, when someone received this item, was announced for every server.
 
Code:
function script Surp {
setarray @id[0], 501,502,503; /*  Id of the awards that can be obtained. */
setarray @qn[0], 10, 1,1; /* Quantity wins.*/
setarray @pt[0], 1,0.5,0.1; /*Percentage of chance to get the item. (1 = 1% - 10 = 10% - 100 = 100%) */

for(set @i,0; @i < getarraysize(@id);set @i,@i+1){
if(@pt[@i] >= rand(100)){
getitem @id[@i],@qn[@i];
dispbottom "Congrats you were awarded with "+@qn[@i]+" "+getitemname(@id[@i]);
end;
}
}
dispbottom "There was no prize in this egg..";
end;
}
 
NOTE: I know you can do this for the package, but I find it easier for the function and it gets much faster.
 
So, for each point:

1- I've never tried it, I must admit it. Just change the value for integers, and change the rand. For instance, 0.1%, set 1 for success rate, and make a rand(1000) instead of a rand(100). It'll enable more lower chance.

2- remove the dispbottom, and add a getitem for the "bad luck" item.

3- check for the @pt[@i] value. if it's under a certain value (1, if you make a rand 1000, 10 for rand 1000...) and add an announce before the "end" command in the success section.

 
So, for each point:

1- I've never tried it, I must admit it. Just change the value for integers, and change the rand. For instance, 0.1%, set 1 for success rate, and make a rand(1000) instead of a rand(100). It'll enable more lower chance.

2- remove the dispbottom, and add a getitem for the "bad luck" item.

3- check for the @pt[@i] value. if it's under a certain value (1, if you make a rand 1000, 10 for rand 1000...) and add an announce before the "end" command in the success section.
It looks like this:

function script Surp {
setarray @id[0], 501,502,503; //Id of the awards that can be obtained.
setarray @qn[0], 10, 3, 1; //Quantity wins.
setarray @pt[0], 10,5,10; //Percentage of chance to get the item. (10 = 1% - 100 = 10% - 1000 = 100%)

for(set @i,0; @i < getarraysize(@id);set @i,@i+1){
if(@pt[@i] >= rand(1000)){
getitem @id[@i],@qn[@i];
dispbottom "Congrats you were awarded with "+@qn[@i]+" "+getitemname(@id[@i]);
end;
}
}
getitem @id[@i],@qn[@i];
end;
}

But it does not work. It became harder to get the items and still fails most of the time. I think it's best to do the same package. But thanks for the help!

 
Well with the value you provided, there's a 1% chance to get an item. So basically, the rate is pretty low.

Did you tried with higher values, to be sure the chance are well read? 

Cause basically, it should work.

 
Back
Top