So I have this NPC and it's working properly on my Test Server.
But when I tried using it on my online server it didn't work as much as I expected.
It still gives freebies when they already got it. But it records all of the transactions that's happening to him in the SQL.
It is a modified version of this.
SCRIPT CORE:
poring_w02,89,81,6 script Freebies NPC 100,{
mes "[ ^FF0000Administrator Helper^000000 ]";
mes "Welcome to Ragnarok Online.";
next;
switch(select("~ How to claim Beginner Rewards:~ I have the items:~ Cancel")){
Case 1:
mes "[ ^FF0000Administrator Helper^000000 ]";
mes "To claim your Beginner Rewards.";
mes "Gather the following items:";
mes "^FF000015 ^000000"+getitemname(4001);
mes "^FF000015 ^000000"+getitemname(4037);
mes "^FF000015 ^000000"+getitemname(4074);
mes "^FF000010 ^000000"+getitemname(4275);
mes "^FF000010 ^000000"+getitemname(4268);
mes "^FF000010 ^000000"+getitemname(4194);
mes "^FF0000150 ^000000"+getitemname(4129);
mes "^FF00003 ^000000"+getitemname(4147);
mes "^FF00001 ^000000"+getitemname(4305);
close;
Case 2:
query_sql("SELECT last_ip FROM `login` WHERE account_id = "+getcharid(3)+"", .@lastip$);
query_sql("SELECT last_ip FROM `freebies`", .@freebiesip$);
if (.@lastip$ == .@freebiesip$) {
mes "[ ^FF0000Administrator Helper^000000 ]";
mes "Sorry, but you've already received your ^43572FBeginner Rewards^000000.";
close;
} else {
mes "[ ^FF0000Administrator Helper^000000 ]";
mes "Let me see if you have gathered all the following items.";
mes "^FF000015 ^000000"+getitemname(4001);
mes "^FF000015 ^000000"+getitemname(4037);
mes "^FF000015 ^000000"+getitemname(4074);
mes "^FF000010 ^000000"+getitemname(4275);
mes "^FF000010 ^000000"+getitemname(4268);
mes "^FF000010 ^000000"+getitemname(4194);
mes "^FF0000150 ^000000"+getitemname(4129);
mes "^FF00003 ^000000"+getitemname(4147);
mes "^FF00001 ^000000"+getitemname(4305);
next;
if(countitem(4001) < 15) goto L_NoItem;
if(countitem(4037) < 15) goto L_NoItem;
if(countitem(4074) < 15) goto L_NoItem;
if(countitem(4275) < 10) goto L_NoItem;
if(countitem(4268) < 10) goto L_NoItem;
if(countitem(4194) < 10) goto L_NoItem;
if(countitem(4129) < 150) goto L_NoItem;
if(countitem(4147) < 3) goto L_NoItem;
if(countitem(4305) < 1) goto L_NoItem;
mes "[ ^FF0000Administrator Helper^000000 ]";
mes "It seems you've gathered all the items!";
mes "Here's your ^43572FBeginner Rewards^000000.";
delitem 4001,15;
delitem 4037,15;
delitem 4074,15;
delitem 4275,10;
delitem 4268,10;
delitem 4194,10;
delitem 4129,150;
delitem 4147,3;
delitem 4305,1;
query_sql("INSERT INTO `freebies` VALUES (NULL," + getcharid(3) + ",'" + escape_sql(strcharinfo(0)) + "','" + .@lastip$ + "')");
for ( set .@x,0; .@x < getarraysize(.freebie_item); set .@x,.@x + 1 ) {
getitem .freebie_item[.@x], .quantity[.@x];
}
}
close;
L_NoItem:
mes "You don't have:";
if(countitem(4001) < 15) mes "^FF0000"+(15 - countitem(4001)) +"^000000 "+getitemname(4001);
if(countitem(4037) < 15) mes "^FF0000"+(15 - countitem(4037)) +"^000000 "+getitemname(4037);
if(countitem(4074) < 15) mes "^FF0000"+(15 - countitem(4074)) +"^000000 "+getitemname(4074);
if(countitem(4275) < 10) mes "^FF0000"+(10 - countitem(4275)) +"^000000 "+getitemname(4275);
if(countitem(4268) < 10) mes "^FF0000"+(10 - countitem(4268)) +"^000000 "+getitemname(4268);
if(countitem(4194) < 10) mes "^FF0000"+(10 - countitem(4194)) +"^000000 "+getitemname(4194);
if(countitem(4129) < 150) mes "^FF0000"+(150 - countitem(4129)) +"^000000 "+getitemname(4129);
if(countitem(4147) < 3) mes "^FF0000"+(3 - countitem(4147)) +"^000000 "+getitemname(4147);
if(countitem(4305) < 1) mes "^FF0000"+(1 - countitem(4305)) +"^000000 "+getitemname(4305);
close;
Case 3:
close;
}
OnInit:
setarray .freebie_item[0],2357,2524,2421,2115,40138,7776;
setarray .quantity[0],2,2,2,3,3,10;
}
SQL CODE:
CREATE TABLE IF NOT EXISTS `freebies` (
`id` int(11) NOT NULL auto_increment,
`account_id` int(11) NOT NULL default '0',
`name` varchar(23) NOT NULL default '',
`last_ip` varchar(100) NOT NULL default '',
PRIMARY KEY (`account_id`),
KEY (`id`)
) ENGINE=MyISAM;