Jump to content
  • 0

Enchant Random Option


Rizta

Question


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  109
  • Reputation:   5
  • Joined:  08/12/17
  • Last Seen:  

Well, im looking for a way to give different(and random) options by index slot(0, 1 , 2, 3, 4 = 5 slots) and equipment slot( headgear, weapon, armor etc).

Based on that, found one script that do it but completely random and then i edited to do what i want.

But, once im newbie(or simple noob hehe) its obvious i got erros and lots of doubts. 

Here's the full code:

Spoiler

//===== rAthena Script =======================================
//= Random Option SurviveRO
//===== By: ==================================================
//= Rizakh
//===== Current Version: =====================================
//= 1.0
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= Atribui opcoes aleatorias aos equipamentos.
//= com o custo de X zeny/cash
//============================================================
prontera,143,182,3	script	Piranha Safada	700,{
	goto NPC;
end;

OnInit:
//==============================
//	CONFIGURAÇÕES DE MOEDA
//	1 = Zeny
//	0 = Cashpoints
//==============================
set .moeda,1;		// Moeda para comprar a opcao aleatoria
set .preco,1;	// Preco da opcao aleatoria
//setarray .irq[0],990,7041; // Red Blood e Fine Grit
//setarray .iqt[0],1,1; // Quantidade de cada item
//==============================
//	CONFIGURAÇÕES RANDOM OPTION 
//==============================
	set .sobrepor,1;	// Permite sobrepor encantamentos existentes ( 0 = off )
	set .falha,0;		// Define a chance de falha (%)
	//set .MaxOpt,192;		// Maximum item option a player can enchant ( reference: https://github.com/rathena/rathena/blob/master/db/const.txt#L1645-L1836 )
	//set .MinOpt,1;		// Minimum item option a player can enchant
	set .valmin,1;	// Valor minimo a se tirar na opcao aleatoria
	set .valmax,5;	// Valor maximo a se tirar na opcao aleatoria
	set .slotmax,4;	// Maximo de slots para encantar( padrão = 0-4 )
	set .espera,1;		// Delay da barra de progresso em segundos
//============================
// IDS DAS RANDOM OPTIONS 
// SEPARADAS POR EQUIPAMENTOS 
// E SLOT (0 PARA 4 = 5 SLOTS)
//============================
//  Equip Top Head Possible IDS
//============================
setarray .thd0[1], 13, 14, 11, 12, 16, 18,
                    3,  4,  5,  6,  7,  8,
                   20, 21, 22, 23, 24, 19;
setarray .thd1[1], 25, 26, 27, 28, 29, 30,
                   31, 32, 33, 34, 35;
setarray .thd2[1],168,169,170,171,172,167;
setarray .thd3[1],  3,  4,  5,  6,  7,  8,
                   36, 38, 40, 42, 44, 46,
                   48, 50, 52, 54;
setarray .thd4[1],  3,  4,  5,  6,  7,  8,
                   56, 58, 60, 62, 64, 66,
                   68, 70, 72, 74;
//=============================
// Equip Mid Head Possible IDS
//=============================
setarray .mhd0[1],  3,  4,  5,  6,  7,  8;
setarray .mhd1[1], 87, 89, 90, 91, 92, 93,
                   94, 95, 96;
setarray .mhd2[1],168,169,170,171,172,167;
setarray .mhd3[1], 97, 98, 99,100,101,102,
                  103,104,105,106,107,108,
                  109,110,111,112,113,114,
                  115,116;
setarray .mhd4[1],  9, 10, 11, 12, 13, 14,
                   15, 16, 17, 18, 19, 20,
                   21, 22, 23, 24;
//==============================
// Equipe Low Head Possible IDS
//==============================
setarray .lhd0[1],  3,  4,  5,  6,  7,  8;
setarray .lhd1[1], 11, 12, 15, 16, 17, 18,
                   19, 20, 21, 22, 23, 24;
setarray .lhd2[1],164,165,167,168,168, 18;
setarray .lhd3[1],  3,  4,  5,  6,  7,  8,
                    1,  2, 11, 12, 16;
setarray .lhd5[1], 37, 39, 41, 43, 45, 47,
                   49, 51, 53, 55;			   
//==============================
// Equipe Armor Possible IDS
//==============================
setarray .arm0[1], 76, 77, 78, 79, 80, 81,
                   82, 83, 84, 85;
setarray .arm1[1],  9, 10, 11, 12, 20, 21;
setarray .arm2[1], 87, 88, 89, 90, 91, 92,
                   93, 94, 95, 96,107,108,
                  109,110,111,112,113,114,
                  115,116;
setarray .arm3[1],  3,  4,  5,  6,  7,  8,
                   21, 20;
setarray .arm5[1],186,167,160,161,162,165;
//==============================
// Equipe RHand Possible IDS
//==============================
setarray .rwp0[1],175,176,177,178,179,180,
                  181,182,183,184;
setarray .rwp1[1], 13, 18, 19, 15, 16, 24,
                    3,  4,  5,  6,  7,  8;
setarray .rwp2[1], 37, 39, 41, 43, 45, 47,
                   49, 51, 53, 55, 57, 59,
                   61, 63, 65, 67, 69, 71,
                   73, 75;
setarray .rwp3[1],147,148,151,152,153,154,
                  155,156,164,158,159,157;
setarray .rwp5[1],166,173,174,185,187,188,
                  189,117,118,119,120,121,
                  122,123,124,125,126;
//==============================
// Equipe LHand Possible IDS
//==============================
setarray .lwp0[1],  1,  2,  3,  4,  5,  6,
                    7,  8,  9, 10, 11, 12,
                   15, 16, 18, 20, 21, 22,
                   23, 24;				 
setarray .lwp1[1], 25, 26, 27, 28, 29, 30,
                   31, 32, 33, 34, 35;
setarray .lwp2[1], 87, 88, 89, 90, 91, 92,
                   93, 94, 95, 96;
setarray .lwp3[1],160,161,162,165,167,190,
                  191,192; 
setarray .lwp5[1],149,150,151,152, 11, 12;
//==============================
// Equipe Garment Possible IDS
//==============================
setarray .gar0[1],  1,  2,  3,  4,  5,  6,
                    7,  8,  9, 10, 11, 12,
                   13, 14, 15, 16, 17, 18,
                   19, 20, 21, 22, 23, 24;
setarray .gar1[1], 25, 26, 27, 28, 29, 30,
                   31, 32, 33, 34, 35;
setarray .gar2[1],117,118,119,120,121,122,
                  123,124,125,126;
setarray .gar3[1],127,128,129,130,131,132,
                  133,134,135,136,137,138,
                  139,140,141,142,143,144,
                  145,146,153,154,155,156;
setarray .gar5[1],163,165,167,190,191,192;
//==============================
// Equipe Shoes Possible IDS
//==============================
setarray .shs0[1],  1,  2,  3,  4,  5,  6,
                    7,  8,  9, 10, 11, 12,
                   13, 14, 15, 16, 17, 18,
                   19, 20, 21, 22, 23, 24;
setarray .shs1[1],187,188,189,157,158,159;
setarray .shs2[1],151,152,149,147;
setarray .shs3[1],100,101,102,103,104,105,
                  106,107,108,109,110,111,
                  112,113,114,115,116;
setarray .shs5[1], 37, 39, 41, 43, 45, 47,
                   49, 51, 53, 55, 57, 59,
                   61, 63, 65, 67, 69, 71,
                   73, 75;
//==============================
// Equipe RAccessory Possible IDS
//==============================
setarray .rac0[1],  3,  4,  5,  6,  7,  8;
setarray .rac1[1],  1,  2,  9, 10, 11, 12;
setarray .rac2[1], 15, 16, 18, 22, 23, 24;
setarray .rac3[1], 13, 14, 17, 19,166,163;
setarray .rac5[1],168,169,170,171,172,173,
                  174,117,118,119,120,121,
                  122,123,124,125,126;
//==============================
// Equipe LAcessory Possible IDS
//==============================
setarray .lac0[1],  3,  4,  5,  6,  7,  8;
setarray .lac1[1],  1,  2,  9, 10, 11, 12;
setarray .lac2[1], 15, 16, 18, 22, 23, 24;
setarray .lac3[1], 13, 14, 17, 19,166,163;
setarray .lac5[1],168,169,170,171,172,173,
                  174,117,118,119,120,121,
                  122,123,124,125,126;
//==============================
// FIM DAS CONFIGURAÇÕES DE ID
// PARA RANDOM Option
//==============================
end;                        

NPC:
disable_items;
	mes "[ Neight ]";
	mes "Olá jovem!";
	mes "Eu estou pesquisando uma";
	mes "forma de adicionar";
	mes "encantamentos ^FF0000aleatórios^000000";
	mes "em um equipamento.";
	next;
	mes "[ Neight ]";
	mes "Eu posso fazer qualquer um dos seus";
	mes "equipamentos mais fortes";
	mes "do que suas versões atuais...";
next;
mes "[ Neight ]";
	if(.moeda){
		mes "Por um preço de ^0000FF"+.preco+" Zeny^000000,";
		mes "e também","1x ^0000FF"+ getitemname(990) +"^000000","1x ^0000FF"+ getitemname(7041) +"^000000";
	} else {
		mes "Por um preço de ^0000FF"+.preco+" Cashpoints^000000,";
		mes "e também","1x ^0000FF"+ getitemname(990) +"^000000","1x ^0000FF"+ getitemname(7041) +"^000000";
	}	
	mes "Eu vou aplicar uma opção ^FF0000ALEATÓRIA^000000";
	mes "no seu equipamento";
	next;
	mes "[ Neight ]";
	mes "Eu esqueci de mencionar que";
	mes "há uma chance de ^FF0000"+.falha+"%^000000 ";
	mes "que o processo ^FF0000FALHE^000000";
	mes "e eu perca seu equipamento junto...";
	next;
	mes "[ Neight ]";
	mes "Você gostaria de arriscar";
	mes "encantar seu item com uma chance de";
	mes "^FF0000"+.falha+"%^000000 de ^FF0000Falhe^000000";
	mes "e perder seu equipamento?";
	next;
	if(select("Nem! Tô de boas...:^0000FFEu vou testar minha sorte! Encante meu equipamento!^000000")==1) goto OnCancel;
	mes "[ Neight ]";
	mes "Esplêndido!";
	mes "Este processo levará";
	mes "cerca de ^0000FF"+.espera+"^000000 segundos...";
	mes "Não mova um músculo enquanto";
	mes "eu encanto seu equipamento";
	close2;
	if(countitem(990) < 1 && countitem(7041) < 1)
		goto PriceFail;

	setarray .@eq[1], EQI_HEAD_TOP,EQI_HEAD_MID,EQI_HEAD_LOW,EQI_ARMOR,EQI_HAND_R,EQI_HAND_L,EQI_GARMENT,EQI_SHOES,EQI_ACC_R,EQI_ACC_L;
	for(set .@i,1; .@i<getarraysize(.@eq); set .@i,.@i+1){
		if(getequipisequiped(.@eq[.@i])){
			set .@menu$,.@menu$+F_getpositionname(.@eq[.@i])+" ~ [ " + getequipname(.@eq[.@i]) + " ]";
			set .@equipado,1;
		} set .@menu$,.@menu$+":";
	} set .@part,.@eq[select(.@menu$)];
	set .@val, rand(.valmin,.valmax);

	set .@indx,rand(.slotmax);
	if(!.sobrepor){
		if(getequiprandomoption(.@part,4,ROA_ID,getcharid(0))) set .@x4,4;
		if(getequiprandomoption(.@part,3,ROA_ID,getcharid(0))) set .@x3,3;
		if(getequiprandomoption(.@part,2,ROA_ID,getcharid(0))) set .@x2,2;
		if(getequiprandomoption(.@part,1,ROA_ID,getcharid(0))) set .@x1,1;
		if(getequiprandomoption(.@part,0,ROA_ID,getcharid(0))) set .@x0,0;
		if(.@indx == 0 && .@x0)
			if(.@indx==.slotmax) goto OnMax;
			else set .@indx,1;
		if(.@indx == 1 && .@x1)
			if(.@indx==.slotmax) goto OnMax;
			else set .@indx,2;
		if(.@indx == 2 && .@x2)
			if(.@indx==.slotmax) goto OnMax;
			else set .@indx,3;
		if(.@indx == 3 && .@x3)
			if(.@indx==.slotmax) goto OnMax;
			else set .@indx,4;
		if(.@indx == 4 && .@x4)
			if(.@indx==.slotmax) goto OnMax;
	}
	if(.@indx == 4 && (!getequiprandomoption(.@part,3,ROA_ID,getcharid(0)))) set .@indx,3;
	if(.@indx == 3 && (!getequiprandomoption(.@part,2,ROA_ID,getcharid(0)))) set .@indx,2;
	if(.@indx == 2 && (!getequiprandomoption(.@part,1,ROA_ID,getcharid(0)))) set .@indx,1;
	if(.@indx == 1 && (!getequiprandomoption(.@part,0,ROA_ID,getcharid(0)))) set .@indx,0;

	if(.@part == EQI_HEAD_TOP)
		goto THead;
	if(.@part == EQI_HEAD_MID)
		goto MHead;
	if(.@part == EQI_HEAD_LOW)
		goto LHead;
	if(.@part == EQI_ARMOR)
		goto Armor;
	if(.@part == EQI_HAND_R)
		goto RHand;
	if(.@part == EQI_HAND_L)
		goto LHand;
	if(.@part == EQI_GARMENT)
		goto Garment;
	if(.@part == EQI_SHOES)
		goto Shoes;
	if(.@part == EQI_ACC_R)
		goto RAcc;
	if(.@part == EQI_ACC_L)
		goto LAcc;	
THead:
	if(.@indx == 0)
	set .@opt,.thd0[rand(1,18)];
	if(.@indx == 1)
	set .@opt,.thd1[rand(1,11)];
	if(.@indx == 2)
	set .@opt,rand(.thd2);
	if(.@indx == 3)
	set .@opt,rand(.thd3);
	if(.@indx == 4)
	set .@opt,rand(.thd4);
MHead:
	if(.@indx == 0)
	set .@opt,rand(.mhd0);
	if(.@indx == 1)
	set .@opt,rand(.mhd1);
	if(.@indx == 2)
	set .@opt,rand(.mhd2);
	if(.@indx == 3)
	set .@opt,rand(.mhd3);
	if(.@indx == 4)
	set .@opt,rand(.mhd4);
LHead:
	if(.@indx == 0)
	set .@opt,rand(.lhd0);
	if(.@indx == 1)
	set .@opt,rand(.lhd1);
	if(.@indx == 2)
	set .@opt,rand(.lhd2);
	if(.@indx == 3)
	set .@opt,rand(.lhd3);
	if(.@indx == 4)
	set .@opt,rand(.lhd4);
Armor:
	if(.@indx == 0)
	set .@opt,rand(.arm0);
	if(.@indx == 1)
	set .@opt,rand(.arm1);
	if(.@indx == 2)
	set .@opt,rand(.arm2);
	if(.@indx == 3)
	set .@opt,rand(.arm3);
	if(.@indx == 4)
	set .@opt,rand(.arm4);
RHand:
	if(.@indx == 0)
	set .@opt,rand(.rwp0);
	if(.@indx == 1)
	set .@opt,rand(.rwp1);
	if(.@indx == 2)
	set .@opt,rand(.rwp2);
	if(.@indx == 3)
	set .@opt,rand(.rwp3);
	if(.@indx == 4)
	set .@opt,rand(.rwp4);
LHand:
	if(.@indx == 0)
	set .@opt,rand(.lwp0);
	if(.@indx == 1)
	set .@opt,rand(.lwp1);
	if(.@indx == 2)
	set .@opt,rand(.lwp2);
	if(.@indx == 3)
	set .@opt,rand(.lwp3);
	if(.@indx == 4)
	set .@opt,rand(.lwp4);
Garment:
	if(.@indx == 0)
	set .@opt,rand(.gar0);
	if(.@indx == 1)
	set .@opt,rand(.gar1);
	if(.@indx == 2)
	set .@opt,rand(.gar2);
	if(.@indx == 3)
	set .@opt,rand(.gar3);
	if(.@indx == 4)
	set .@opt,rand(.gar4);
Shoes:
	if(.@indx == 0)
	set .@opt,rand(.shs0);
	if(.@indx == 1)
	set .@opt,rand(.shs1);
	if(.@indx == 2)
	set .@opt,rand(.shs2);
	if(.@indx == 3)
	set .@opt,rand(.shs3);
	if(.@indx == 4)
	set .@opt,rand(.shs4);
RAcc:
	if(.@indx == 0)
	set .@opt,rand(.rac0);
	if(.@indx == 1)
	set .@opt,rand(.rac1);
	if(.@indx == 2)
	set .@opt,rand(.rac2);
	if(.@indx == 3)
	set .@opt,rand(.rac3);
	if(.@indx == 4)
	set .@opt,rand(.rac4);
LAcc:
	if(.@indx == 0)
	set .@opt,rand(.lac0);
	if(.@indx == 1)
	set .@opt,rand(.lac1);
	if(.@indx == 2)
	set .@opt,rand(.lac2);
	if(.@indx == 3)
	set .@opt,rand(.lac3);
	if(.@indx == 4)
	set .@opt,rand(.lac4);
	
	progressbar "ffff00",.espera;

	if(.moeda){
		if(Zeny < .preco)
			goto PriceFail;
		else
			set Zeny,Zeny-.preco;
			delitem 990,1;
			delitem 7041,1;
	} else {
		if(#CASHPOINTS < .preco)
			goto PriceFail;
		else	
			set #CASHPOINTS,#CASHPOINTS-.preco;
			delitem 990,1;
			delitem 7041,1;

	}
	
	// Falha...
	if(.falha > 100) set .falha,100;
	if(rand(100) <= .falha) goto OnFailure;

	// Sucesso!!
	specialeffect2 154;
	setrandomoption(.@part,.@indx,.@opt,.@val,.@indx,getcharid(0));
end;
	
	
OnMax:
	mes "[ Neight ]";
	mes "Ops... Seu equipamento ja";
	mes "foi encantado ao máximo!";
	mes " ";
	mes "Perdão, mas, não posso";
	mes "adicionar mais encantamentos";
	mes "ao seu item.";
close;

OnFailure:
specialeffect2 EF_PHARMACY_FAIL;
	mes "[ Neight ]"," ";
	mes "Me perdoe..."," ";
	mes "^FF0000O processo falhou...";
	mes "Seu item foi destruído.^000000";
	delequip .@part;
close;

PriceFail:
	mes "[ Neight ]";
	mes "O que e isso?";
	mes "Você está brincando comigo?";
	mes "Perdão, mas, eu não trabalho";
	mes "de graça!";
	mes "Você pode voltar quando";
	mes "tiver dinheiro para me pagar";
	mes "pelos meus serviços.";
close;

OnCancel:
	mes "[ Neight ]";
	mes "Vista-se.";
	mes "Deixe-me saber caso";
	mes "você mude de ideia";
close;
}

 

I really want to give credits for the person that created this script, used by me to create this one above, but, im really dont know who did it (if you are the owner or know him, pls contact me)

Original:

Spoiler

celestiaj,63,82,3	script	Neight	700,{
	goto NPC;
end;

OnInit:
//==============================
//	CURRENCY SETTING
//	1 = Zeny
//	0 = Cashpoints
//==============================
set .Currency,1;		// Currency to buy random option
set .Price,10000;	// Prize of random option
setarray .irq[0],990,7041; // Red Blood e Fine Grit
setarray .iqt[0],1,1; // Quantidade de cada item

//==============================
//	RANDOM OPTION SETTING
//==============================
	set .OverWrite,1;	// Allows overwriting the already existing option enchantment ( 0 to disable )
	set .FailRate,40;	// Sets fail chance
	set .MaxOpt,192;	// Maximum item option a player can enchant ( reference: https://github.com/rathena/rathena/blob/master/db/const.txt#L1645-L1836 )
	set .MinOpt,1;		// Minimum item option a player can enchant
	set .MinValue,1;	// Minimum option effect value
	set .MaxValue,10;	// Maximum option effect value
	set .MaxIndex,4;	// Maximum option slots ( default is 0 to 4 )
	set .Wait,1;		// Progress bar delay in seconds

	// Random option that will not be applied
	setarray .ignore[0],
		86,		// RDMOPT_BODY_ATTR_ALL
end;

NPC:
disable_items;
	mes "[ Neight ]";
	mes "Olá jovem!";
	mes "Eu estou pesquisando uma";
	mes "forma de adicionar";
	mes "encantamentos ^FF0000aleatórios^000000";
	mes "em um equipamento.";
	next;
	mes "[ Neight ]";
	mes "Eu posso fazer qualquer um dos seus";
	mes "equipamentos mais fortes";
	mes "do que suas versões atuais...";
next;
mes "[ Neight ]";
	if(.Currency){
		mes "Por um preço de ^0000FF"+.Price+" Zeny^000000,";
		mes "e também","1x ^0000FF"+ getitemname(990) +"^000000","1x ^0000FF"+ getitemname(7041) +"^000000";
	} else {
		mes "Por um preço de ^0000FF"+.Price+" Cashpoints^000000,";
		mes "e também","1x ^0000FF"+ getitemname(990) +"^000000","1x ^0000FF"+ getitemname(7041) +"^000000";
	}
	mes "Eu vou aplicar uma opção ^FF0000ALEATÓRIA^000000";
	mes "no seu equipamento";
	next;
	mes "[ Neight ]";
	mes "Eu esqueci de mencionar que";
	mes "há uma chance de ^FF0000"+.FailRate+"%^000000 ";
	mes "que o processo ^FF0000FALHE^000000";
	mes "e eu perca seu equipamento junto...";
	next;
	mes "[ Neight ]";
	mes "Você gostaria de arriscar";
	mes "encantar seu item com uma chance de";
	mes "^FF0000"+.FailRate+"%^000000 de ^FF0000Falhe^000000";
	mes "e perder seu equipamento?";
	next;
	if(select("Nem! Tô de boas...:^0000FFEu vou testar minha sorte! Encante meu equipamento!^000000")==1) goto OnCancel;
	mes "[ Neight ]";
	mes "Esplêndido!";
	mes "Este processo levará";
	mes "cerca de ^0000FF"+.Wait+"^000000 segundos...";
	mes "Não mova um músculo enquanto";
	mes "eu encanto seu equipamento";
	close2;
	if(countitem(990) < 1 && countitem(7041) < 1)
		goto PriceFail;
	
	setarray .@eq[1], EQI_HEAD_TOP,EQI_HEAD_MID,EQI_HEAD_LOW,EQI_ARMOR,EQI_HAND_R,EQI_HAND_L,EQI_GARMENT,EQI_SHOES,EQI_ACC_R,EQI_ACC_L;
	for(set .@i,1; .@i<getarraysize(.@eq); set .@i,.@i+1){
		if(getequipisequiped(.@eq[.@i])){
			set .@menu$,.@menu$+F_getpositionname(.@eq[.@i])+" ~ [ " + getequipname(.@eq[.@i]) + " ]";
			set .@equipped,1;
		} set .@menu$,.@menu$+":";
	} set .@part,.@eq[select(.@menu$)];

	set .@val,rand(.MinValue,.MaxValue);

IgnoreCheck:
	set .@opt,rand(.MinOpt,.MaxOpt);
	for(set .@f,1; .@f<getarraysize(.ignore); set .@f,.@f+1)
		if(.@opt==.ignore[.@f])
			goto IgnoreCheck;

	set .@indx,rand(.MaxIndex);
	if(!.OverWrite){
		if(getequiprandomoption(.@part,4,ROA_ID,getcharid(0))) set .@x4,4;
		if(getequiprandomoption(.@part,3,ROA_ID,getcharid(0))) set .@x3,3;
		if(getequiprandomoption(.@part,2,ROA_ID,getcharid(0))) set .@x2,2;
		if(getequiprandomoption(.@part,1,ROA_ID,getcharid(0))) set .@x1,1;
		if(getequiprandomoption(.@part,0,ROA_ID,getcharid(0))) set .@x0,0;

		if(.@indx == 0 && .@x0)
			if(.@indx==.MaxIndex) goto OnMax;
			else set .@indx,1;
		if(.@indx == 1 && .@x1)
			if(.@indx==.MaxIndex) goto OnMax;
			else set .@indx,2;
		if(.@indx == 2 && .@x2)
			if(.@indx==.MaxIndex) goto OnMax;
			else set .@indx,3;
		if(.@indx == 3 && .@x3)
			if(.@indx==.MaxIndex) goto OnMax;
			else set .@indx,4;
		if(.@indx == 4 && .@x4)
			if(.@indx==.MaxIndex) goto OnMax;
	}
	if(.@indx == 4 && (!getequiprandomoption(.@part,3,ROA_ID,getcharid(0)))) set .@indx,3;
	if(.@indx == 3 && (!getequiprandomoption(.@part,2,ROA_ID,getcharid(0)))) set .@indx,2;
	if(.@indx == 2 && (!getequiprandomoption(.@part,1,ROA_ID,getcharid(0)))) set .@indx,1;
	if(.@indx == 1 && (!getequiprandomoption(.@part,0,ROA_ID,getcharid(0)))) set .@indx,0;

	progressbar "ffff00",.Wait;

	if(.Currency){
		if(Zeny < .Price)
			goto PriceFail;
		else
			set Zeny,Zeny-.Price;
			delitem 990,1;
			delitem 7041,1;

	} else {
		if(#CASHPOINTS < .Price)
			goto PriceFail;
		else	
			set #CASHPOINTS,#CASHPOINTS-.Price;
			delitem 990,1;
			delitem 7041,1;

	}

	// Failed...
	if(.FailRate > 100) set .FailRate,100;
	if(rand(100) <= .FailRate) goto OnFailure;

	// Success!!
	specialeffect2 154;
	setrandomoption(.@part,.@indx,.@opt,.@val,.@indx,getcharid(0));
end;

OnMax:
	mes "[ Neight ]";
	mes "Ops... Seu equipamento ja";
	mes "foi encantado ao máximo!";
	mes " ";
	mes "Perdão, mas, não posso";
	mes "adicionar mais encantamentos";
	mes "ao seu item.";
close;

OnFailure:
specialeffect2 EF_PHARMACY_FAIL;
	mes "[ Neight ]"," ";
	mes "Me perdoe..."," ";
	mes "^FF0000O processo falhou...";
	mes "Seu item foi destruído.^000000";
	delequip .@part;
close;

PriceFail:
	mes "[ Neight ]";
	mes "O que e isso?";
	mes "Você está brincando comigo?";
	mes "Perdão, mas, eu não trabalho";
	mes "de graça!";
	mes "Você pode voltar quando";
	mes "tiver dinheiro para me pagar";
	mes "pelos meus serviços.";
close;

OnCancel:
	mes "[ Neight ]";
	mes "Vista-se.";
	mes "Deixe-me saber caso";
	mes "você mude de ideia";
close;
}

 

 

Now im looking for an way to optimize and solve the followying errors:
 

[Error]: buildin_setrandomoption: Random option ID 0 does not exists.

[Error]: buildin_disableitemuse: fatal error ! player not attached! - SOLVED

Edit: When the first error didnt happen, the item is enchanted, but, only with ID 1 and 2(MaxHP or MaxSP).

I dont know if i will get more errors after solve this ones.

Thx for all that read this topic!

Edited by Rizta
Solved the second buildin error
Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

You actually hit it right except for your understand with arrays.

for example:

set .@opt,rand(.mhd4);

this would be evaluated as rand(0) as .mhd is not a numerical value. thus:

.@opt = 0

so when .@opt is interpreted as an input value to setrandomoption

setrandomoption(.@part,.@indx,.@opt,.@val,.@indx,getcharid(0));

You will be expecting an error since option 0 does not exist at all.

image.png.3033c954552640c01a42ead76d1022bd.png

 

next example:

set .@opt,.thd0[rand(1,18)];

this will be interpreted as
let x = rand(1,18), let's say it randomed a value of 2
let .@opt = index 2 of array .thd0

since:

setarray .thd0[1], 13, 14, 11, 12, 16, 18,
                    3,  4,  5,  6,  7,  8,
                   20, 21, 22, 23, 24, 19;

.thd[2] = 14

I assume that you already understand why it is so and thus you know the difference between starting at .thd0[0] vs .thd0[1].

thus, .@opt = 14. and will be interpreted correctly by setrandomoption since option 14 exists.

TLDR;

your set .@opt statements should point to a random index of an array hence follow the pattern

THead:
	if(.@indx == 0)
	set .@opt,.thd0[rand(getarraysize(.thd0))];
	if(.@indx == 1)
	set .@opt,.thd1[rand(getarraysize(.thd1))];
	if(.@indx == 2)
	set .@opt,.thd2[rand(getarraysize(.thd2))];
	if(.@indx == 3)
	set .@opt,.thd3[rand(getarraysize(.thd3))];
	if(.@indx == 4)
	set .@opt,.thd4[rand(getarraysize(.thd4))];

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  109
  • Reputation:   5
  • Joined:  08/12/17
  • Last Seen:  

12 hours ago, Ninja said:

You actually hit it right except for your understand with arrays.

for example:


set .@opt,rand(.mhd4);

this would be evaluated as rand(0) as .mhd is not a numerical value. thus:

.@opt = 0

so when .@opt is interpreted as an input value to setrandomoption


setrandomoption(.@part,.@indx,.@opt,.@val,.@indx,getcharid(0));

You will be expecting an error since option 0 does not exist at all.

image.png.3033c954552640c01a42ead76d1022bd.png

 

next example:


set .@opt,.thd0[rand(1,18)];

this will be interpreted as
let x = rand(1,18), let's say it randomed a value of 2
let .@opt = index 2 of array .thd0

since:


setarray .thd0[1], 13, 14, 11, 12, 16, 18,
                    3,  4,  5,  6,  7,  8,
                   20, 21, 22, 23, 24, 19;

.thd[2] = 14

I assume that you already understand why it is so and thus you know the difference between starting at .thd0[0] vs .thd0[1].

thus, .@opt = 14. and will be interpreted correctly by setrandomoption since option 14 exists.

TLDR;

your set .@opt statements should point to a random index of an array hence follow the pattern


THead:
	if(.@indx == 0)
	set .@opt,.thd0[rand(getarraysize(.thd0))];
	if(.@indx == 1)
	set .@opt,.thd1[rand(getarraysize(.thd1))];
	if(.@indx == 2)
	set .@opt,.thd2[rand(getarraysize(.thd2))];
	if(.@indx == 3)
	set .@opt,.thd3[rand(getarraysize(.thd3))];
	if(.@indx == 4)
	set .@opt,.thd4[rand(getarraysize(.thd4))];

 

Oh, thanks a lot for helping me! In talk with @Stolao he give me the same answer and i do some modifications to the script. I still getting errors but atm i can enchant some slots(randomically). Let me post the actual code for you see.

 

Spoiler

//===== rAthena Script =======================================
//= Random Option SurviveRO
//===== By: ==================================================
//= Rizakh
//===== Current Version: =====================================
//= 1.0
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= Atribui opcoes aleatorias aos equipamentos.
//= com o custo de X zeny/cash
//============================================================
prontera,143,182,3	script	Piranha Safada	700,{
	goto NPC;
end;

OnInit:
//==============================
//	CONFIGURAÇÕES DE MOEDA
//	1 = Zeny
//	0 = Cashpoints
//==============================
set .moeda,1;		// Moeda para comprar a opcao aleatoria
set .preco,1;	// Preco da opcao aleatoria
//setarray .irq[0],990,7041; // Red Blood e Fine Grit
//setarray .iqt[0],1,1; // Quantidade de cada item
//==============================
//	CONFIGURAÇÕES RANDOM OPTION 
//==============================
	set .sobrepor,0;	// Permite sobrepor encantamentos existentes ( 0 = off )
	set .falha,0;		// Define a chance de falha (%)
	//set .MaxOpt,192;		// Maximum item option a player can enchant ( reference: https://github.com/rathena/rathena/blob/master/db/const.txt#L1645-L1836 )
	//set .MinOpt,1;		// Minimum item option a player can enchant
	set .valmin,1;	// Valor minimo a se tirar na opcao aleatoria
	set .valmax,5;	// Valor maximo a se tirar na opcao aleatoria
	set .slotmax,4;	// Maximo de slots para encantar( padrão = 0-4 )
	set .espera,1;		// Delay da barra de progresso em segundos
//============================
// IDS DAS RANDOM OPTIONS 
// SEPARADAS POR EQUIPAMENTOS 
// E SLOT (0 PARA 4 = 5 SLOTS)
//============================
//  Equip Top Head Possible IDS
//============================
setarray .thd0[1], 13, 14, 11, 12, 16, 18,
                    3,  4,  5,  6,  7,  8,
                   20, 21, 22, 23, 24, 19;
setarray .thd1[1], 25, 26, 27, 28, 29, 30,
                   31, 32, 33, 34, 35;
setarray .thd2[1],168,169,170,171,172,167;
setarray .thd3[1],  3,  4,  5,  6,  7,  8,
                   36, 38, 40, 42, 44, 46,
                   48, 50, 52, 54;
setarray .thd4[1],  3,  4,  5,  6,  7,  8,
                   56, 58, 60, 62, 64, 66,
                   68, 70, 72, 74;
//=============================
// Equip Mid Head Possible IDS
//=============================
setarray .mhd0[1],  3,  4,  5,  6,  7,  8;
setarray .mhd1[1], 87, 89, 90, 91, 92, 93,
                   94, 95, 96;
setarray .mhd2[1],168,169,170,171,172,167;
setarray .mhd3[1], 97, 98, 99,100,101,102,
                  103,104,105,106,107,108,
                  109,110,111,112,113,114,
                  115,116;
setarray .mhd4[1],  9, 10, 11, 12, 13, 14,
                   15, 16, 17, 18, 19, 20,
                   21, 22, 23, 24;
//==============================
// Equipe Low Head Possible IDS
//==============================
setarray .lhd0[1],  3,  4,  5,  6,  7,  8;
setarray .lhd1[1], 11, 12, 15, 16, 17, 18,
                   19, 20, 21, 22, 23, 24;
setarray .lhd2[1],164,165,167,168,168, 18;
setarray .lhd3[1],  3,  4,  5,  6,  7,  8,
                    1,  2, 11, 12, 16;
setarray .lhd5[1], 37, 39, 41, 43, 45, 47,
                   49, 51, 53, 55;			   
//==============================
// Equipe Armor Possible IDS
//==============================
setarray .arm0[1], 76, 77, 78, 79, 80, 81,
                   82, 83, 84, 85;
setarray .arm1[1],  9, 10, 11, 12, 20, 21;
setarray .arm2[1], 87, 88, 89, 90, 91, 92,
                   93, 94, 95, 96,107,108,
                  109,110,111,112,113,114,
                  115,116;
setarray .arm3[1],  3,  4,  5,  6,  7,  8,
                   21, 20;
setarray .arm5[1],186,167,160,161,162,165;
//==============================
// Equipe RHand Possible IDS
//==============================
setarray .rwp0[1],175,176,177,178,179,180,
                  181,182,183,184;
setarray .rwp1[1], 13, 18, 19, 15, 16, 24,
                    3,  4,  5,  6,  7,  8;
setarray .rwp2[1], 37, 39, 41, 43, 45, 47,
                   49, 51, 53, 55, 57, 59,
                   61, 63, 65, 67, 69, 71,
                   73, 75;
setarray .rwp3[1],147,148,151,152,153,154,
                  155,156,164,158,159,157;
setarray .rwp5[1],166,173,174,185,187,188,
                  189,117,118,119,120,121,
                  122,123,124,125,126;
//==============================
// Equipe LHand Possible IDS
//==============================
setarray .lwp0[1],  1,  2,  3,  4,  5,  6,
                    7,  8,  9, 10, 11, 12,
                   15, 16, 18, 20, 21, 22,
                   23, 24;				 
setarray .lwp1[1], 25, 26, 27, 28, 29, 30,
                   31, 32, 33, 34, 35;
setarray .lwp2[1], 87, 88, 89, 90, 91, 92,
                   93, 94, 95, 96;
setarray .lwp3[1],160,161,162,165,167,190,
                  191,192; 
setarray .lwp5[1],149,150,151,152, 11, 12;
//==============================
// Equipe Garment Possible IDS
//==============================
setarray .gar0[1],  1,  2,  3,  4,  5,  6,
                    7,  8,  9, 10, 11, 12,
                   13, 14, 15, 16, 17, 18,
                   19, 20, 21, 22, 23, 24;
setarray .gar1[1], 25, 26, 27, 28, 29, 30,
                   31, 32, 33, 34, 35;
setarray .gar2[1],117,118,119,120,121,122,
                  123,124,125,126;
setarray .gar3[1],127,128,129,130,131,132,
                  133,134,135,136,137,138,
                  139,140,141,142,143,144,
                  145,146,153,154,155,156;
setarray .gar5[1],163,165,167,190,191,192;
//==============================
// Equipe Shoes Possible IDS
//==============================
setarray .shs0[1],  1,  2,  3,  4,  5,  6,
                    7,  8,  9, 10, 11, 12,
                   13, 14, 15, 16, 17, 18,
                   19, 20, 21, 22, 23, 24;
setarray .shs1[1],187,188,189,157,158,159;
setarray .shs2[1],151,152,149,147;
setarray .shs3[1],100,101,102,103,104,105,
                  106,107,108,109,110,111,
                  112,113,114,115,116;
setarray .shs5[1], 37, 39, 41, 43, 45, 47,
                   49, 51, 53, 55, 57, 59,
                   61, 63, 65, 67, 69, 71,
                   73, 75;
//==============================
// Equipe RAccessory Possible IDS
//==============================
setarray .rac0[1],  3,  4,  5,  6,  7,  8;
setarray .rac1[1],  1,  2,  9, 10, 11, 12;
setarray .rac2[1], 15, 16, 18, 22, 23, 24;
setarray .rac3[1], 13, 14, 17, 19,166,163;
setarray .rac5[1],168,169,170,171,172,173,
                  174,117,118,119,120,121,
                  122,123,124,125,126;
//==============================
// Equipe LAcessory Possible IDS
//==============================
setarray .lac0[1],  3,  4,  5,  6,  7,  8;
setarray .lac1[1],  1,  2,  9, 10, 11, 12;
setarray .lac2[1], 15, 16, 18, 22, 23, 24;
setarray .lac3[1], 13, 14, 17, 19,166,163;
setarray .lac5[1],168,169,170,171,172,173,
                  174,117,118,119,120,121,
                  122,123,124,125,126;
//==============================
// Lista de ID's ignorados
//==============================
	//setarray .ignora[0],  0, 86;
//==============================
// FIM DAS CONFIGURAÇÕES DE ID
// PARA RANDOM Option
//==============================
end;                        

NPC:
disable_items;
	mes "[ Neight ]";
	mes "Olá jovem!";
	mes "Eu estou pesquisando uma";
	mes "forma de adicionar";
	mes "encantamentos ^FF0000aleatórios^000000";
	mes "em um equipamento.";
	next;
	mes "[ Neight ]";
	mes "Eu posso fazer qualquer um dos seus";
	mes "equipamentos mais fortes";
	mes "do que suas versões atuais...";
next;
mes "[ Neight ]";
	if(.moeda){
		mes "Por um preço de ^0000FF"+.preco+" Zeny^000000,";
		mes "e também","1x ^0000FF"+ getitemname(990) +"^000000","1x ^0000FF"+ getitemname(7041) +"^000000";
	} else {
		mes "Por um preço de ^0000FF"+.preco+" Cashpoints^000000,";
		mes "e também","1x ^0000FF"+ getitemname(990) +"^000000","1x ^0000FF"+ getitemname(7041) +"^000000";
	}	
	mes "Eu vou aplicar uma opção ^FF0000ALEATÓRIA^000000";
	mes "no seu equipamento";
	next;
	mes "[ Neight ]";
	mes "Eu esqueci de mencionar que";
	mes "há uma chance de ^FF0000"+.falha+"%^000000 ";
	mes "que o processo ^FF0000FALHE^000000";
	mes "e eu perca seu equipamento junto...";
	next;
	mes "[ Neight ]";
	mes "Você gostaria de arriscar";
	mes "encantar seu item com uma chance de";
	mes "^FF0000"+.falha+"%^000000 de ^FF0000Falhe^000000";
	mes "e perder seu equipamento?";
	next;
	if(select("Nem! Tô de boas...:^0000FFEu vou testar minha sorte! Encante meu equipamento!^000000")==1) goto OnCancel;
	mes "[ Neight ]";
	mes "Esplêndido!";
	mes "Este processo levará";
	mes "cerca de ^0000FF"+.espera+"^000000 segundos...";
	mes "Não mova um músculo enquanto";
	mes "eu encanto seu equipamento";
	close2;
	//if(countitem(990) < 1 && countitem(7041) < 1)
		//goto PriceFail;
	if(.moeda){
		if(Zeny < .preco)
			goto PriceFail;
		else
			set Zeny,Zeny-.preco;
			//delitem 990,1;
			//delitem 7041,1;
	} else {
		if(#CASHPOINTS < .preco)
			goto PriceFail;
		else	
			set #CASHPOINTS,#CASHPOINTS-.preco;
			delitem 990,1;
			delitem 7041,1;
	}		
		
	setarray .@eq[1], EQI_HEAD_TOP,EQI_HEAD_MID,EQI_HEAD_LOW,EQI_ARMOR,EQI_HAND_R,EQI_HAND_L,EQI_GARMENT,EQI_SHOES,EQI_ACC_R,EQI_ACC_L;
	for(set .@i,1; .@i<getarraysize(.@eq); set .@i,.@i+1){
		if(getequipisequiped(.@eq[.@i])){
			set .@menu$,.@menu$+F_getpositionname(.@eq[.@i])+" ~ [ " + getequipname(.@eq[.@i]) + " ]";
			set .@equipado,1;
		} set .@menu$,.@menu$+":";
	} set .@part,.@eq[select(.@menu$)];
	set .@val, rand(.valmin,.valmax);

	set .@indx,rand(.slotmax);

		if(.@part == EQI_HEAD_TOP)
			dispbottom .@indx+"";
			if(.@indx == 0)
			.@opt = .thd0[rand(getarraysize(.thd0))];
			if(.@indx == 1)
			.@opt = .thd1[rand(getarraysize(.thd1))];
			if(.@indx == 2)
			.@opt = .thd2[rand(getarraysize(.thd2))];
			if(.@indx == 3)
			.@opt = .thd3[rand(getarraysize(.thd3))];
			if(.@indx == 4)
			.@opt = .thd4[rand(getarraysize(.thd4))];
		if(.@part == EQI_HEAD_MID)
			dispbottom .@indx+"";
			if(.@indx == 0)
			.@opt = .mhd0[rand(getarraysize(.mhd0))];
			if(.@indx == 1)
			.@opt = .mhd1[rand(getarraysize(.mhd1))];
			if(.@indx == 2)
			.@opt = .mhd2[rand(getarraysize(.mhd2))];
			if(.@indx == 3)
			.@opt = .mhd3[rand(getarraysize(.mhd3))];
			if(.@indx == 4)
			.@opt = .mhd4[rand(getarraysize(.mhd4))];
		if(.@part == EQI_HEAD_LOW)
			dispbottom .@indx+"";
			if(.@indx == 0)
			.@opt = .lhd0[rand(getarraysize(.lhd0))];
			if(.@indx == 1)
			.@opt = .lhd1[rand(getarraysize(.lhd1))];
			if(.@indx == 2)
			.@opt = .lhd2[rand(getarraysize(.lhd2))];
			if(.@indx == 3)
			.@opt = .lhd3[rand(getarraysize(.lhd3))];
			if(.@indx == 4)
			.@opt = .lhd4[rand(getarraysize(.lhd4))];
		if(.@part == EQI_ARMOR)
			dispbottom .@indx+"";
			if(.@indx == 0)
			.@opt = .arm0[rand(getarraysize(.arm0))];
			if(.@indx == 1)
			.@opt = .arm1[rand(getarraysize(.arm1))];
			if(.@indx == 2)
			.@opt = .arm2[rand(getarraysize(.arm2))];
			if(.@indx == 3)
			.@opt = .arm3[rand(getarraysize(.arm3))];
			if(.@indx == 4)
			.@opt = .arm4[rand(getarraysize(.arm4))];
		if(.@part == EQI_HAND_R)
			dispbottom .@indx+"";
			if(.@indx == 0)
			.@opt = .rwp0[rand(getarraysize(.rwp0))];
			if(.@indx == 1)
			.@opt = .rwp1[rand(getarraysize(.rwp1))];
			if(.@indx == 2)
			.@opt = .rwp2[rand(getarraysize(.rwp2))];
			if(.@indx == 3)
			.@opt = .rwp3[rand(getarraysize(.rwp3))];
			if(.@indx == 4)
			.@opt = .rwp4[rand(getarraysize(.rwp4))];
		if(.@part == EQI_HAND_L)
			dispbottom .@indx+"";
			if(.@indx == 0)
			.@opt = .lwp0[rand(getarraysize(.lwp0))];
			if(.@indx == 1)
			.@opt = .lwp1[rand(getarraysize(.lwp1))];
			if(.@indx == 2)
			.@opt = .lwp2[rand(getarraysize(.lwp2))];
			if(.@indx == 3)
			.@opt = .lwp3[rand(getarraysize(.lwp3))];
			if(.@indx == 4)
			.@opt = .lwp4[rand(getarraysize(.lwp4))];
		if(.@part == EQI_GARMENT)
			dispbottom .@indx+"";
			if(.@indx == 0)
			.@opt = .gar0[rand(getarraysize(.gar0))];
			if(.@indx == 1)
			.@opt = .gar1[rand(getarraysize(.gar1))];
			if(.@indx == 2)
			.@opt = .gar2[rand(getarraysize(.gar2))];
			if(.@indx == 3)
			.@opt = .gar3[rand(getarraysize(.gar3))];
			if(.@indx == 4)
			.@opt = .gar4[rand(getarraysize(.gar4))];
		if(.@part == EQI_SHOES)
			dispbottom .@indx+"";
			if(.@indx == 0)
			.@opt = .shs0[rand(getarraysize(.shs0))];
			if(.@indx == 1)
			.@opt = .shs1[rand(getarraysize(.shs1))];
			if(.@indx == 2)
			.@opt = .shs2[rand(getarraysize(.shs2))];
			if(.@indx == 3)
			.@opt = .shs3[rand(getarraysize(.shs3))];
			if(.@indx == 4)
			.@opt = .shs4[rand(getarraysize(.shs4))];
		if(.@part == EQI_ACC_R)
			dispbottom .@indx+"";
			if(.@indx == 0)
			.@opt = .rac0[rand(getarraysize(.rac0))];
			if(.@indx == 1)
			.@opt = .rac1[rand(getarraysize(.rac1))];
			if(.@indx == 2)
			.@opt = .rac2[rand(getarraysize(.rac2))];
			if(.@indx == 3)
			.@opt = .rac3[rand(getarraysize(.rac3))];
			if(.@indx == 4)
			.@opt = .rac4[rand(getarraysize(.rac4))];
		if(.@part == EQI_ACC_L)
			dispbottom .@indx+"";
			if(.@indx == 0)
			.@opt = .lac0[rand(getarraysize(.lac0))];
			if(.@indx == 1)
			.@opt = .lac1[rand(getarraysize(.lac1))];
			if(.@indx == 2)
			.@opt = .lac2[rand(getarraysize(.lac2))];
			if(.@indx == 3)
			.@opt = .lac3[rand(getarraysize(.lac3))];
			if(.@indx == 4)
			.@opt = .lac4[rand(getarraysize(.lac4))];	
	
	progressbar "ffff00",.espera;
	
	// Falha...
	if(.falha > 100) set .falha,100;
	if(rand(100) <= .falha) goto OnFailure;

	// Sucesso!!
	specialeffect2 154;
	setrandomoption(.@part,.@indx,.@opt,.@val,.@indx,getcharid(0));
end;
	
	
OnMax:
	mes "[ Neight ]";
	mes "Ops... Seu equipamento ja";
	mes "foi encantado ao máximo!";
	mes " ";
	mes "Perdão, mas, não posso";
	mes "adicionar mais encantamentos";
	mes "ao seu item.";
close;

OnFailure:
specialeffect2 EF_PHARMACY_FAIL;
	mes "[ Neight ]"," ";
	mes "Me perdoe..."," ";
	mes "^FF0000O processo falhou...";
	mes "Seu item foi destruído.^000000";
	delequip .@part;
close;

PriceFail:
	mes "[ Neight ]";
	mes "O que e isso?";
	mes "Você está brincando comigo?";
	mes "Perdão, mas, eu não trabalho";
	mes "de graça!";
	mes "Você pode voltar quando";
	mes "tiver dinheiro para me pagar";
	mes "pelos meus serviços.";
close;

OnCancel:
	mes "[ Neight ]";
	mes "Vista-se.";
	mes "Deixe-me saber caso";
	mes "você mude de ideia";
close;
}	

 

I tried replace the numbers in array for constant full name and got the same errors. If you download and test script you'll see a strange behaviour for script.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

15 hours ago, Ninja said:

I assume that you already understand why it is so and thus you know the difference between starting at .thd0[0] vs .thd0[1].

*rand(<number>{,<number>});


This function returns a number ...
(if you specify one) ... randomly positioned between 0 and the number you specify -1.
(if you specify two) ... randomly positioned between the two numbers you specify.


rand(10)  would result in 0,1,2,3,4,5,6,7,8 or 9
rand(0,9) would result in 0,1,2,3,4,5,6,7,8 or 9
rand(2,5) would result in 2,3,4 or 5

these will prolly help you. To make the story short, try starting at index 0. Hence,

setarray .gar0[0],  1,  2,  3,  4,  5,  6,
                    7,  8,  9, 10, 11, 12,
                   13, 14, 15, 16, 17, 18,
                   19, 20, 21, 22, 23, 24;

because

.gar0[rand(getarraysize(.gar0))];

can still end up as .gar0[0] and will produce the same output as I've pointed out above

Edited by Ninja
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  109
  • Reputation:   5
  • Joined:  08/12/17
  • Last Seen:  

3 hours ago, Ninja said:

*rand(<number>{,<number>});


This function returns a number ...
(if you specify one) ... randomly positioned between 0 and the number you specify -1.
(if you specify two) ... randomly positioned between the two numbers you specify.


rand(10)  would result in 0,1,2,3,4,5,6,7,8 or 9
rand(0,9) would result in 0,1,2,3,4,5,6,7,8 or 9
rand(2,5) would result in 2,3,4 or 5

these will prolly help you. To make the story short, try starting at index 0. Hence,


setarray .gar0[0],  1,  2,  3,  4,  5,  6,
                    7,  8,  9, 10, 11, 12,
                   13, 14, 15, 16, 17, 18,
                   19, 20, 21, 22, 23, 24;

because


.gar0[rand(getarraysize(.gar0))];

can still end up as .gar0[0] and will produce the same output as I've pointed out above

So are you suggesting me to use rand(x,y) ? 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

5 hours ago, Rizta said:

So are you suggesting me to use rand(x,y) ? 

Ahh, no. I'm suggesting to change all your setarray lines to start at index 0. ?

Ex.

setarray .gar0[0]

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   341
  • Joined:  10/17/12
  • Last Seen:  

8 hours ago, Ninja said:

Ahh, no. I'm suggesting to change all your setarray lines to start at index 0. ?

Ex.

setarray .gar0[0]

I went over this in discord with him, he needed to fix that rand() and the index at least (assuming no other issues I don't see right away).

Also suggested using constant instead of int values for the options for readability.

 

I have a function in my git  for converting random options into a readable line btw, if you need it ever.

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

2 hours ago, Stolao said:

I went over this in discord with him, he needed to fix that rand() and the index at least (assuming no other issues I don't see right away).

Also suggested using constant instead of int values for the options for readability.

 

I have a function in my git  for converting random options into a readable line btw, if you need it ever.

Ayt. I guess this is good as done ?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  109
  • Reputation:   5
  • Joined:  08/12/17
  • Last Seen:  

On 8/22/2018 at 11:43 AM, Ninja said:

Ahh, no. I'm suggesting to change all your setarray lines to start at index 0. ?

Ex.

setarray .gar0[0]

Try it, same results.:/
 

On 8/22/2018 at 8:39 PM, Stolao said:

I went over this in discord with him, he needed to fix that rand() and the index at least (assuming no other issues I don't see right away).

Also suggested using constant instead of int values for the options for readability.

 

I have a function in my git  for converting random options into a readable line btw, if you need it ever.

Yes. I think ive changed everything at least 4x and everytime i get a different behavior from script. Currently have no idea of what to do or what change...

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  32
  • Topics Per Day:  0.02
  • Content Count:  71
  • Reputation:   0
  • Joined:  06/24/19
  • Last Seen:  

How can i put more than 4 slots? like 7 for exemple.

Link to comment
Share on other sites

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.

×
×
  • Create New...