Hello Racaae, thx for your help! i'm testing your script now, and he looks really clean and with more features than i expected! I noticed that some time when even if the player gets the right number of the raffle (win codition) he not get the grand prize istead the npc gives to the player the consolation prize.
I've made some changes on my original code yesterday before read your post and here is what my actual raffle script is:
prontera,161,188,4 script Ana da Rifa 4_F_PINKWOMAN,{
.@npc_name$ = "[^FF09FF Ana ^000000]";
mes .@npc_name$;
if ((gettimetick(2) - .last_participation_time) <= 3) {
mes "Você já comprou uma rifa recentemente, aguarde um instante...";
close;
}
mes "Olá, seja bem-vindo(a) ao nosso sistema de rifas!";
mes "Temos vários prêmios interessantes que podem te ajudar em sua jornada!";
next;
mes "Gostaria de participar da rifa do momento?";
mes "O prêmio ^FFAF22 PRINCIPAL ^000000 será: ";
mes "x"+.Grand_Prize_Amount[.index]+" ^477FEE"+ .Grand_Prize_T$[.index];
mes "-------------------------------------------";
mes "O prêmio de ^FF0000 consolação ^000000 será: ";
mes "x"+.Consolation_Prize_Amount[.index]+" ^895818"+ .Consolation_Prize_T$[.index];
mes "O valor da rifa é de ^FF0000"+ .zeny_required[.index] +"^000000 Zenys";
next;
switch( select("Tentar a sorte!", "Hoje não.") ) {
case 1:
if (Zeny <= .zeny_required[.index]) {
mes "Você não tem ^FF0000"+ .zeny_required[.index] +"^000000 Zenys para participar da Rifa!";
close;
}
.@weight = 100 * Weight / MaxWeight;
getinventorylist;
if (.@weight > 50) || ((100 - @inventorylist_count ) < 6) {
mes "Verifique se você esta sobrecarregado ou com o inventário próximo do limite!";
close;
}
.@p1 = (rand(1000)+1);
mes "Sua chance de ganhar é de "+ (.odds[.index]/10) +"%";
next;
mes "Sua sorte hoje é o número - ^FF9900"+ .@p1 +".";
if (.@p1 <= .odds[.index]) {
mes "Parabéns voce ganhou o grande prêmio:";
mes "x"+ .Grand_Prize_Amount[.index] +" ^477FEE"+ .Grand_Prize_T$[.index];
Zeny -= .zeny_required[.index];
getitem .Grand_Prize$[.index], .Grand_Prize_Amount[.index];
mapannounce .map$, "O jogador "+ strcharinfo(0) +" foi o vencedor da atual rifa!", 0, 0xFCE516;
close2;
goto OnInit;
}
else{
.last_participation_time = gettimetick(2);
mes "Infelizmente não foi desta vez, seu prêmio de consolação é: ";
mes "x"+ .Consolation_Prize_Amount[.index] +" ^895818"+ .Consolation_Prize_T$[.index];
Zeny -= .zeny_required[.index];
getitem .Consolation_Prize$[.index], .Consolation_Prize_Amount[.index];
close;
}
}
close;
OnInit: OnTimer600000: initnpctimer;
.map$ = "prontera";
hideonnpc "Ana da Rifa";
sleep 12000;
hideoffnpc "Ana da Rifa";
setarray .raffle[0], 0, 1, 2, 3, 4;
setarray .Grand_Prize$[0], "Red_Potion", "White_Potion", "Blue_Potion", "Tha_Maero_Card", "Poring_Card";
setarray .Grand_Prize_T$[0], "Poções Vermelhas", "Poções Brancas", "Poções Azuis", "Carta Memória de Thanatos", "Carta Poring";
setarray .Grand_Prize_Amount[0], 20, 30, 5, 50, 25;
setarray .Consolation_Prize$[0], "Red_Potion", "White_Potion", "Blue_Potion", "Jellopy", "Stone_Fragments";
setarray .Consolation_Prize_T$[0], "Poção Vermelha", "Poção Branca", "Poção Azul", "Jellopys", "Fragmentos de Pedra";
setarray .Consolation_Prize_Amount[0], 1, 1, 1, 50, 5;
setarray .zeny_required[0], 500, 1500, 10000, 2500000, 999;
setarray .odds[0], 500, 350, 450, 30, 500;
.index = rand(getarraysize(.raffle));
announce "Olá, uma nova rifa está disponível! O prêmio no momento para o ganhador é x"+ .Grand_Prize_Amount[.index]+ " " + .Grand_Prize_T$[.index] +", e para quem não conseguir, o prêmio de consolação será x"+ .Consolation_Prize_Amount[.index]+ " " + .Consolation_Prize_T$[.index] + ", a chance de ganhar o prêmio é de "+ (.odds[.index]/10) +"%." , 0, 0x7AF6EE;
end;
}
Some of the changes:
Yet i need to fix a problem when one player wins and the others are chatting with the NPC they also get one last chance to win, but i see in your code the solution (check if the npcs is cloaked before the prize results, if true, go to restarting label!)
Thank you very much Racaae for coding my request and for the insights it gives me, I will try to understand the complete code to improve my scripting skills!
I will make some changes based on Raccae's code and in a few days i will share it here.