/*
CREATE TABLE IF NOT EXISTS `rebirth_system` (
`char_id` int(11) unsigned NOT NULL default '0',
`name` varchar(24) NOT NULL DEFAULT 'NULL',
`num_rebirth` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`char_id`)
) ENGINE=MyISAM;
*/
prontera,150,150,5 script Rebirth System 866,{
function checkItem; // check if player have all item required
function colorItemrequired; // color the text. Red : not enough item, green otherwise
function deleteItem; // delete all items required
function displayItemneed; // display all items need at start
function getItemReward; // give the items reward
function weightreq; // check if your current weight is highter than weight high novice
mes "^11E6D0[Rebirth System]^000000";
mes strcharinfo(0)+", How may I help you?";
switch( select( "^777777~ Ranking", "~ Rebirth", "~ Information", "~ Cancel^000000" ) ) {
case 1:
query_sql "SELECT `name`,`num_rebirth` FROM `rebirth_system` ORDER BY `num_rebirth` DESC LIMIT "+.list,@name$,@num_rebirth;
if(getarraysize(@name$)==0){mes "^F20808 No Records Found ^000000"; close;}
mes "Format:";
mes "^0814F2[Character Name]^000000 - ^B308F2[Rebirths]^000000";
for (.@i=0; .@i < getarraysize(@name$); .@i++){
mes (.@i+1) +".) ^0814F2["+ @name$[.@i] +"]^000000 - ^B308F2["+ @num_rebirth[.@i] +"]^000000";
}
deletearray @name$[0],.list; deletearray @num_rebirth[0],.list;
close;
case 2:
set .@eac,eaclass();
if( NextJobExp || NextBaseExp || !( .@eac&(.job_rebirth) ) || !Upper ) {
mes "You must be Max BaselLevel/Joblevel to Rebirth.";
close;
}
mes "Items need :";
displayItemneed();
next;
mes "^11E6D0[Rebirth System]^000000";
weightreq();
checkItem();
deleteItem();
break;
case 3:
switch(.reset_opt){
case 1:
mes "Your BaseLevel,JobLevel,Skills,StatPoints,Stats will be Reset.";
break;
case 2:
mes "Your BaseLevel,JobLevel And SkillPoints will be Reset.";
break;
case 3:
mes "You will be Changed to BaseLevel 1 with JobLevel and Skills/Stats Unaffected, For Rebirth, you will need some items.";
break;
case 4:
mes "You will be Changed to JobLevel 1 with BaseLevel and Skills/Stats Unaffected";
break;
}
mes "For Rebirth, you may need some items.";
close;
case 4:
mes "Bye.";
close;
}
set num_rebirth,num_rebirth+1;
resetlvl(.reset_opt);
getItemReward();
query_sql "INSERT INTO `rebirth_system` (`char_id`,`name`,`num_rebirth`) VALUES ("+getcharid(0)+",'"+strcharinfo(0)+"',"+num_rebirth+") ON DUPLICATE KEY UPDATE `num_rebirth`="+num_rebirth+"";
mes "You have taken Rebirth.";
announce "[ Rebirth system ] : "+ strcharinfo(0) +" rebirth for the "+ num_rebirth +" time !", 0;
close;
function checkItem {
for (set .@i,0 ; .@i < .size_item; set .@i,.@i+2 ){
if ( countitem( .item_req[.@i] ) < .item_req[ .@i+1 ] ) {
mes "You don't have enough ^E6DB11"+ getitemname( .item_req[.@i] ) +"^000000. ^ff0000["+ countitem( .item_req[.@i] ) +"/"+ ( .item_req[ .@i+1 ] ) +"]^000000";
close;
}
}
return;
}
function colorItemrequired {
if ( countitem( .item_req[ getarg(0) ] ) < .item_req[ getarg(0)+1 ] ) return "^ff0000";
return "^00ff00";
}
function deleteItem {
for (set .@i,0 ; .@i < .size_item; set .@i,.@i+2 ){
delitem .item_req[.@i], ( .item_req[ .@i+1 ] );
}
return;
}
function displayItemneed {
for (set .@i,0 ; .@i < .size_item; set .@i,.@i+2 ){
mes colorItemrequired( .@i ) +" - x"+ ( .item_req[ .@i+1 ] ) +" "+ getitemname( .item_req[.@i] );
}
return;
}
function getItemReward {
for (set .@i,0 ; .@i < .size_reward; set .@i,.@i+3 ){
if (rand(1,10000) <= .reward[.@i+2]){
getitem .reward[.@i], .reward[ .@i+1 ];
}
}
return;
}
function weightreq {
if ( Weight > 20000 ) {
mes "You have too much items on you. Your weight will be too high after rebirth.";
close;
}
return;
}
OnInit:
// item required <item ID>, <number>
setarray .item_req, 501, 5,
502, 2,
503, 3;
set .size_item,getarraysize( .item_req );
// rewards <item ID>, <quantity>,<chance(10000=100%)>
// recalculates the chance and gives the next reward if chance is met.
setarray .reward, 504, 1, 10000,
501, 5, 10000;
set .size_reward,getarraysize( .reward );
set .list,10; //Show Top x in Ranking
set .job_rebirth,EAJL_THIRD; //EAJL_THIRD = Third Job, EAJL_2 = Second Job, (EAJL_2&EAJL_THIRD) = Second and Third job can rebirth.
//More Options [EAJL_2_1,EAJL_2_2,EAJL_UPPER,EAJL_BABY]
set .reset_opt,3; //(1=Reset Base and JobLevel to 1(0 skill points and all stats to 1),2=Reset Base and JobLevel to 1(SkillPoint=0, While Skills and stats are not affected),3=Reset BaseLevel to 1, 4=Reset Job Level to 1)
query_sql "CREATE TABLE IF NOT EXISTS `rebirth_system` ( `char_id` int(11) unsigned NOT NULL default '0', `name` varchar(24) NOT NULL DEFAULT 'NULL', `num_rebirth` int(11) unsigned NOT NULL default '0', PRIMARY KEY (`char_id`)) ENGINE=MyISAM";
end;
}