Jump to content
  • 0

Help with Freebies


Yoona

Question


  • Group:  Members
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  567
  • Reputation:   18
  • Joined:  04/15/13
  • Last Seen:  

Now the error is in line 30 =(

post-16619-0-56643100-1373676219_thumb.jpg

Edited by Yoona
Link to comment
Share on other sites

8 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  90
  • Reputation:   5
  • Joined:  06/17/12
  • Last Seen:  


prontera,168,184,3<TAB>script<TAB>Freebies<TAB>479,{
mes .NPC$;
mes "Wanna get the freebies " +strcharinfo(0)+ "?";
next;
if (select("Yes:No") - 1) close;
mes .NPC$;
mes "Let me check if you are really a new member";
next;

query_sql("SELECT last_ip FROM `login` WHERE account_id = "+getcharid(3)+"", .@lastip);
query_sql("SELECT last_ip, account_id FROM `freebies`", .@freebiesip, .@accid);

if (.@lastip == .@freebiesip) || (.@accid == getcharid(3))
{
mes .NPC$;
mes "You already got the freebies " +strcharinfo(0);
end;
}

mes .NPC$; mes "Okay, take these...";
next;

query_sql("INSERT INTO `freebies` VALUES (NULL," + getcharid(3) + ",'" + escape_sql(strcharinfo(0)) + "','" + escape_sql(getcharip()) + "')"); for ( set .@x,0; .@x < getarraysize(.freebie_item); set .@x,.@x + 1 )
{
getitem .freebie_item[.@x], .quantity[.@x];
}
end; 

OnInit:
set .NPC$, "[ " +strnpcinfo(1)+ " ]";
.freebie_item[0],30316,30315,30314,30027,30028,30029,30030,4302,4403,7227,30499,671,2629,2630,4140; setarray .quantity[0],1,1,1,1,1,1,1,1,1,1000,1,1000,2,2,4; waitingroom "Freebies Here",0;
end;
}

 

It duplicates because you dont have an account ID check. it wont really insert not unless you'll use "update".
 
I assume that your player have changed IP, so he/she was able to get another freebie item, unfortunately, his/her account_id was already registered. That's why it produced an error for duplicating  an existing row using the account id which is your freebie's primary key.
 
And also try this sql
 
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(15) NOT NULL,
  PRIMARY KEY (`account_id`),
  KEY (`id`)
) ENGINE=MyISAM;

--------------------------------------------------------------------------------------------------------

 

And BTW, this:

query_sql("INSERT INTO `freebies` VALUES (NULL," + getcharid(3) + ",'" + escape_sql(strcharinfo(0)) + "','" + .@lastip + "')"); 

will only save the first numbers before the period. Like for example "127.0.0.1", it will only save "127"

 

So I Suggest you to use this instead:

query_sql("INSERT INTO `freebies` VALUES (NULL," + getcharid(3) + ",'" + escape_sql(strcharinfo(0)) + "','" + escape_sql(getcharip()) + "')");
Edited by KoolKat29
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  567
  • Reputation:   18
  • Joined:  04/15/13
  • Last Seen:  


prontera,168,184,3    script    Freebies    479,{
    mes .NPC$;
    mes "Wanna get the freebies " +strcharinfo(0)+ "?";
    next;
    if (select("Yes:No") - 1) close;
    mes .NPC$;
    mes "Let me check if you are really a new member";
    next;
    query_sql("SELECT last_ip, account_id FROM `login` WHERE account_id = "+getcharid(3)+"", .@lastip,.@accid);
    query_sql("SELECT last_ip FROM `freebies`", .@freebiesip);
    if (.@lastip == .@freebiesip && .@accid == getcharid(3))
    {
            mes .NPC$;
            mes "You already got the freebies " +strcharinfo(0);
            close;
    }
    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;
    
    OnInit:
    set .NPC$, "[ " +strnpcinfo(1)+ " ]";
    .freebie_item[0],30316,30315,30314,30027,30028,30029,30030,4302,4403,7227,30499,671,2629,2630,4140;
    setarray .quantity[0],1,1,1,1,1,1,1,1,1,1000,1,1000,2,2,4;
    waitingroom "Freebies Here",0;
    end;
}

 

