function script F_MesItemInfo {
[email protected] = getarg(0);
[email protected]$ = getitemname(
[email protected]);
if (
[email protected]$ != "null") {
[email protected] = getitemslots(
[email protected]);
if (
[email protected])
[email protected]$ = sprintf("%s [%d]",
[email protected]$,
[email protected]);
}
else
[email protected]$ = "Unknown Item";
if (PACKETVER >= 20150729)
return sprintf("<ITEM>%s<INFO>%d</INFO></ITEM>",
[email protected]$,
[email protected]);
else if (PACKETVER >= 20130130)
return sprintf("<ITEMLINK>%s<INFO>%d</INFO></ITEMLINK>",
[email protected]$,
[email protected]);
else
return
[email protected]$;
}
//===== Hercules Script ======================================
//= Lotti Girl
//===== By: ==================================================
//= AnnieRuru
//===== Current Version: =====================================
//= 1.0
//===== Compatible With: =====================================
//= Hercules 2019-02-22
//===== Description: =========================================
//= Roll a lottery ticket and get some cool items
//= even if you get all the trash items, you still collecting points to buy in lotti shop
//===== Topic ================================================
//= http://herc.ws/board/topic/16579-lotti-girl/
//===== Additional Comments: =================================
//=
//============================================================
/*
create table lotti_rank (
char_id int(11),
name varchar(24),
lotti_point int(11),
primary key (char_id),
key (lotti_point)
) engine = innodb;
*/
prontera,155,180,5 script Lotti Girl 1_F_MARIA,{
goto L_talk;
OnInit:
// Announce to the server when player roll on a rare item
.rare_announcement = 1; // Default 1 : means any item with 0.00%~0.99%
// Amount of points gain for each roll
.lotti_points = 1;
// If the player choose to Roll Repeatedly, what is the maximum amount of Roll in the input
.max_roll = 100;
setarray .item,
Id_Lottery_Ticket, // Item ID requirement
1, // amount of the Item needed
0, // chance of not getting any items
// chance of getting the items
// <Item ID>, <amount>, <chance>
Apple, 10, 1000,
Red_Potion, 5, 50,
Orange_Potion, 4, 40,
Yellow_Potion, 3, 30,
White_Potion, 2, 20,
Blue_Potion, 1, 10;
setarray .itemshop,
// Item sold in the shop
// <Item ID>, <Lotti Points needed>
Red_Potion, 100,
Orange_Potion, 200,
Yellow_Potion, 300,
White_Potion, 400,
Blue_Potion, 500;
// =========================================================================================================
.size = getarraysize(.item);
for (
[email protected] = 2;
[email protected] < .size;
[email protected] += 3 )
.totalchance += .item[
[email protected]];
for (
[email protected] = 2;
[email protected] < .size;
[email protected] += 3 ) {
[email protected] = .item[
[email protected]] *10000 / .totalchance;
[email protected] =
[email protected] / 100;
[email protected]$ =
[email protected] % 100;
while ( getstrlen(
[email protected]$) < 2 )
[email protected]$ = insertchar(
[email protected]$, "0", 0);
.chance_display$[
[email protected]] =
[email protected] +"."+
[email protected]$ +"%";
if (
[email protected] < .rare_announcement )
.announce[
[email protected]] = true;
}
.shop_size = getarraysize(.itemshop);
npcshopdelitem "Lotti#hidden", 512;
for (
[email protected] = 0;
[email protected] < .shop_size;
[email protected] += 2 )
npcshopadditem "Lotti#hidden", .itemshop[
[email protected]], .itemshop[
[email protected] +1];
npcshopattach "Lotti#hidden";
.npcname$ = "["+ strnpcinfo(NPC_NAME) +"]";
end;
L_talk:
mes .npcname$;
mes "Hello, do you want to play lottery ?";
next;
switch( select( "Deal me in!", "More Information", "Lotti Shop", "Lotti Ranking" ) ) {
mes .npcname$;
case 1:
mesf "It costs %dx %s to play.", .item[1], F_MesItemInfo( .item[0] );
if ( countitem( .item[0] ) < .item[1] )
close;
next;
if ( select( "Play", "Roll Repeatedly" ) == 1 ) {
mes .npcname$;
while ( true ) {
mes "Here we go...";
mes " ";
[email protected] = rand(.totalchance);
for (
[email protected] = 2; (
[email protected] -= .item[
[email protected]] ) >= 0;
[email protected] += 3 );
if ( checkweight( .item[
[email protected] -2], .item[
[email protected] -1] ) == false ) {
mes "It appears you have overweight";
break;
}
delitem .item[0], .item[1];
if (
[email protected] == 2 )
mes "You get nothing...";
else {
mesf "You get %s%dx%s %s", F_MesColor(C_TEAL), .item[
[email protected] -1], F_MesColor(C_BLACK), F_MesItemInfo(.item[
[email protected] -2]);
getitem .item[
[email protected] -2], .item[
[email protected] -1];
if ( .announce[
[email protected]] )
announce sprintf( _$( "Lotti Girl: Player [%s] has roll on [%s](%s)" ), strcharinfo(0), getitemname(.item[
[email protected] -2]), .chance_display$[
[email protected]] ), bc_all, C_PINK;
}
lotti_points += .lotti_points;
query_sql "insert into lotti_rank values ( "+ getcharid(CHAR_ID_CHAR) +", '"+ escape_sql( strcharinfo(PC_NAME) ) +"', "+ .lotti_points +" ) on duplicate key update lotti_point = lotti_point + "+ .lotti_points;
mes " ";
mes "wanna try again ?";
next;
if ( select( "Yes", "No" ) == 2 ) break;
mes .npcname$;
if ( countitem( .item[0] ) < .item[1] ) {
mes " ";
mesf "It appears you have ran out of %s", F_MesItemInfo( .item[0] );
break;
}
}
}
else {
mes .npcname$;
mes "Input how many rounds to roll";
mesf "Currently you have %dx %s", countitem( .item[0] ), F_MesItemInfo( .item[0] );
next;
input
[email protected]_input, 1, min( countitem( .item[0] ) / .item[1], .max_roll );
mes .npcname$;
mesf "Are you sure you want to roll %d times ?",
[email protected]_input;
next;
if ( select( "Yes", "No" ) == 2 ) close;
mes .npcname$;
mes "Here we go...";
mes " ";
// freeloop true;
for (
[email protected] = 0;
[email protected] <
[email protected]_input;
[email protected] ) {
[email protected] = rand(.totalchance);
for (
[email protected] = 2; (
[email protected] -= .item[
[email protected]] ) >= 0;
[email protected] += 3 );
if ( checkweight( .item[
[email protected] -2], .item[
[email protected] -1] ) == false ) {
mes "It appears you have overweight";
break;
}
delitem .item[0], .item[1];
if (
[email protected] == 2 )
mes "You get nothing...";
else {
mesf "You get %s%dx%s %s", F_MesColor(C_TEAL), .item[
[email protected] -1], F_MesColor(C_BLACK), F_MesItemInfo(.item[
[email protected] -2]);
getitem .item[
[email protected] -2], .item[
[email protected] -1];
if ( .announce[
[email protected]] )
announce sprintf( _$( "Lotti Girl: Player [%s] has roll on [%s](%s)" ), strcharinfo(0), getitemname(.item[
[email protected] -2]), .chance_display$[
[email protected]] ), bc_all, C_PINK;
}
[email protected];
sleep2 1; // prevent lag the server
}
lotti_points += .lotti_points *
[email protected];
query_sql "insert into lotti_rank values ( "+ getcharid(CHAR_ID_CHAR) +", '"+ escape_sql( strcharinfo(PC_NAME) ) +"', "+ .lotti_points +" ) on duplicate key update lotti_point = lotti_point + "+( .lotti_points *
[email protected] );
mesf "Total roll : %d times.",
[email protected];
}
mes " ";
mes "Thank you for using Lotti service~";
close;
case 2:
freeloop true;
mesf "Item required: %s%dx%s %s", F_MesColor(C_TEAL), .item[1], F_MesColor(C_BLACK), F_MesItemInfo(.item[0]);
if ( .item[2] )
mesf "Chance to gain nothing : %s%s%s", F_MesColor(C_CHOCOLATE), .chance_display$[2], F_MesColor(C_BLACK);
mes "Possible gains:";
for (
[email protected] = 3;
[email protected] < .size;
[email protected] += 3 )
mesf "%s%dx%s %s (%s%s%s)", F_MesColor(C_TEAL), .item[
[email protected] +1], F_MesColor(C_BLACK), F_MesItemInfo(.item[
[email protected]]), F_MesColor(C_CHOCOLATE), .chance_display$[
[email protected] +2], F_MesColor(C_BLACK);
next;
mes .npcname$;
mesf "Each time you roll, will gain %d Lotti Points.", .lotti_points;
mes "Which can be use to buy rare items in Lotti Shop.";
close;
case 3:
mesf "You currently have %s Lotti Points.", lotti_points;
dispbottom sprintf( _$("You currently have %s Lotti Points."), lotti_points );
close2;
callshop "Lotti#hidden", 1;
end;
case 4:
[email protected]$ = "SELECT `name`, IF(@d=t.`lotti_point`, @r, @r:
[email protected]), @d:=t.`lotti_point`, @i:
[email protected]+1 ";
[email protected]$ += "FROM `lotti_rank` t, (SELECT @d:=0, @r:=0, @i:=1)q ";
[email protected]$ += "ORDER BY `lotti_point` DESC LIMIT 5";
[email protected] = query_sql(
[email protected]$,
[email protected]$,
[email protected],
[email protected],
[email protected]);
if (
[email protected] ) {
mes "There's no ranking yet ~";
close;
}
for (
[email protected] = 0;
[email protected] <
[email protected];
[email protected] )
mesf "%d. %s%s %s%d%s Points",
[email protected][
[email protected]], F_MesColor(C_TEAL),
[email protected]$[
[email protected]], F_MesColor(C_CHOCOLATE),
[email protected][
[email protected]], F_MesColor(C_BLACK);
mes " ";
if ( !query_sql( "SELECT `lotti_point`, 1+(SELECT COUNT(1) FROM `lotti_rank` t1 WHERE t1.lotti_point > t2.lotti_point) FROM `lotti_rank` t2 WHERE `char_id` = "+ getcharid(CHAR_ID_CHAR),
[email protected],
[email protected] ) ) {
mes "You are not in the rank.";
close;
}
mesf "Your current Point > %d",
[email protected];
mesf "Your current Rank > %d",
[email protected];
close;
}
end; // shouldn't reach
OnBuyItem:
mes .npcname$;
if (
[email protected]_quantity ) end;
if ( checkweight2( @bought_nameid, @bought_quantity ) == false ) {
mes "It appears you can't carry them all";
close;
}
[email protected] = getarraysize( @bought_nameid );
for (
[email protected] = 0;
[email protected] <
[email protected];
[email protected]++ ) {
for (
[email protected] = 0;
[email protected] < .shop_size;
[email protected] += 2 )
if ( @bought_nameid[
[email protected]] == .itemshop[
[email protected]] )
break;
[email protected] += .itemshop[
[email protected] +1] * @bought_quantity[
[email protected]];
}
if (
[email protected] > lotti_points ) {
mes "You don't have enough Lotti Points";
close;
}
lotti_points -=
[email protected];
for (
[email protected] = 0;
[email protected] <
[email protected];
[email protected] )
getitem @bought_nameid[
[email protected]], @bought_quantity[
[email protected]];
deletearray @bought_nameid;
deletearray @bought_quantity;
mes "Thanks for buying ~";
close;
}
- shop Lotti#hidden -1,512:1000
how to work this on rathena? error on mesf lines