Just tell what you want and we can try to help you.
If .size is initialized after the rand, it will rand(0), try this instead:
.@mid = .Peco[rand(getarraysize(.Peco))]; // else where in the code
OnInit: // inside the script but at end
setarray .Peco[0], 2811;
end;
If size is 1, rand(1) will give 0, which is first position, no error must be shown.