It duplicates because you dont have an account ID check. it wont really insert not unless you'll use "update".
 
I assume that your player have changed IP, so he/she was able to get another freebie item, unfortunately, his/her account_id was already registered. That's why it produced an error for duplicating  an existing row using the account id which is your freebie's primary key.
 
And also try this sql
 
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(15) NOT NULL,
  PRIMARY KEY (`account_id`),
  KEY (`id`)
) ENGINE=MyISAM;

 

edit:

sorry... change this

if (.@lastip == .@freebiesip && .@accid == getcharid(3))

to this:

if (.@lastip == .@freebiesip || .@accid == getcharid(3))

i got an error at line 26?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  90
  • Reputation:   5
  • Joined:  06/17/12
  • Last Seen:  

please post your script. :D

 

or try this, because the above post is quite messy XD

prontera,168,184,3	script	Freebies	479,{
    mes .NPC$;
    mes "Wanna get the freebies " +strcharinfo(0)+ "?";
    next;
    if (select("Yes:No") - 1) close;
    mes .NPC$;
    mes "Let me check if you are really a new member";
    next;

    query_sql("SELECT last_ip FROM `login` WHERE account_id = "+getcharid(3)+"", .@lastip);
    query_sql("SELECT last_ip, account_id FROM `freebies`", .@freebiesip, .@accid);

    if (.@lastip == .@freebiesip) || (.@accid == getcharid(3))
    {
            mes .NPC$;
            mes "You already got the freebies " +strcharinfo(0);
            end;
    }

mes .NPC$; mes "Okay, take these...";
next;

query_sql("INSERT INTO `freebies` VALUES (NULL," + getcharid(3) + ",'" + escape_sql(strcharinfo(0)) + "','" + escape_sql(getcharip()) + "')");

for ( set .@x,0; .@x < getarraysize(.freebie_item); set .@x,.@x + 1 )
     {
     getitem .freebie_item[.@x], .quantity[.@x];
     }
end; 

OnInit:
set .NPC$, "[ " +strnpcinfo(1)+ " ]";
setarray .freebie_item[0],30316,30315,30314,30027,30028,30029,30030,4302,4403,7227,30499,671,2629,2630,4140;
setarray .quantity[0],1,1,1,1,1,1,1,1,1,1000,1,1000,2,2,4; waitingroom "Freebies Here",0;
end;
} 

 

 

Edited by KoolKat29
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  567
  • Reputation:   18
  • Joined:  04/15/13
  • Last Seen:  

please post your script. :D

 

or try this, because the above post is quite messy XD

 

prontera,168,184,3 script Freebies 479,{
    mes .NPC$;
    mes "Wanna get the freebies " +strcharinfo(0)+ "?";
	next;
    if (select("Yes:No") - 1) close;
    mes .NPC$;
    mes "Let me check if you are really a new member";
    next;
    query_sql("SELECT last_ip, account_id FROM `login` WHERE account_id = "+getcharid(3)+"", .@lastip,.@accid);
    query_sql("SELECT last_ip FROM `freebies`", .@freebiesip);
    if (.@lastip == .@freebiesip || .@accid == getcharid(3))
	{
            mes .NPC$;
            mes "You already got the freebies " +strcharinfo(0);
            end;
    }
    mes .NPC$;
    mes "Okay, take these...";
    next;
    query_sql("INSERT INTO `freebies` VALUES (NULL," + getcharid(3) + ",'" + escape_sql(strcharinfo(0)) + "','" + escape_sql(getcharip()) + "')");
    
     for ( set .@x,0; .@x < getarraysize(.freebie_item); set .@x,.@x + 1 )
       {
       getitem .freebie_item[.@x], .quantity[.@x];
       }
    end;
    
    OnInit:
    set .NPC$, "[ " +strnpcinfo(1)+ " ]";
    .freebie_item[0],30316,30315,30314,30027,30028,30029,30030,4302,4403,7227,30499,671,2629,2630,4140;
    setarray .quantity[0],1,1,1,1,1,1,1,1,1,1000,1,1000,2,2,4;
    waitingroom "Freebies Here",0;
    end;
}

now its error in line 30 =( it says

 

" parse_line: expect command, missing function name or calling undeclared dunction "

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  90
  • Reputation:   5
  • Joined:  06/17/12
  • Last Seen:  

yoona Yes, I've modified it again. I forgot and I've edited this part :

 query_sql("SELECT last_ip FROM `login` WHERE account_id = "+getcharid(3)+"", .@lastip);
    query_sql("SELECT last_ip, account_id FROM `freebies`", .@freebiesip, .@accid);
 
    if (.@lastip == .@freebiesip) || (.@accid == getcharid(3))


You can try the above post again. 

Edited by KoolKat29
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  567
  • Reputation:   18
  • Joined:  04/15/13
  • Last Seen:  

yoona Yes, I've modified it again. I forgot and I've edited this part :

 query_sql("SELECT last_ip FROM `login` WHERE account_id = "+getcharid(3)+"", .@lastip);
    query_sql("SELECT last_ip, account_id FROM `freebies`", .@freebiesip, .@accid);
 
    if (.@lastip == .@freebiesip) || (.@accid == getcharid(3))

You can try the above post again. 

still the same error =( 

 

" parse_line: expect command, missing function name or calling undeclared function "

Edited by Yoona
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  90
  • Reputation:   5
  • Joined:  06/17/12
  • Last Seen:  

http://pastebin.com/KwmTHpTd

 

 

I just forgot to put back the setarray for your item list. 

Edited by KoolKat29
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  79
  • Topics Per Day:  0.02
  • Content Count:  327
  • Reputation:   4
  • Joined:  06/22/13
  • Last Seen:  

Now the error is in line 30 =(

try this one, im using it and is working very good, easy to edit and it will give freebies only once per account:

//============================================
//= Npc that gives freebies to the new
//============================================
//= Rewritten by SkittleNugget (rAthena.org)
//============================================
prontera,146,161,6	script	Novice Support	893,{

    if( #PlayerRecievedFreebies )
	{
		mes "[Lisa]";
		emotion	e_swt2;
		mes "You already claimed your free items or you are not a novice anymore, Remember that i'll give you some free stuffs only once per account!";
		close;
	}
		else if ( Class < 1 )
	{
		mes "[Lisa]";
		emotion	e_ho;
		mes "Hello young adventurer and welcome to Kyojin RO";
		mes "I can give you some free items to help you grown fast";
		mes "Do you want it?";
		next;
		if ( select("You're so kind. Thank you!:Nah~ Im too pro for this!")==2)
		{
			mes "[Lisa]";
			emotion	e_ag;
			mes "Such a arrogant person.";
			mes "^ff0000@kill "+ strcharinfo(0) +"^000000";
			next;
			mes "[Lisa]";
			emotion	e_omg;
			mes "Why my command not work?!";
			mes "Maybe you're lucky!";
			close;
		}
		mes "[Lisa]";
		emotion	e_kis;
		mes "Please take this item and have a nice day~";
		next;
		getitem	504,30;	//White Potion
		getitem	645,25;	//Concentration potion
		getitem	14533,4;	//Field Manual
		getitem	14232,10;	//ygg berry box(10)
		getitem	4142,1;	//Doppelganger Card
		set #PlayerRecievedFreebies, 1;
		mes "See you soon~";
		close;
	}
}
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...