Jump to content
  • 0

New freebie NPC


zmref

Question


  • Group:  Members
  • Topic Count:  148
  • Topics Per Day:  0.03
  • Content Count:  299
  • Reputation:   6
  • Joined:  06/14/12
  • Last Seen:  

Hi!, I'm requesting for, a dynamic and user-friendly freebie NPC that is capable of doing the following:

Steps:

1.) mes "Hello <code for name of the char>, as of now I'll give you this ff items:"

2.) gives some item/s or rents some item/s

3.) mes "upon reaching this level, <level> you can get your surprise item"

gives additional items when reach a certain base lvl (ex. Base lvl 70)

4.) for account based only

5.) with display "Freebie NPC" above their head like a Chatroom.

Hoping for the correct scripts.

Thank you in advance

Edited by zmref
  • Upvote 1
Link to comment
Share on other sites

12 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  21
  • Reputation:   0
  • Joined:  04/02/12
  • Last Seen:  

prontera.gat,149,180,5 script Freebie NPC 753,{
if(#itemreceived == 1) && (Baselevel < 70) goto Lhaveitem1;
else if(#itemreveived == 1) && (BaseLevel >= 70) goto Lhaveitem2;
else if(#itemreceived == 2) goto Lhaveitem3;
mes "[Freebie NPC]";
mes "Hello "+strcharinfo(0)+", you can have this free item.";
getitem 501,10;
next;
set #itemreceived, 1;
mes "[Freebie NPC]";
mes "Come back when you are level 70 and you will get a special item.";
close;
Lhaveitem1:
mes "[Freebie NPC]";
mes "You have already received this item, please come back when you are level 70 for a special item.";
close;
Lhaveitem2:
mes "[Freebie NPC]";
mes "Are you ready to receive your special item?";
menu "Yes",-,"Double Yes!",-;
getitem 502,10;
next;
mes "[Freebie NPC]";
mes "Hope you enjoy!";
set #itemreceived, 2;
close;
Lhaveitem3:
mes "[Freebie NPC]";
mes "Sorry, I don't have anymore items to give you!";
close;
OnInit:
waitingroom "Free items!",0;
end;
}

You'll have to excuse me, my scripting is a bit rusty. I tested it and I think this is exactly what you are looking for.

I have it set to give the second item once the character is base level 70 or higher. You can edit the level and the rewards to your liking.

Let me know if it's what you were looking for!

DT

Edited by DarkTakeshi
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  177
  • Reputation:   9
  • Joined:  06/25/12
  • Last Seen:  

i used your script, but the npc keeps on giving me the items.. what should i do

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  21
  • Reputation:   0
  • Joined:  04/02/12
  • Last Seen:  

Really? It works perfectly fine on my server. Did you try using @reloadscript after you enabled the NPC? I know it needs to be reloaded for the chat room box to appear above its head, and I have no problems with it at all. It's set to only work for one character per account like you requested. Can you post your modified version of the script here so I can see if you may have changed something accidentally?

DT

Edited by DarkTakeshi
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  4
  • Reputation:   0
  • Joined:  07/29/12
  • Last Seen:  

When i use it there's no NPC appeared can anyone give me guide.. i put it in npc/custom

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  21
  • Reputation:   0
  • Joined:  04/02/12
  • Last Seen:  

You need to make sure you put an entry in script_custom.txt so the server recognizes it. You would input it as this - npc: npc/custom/script.txt replacing "script" with whatever name you have given to this script file. You can either restart your server or load the NPC in manually using @loadnpc npc/custom/script.txt.

DT

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  78
  • Reputation:   2
  • Joined:  08/02/12
  • Last Seen:  

the npc continues giving the item in lvl 70..

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

Alright guys this one took me a while I even had to add some options to Key_Worlds Explode function to keep the script universal, but I'm not really sure how user friendly it is... Tell me what you think... I'll to and explain it.

 

It's has a small delay right now, because it's the first version, and I had to use many functions to emulate rathena commands.... :(

 

prontera.gat,149,180,5    script    Freebie NPC    753,{
//Configurable Char Variables
set @c, 1; // This is a variable for first letter Case-change. ( 1=on/0=off --Disable for speed up! )
set @npc$,    "[^0000FFFreebie NPC^000000]";
setarray @cmds$,    "getitemname",    "getcharid",    "strcharinfo";
//End

//Character Vars
set .@blvl,    BaseLevel;
set .@getitm$, ".itm"+#itmget+"$";
set .@getitm_len, getarraysize(getd(.@getitm$));
set .@nxtrblvl,    atoi(getd(".itm"+(#itmget+1)+"$[2]"));
set .@rblvl,    atoi(getd(.@getitm$+"[2]"));
//End

//NPC Dialogue
if(.@blvl>=.@rblvl) {
    for(set .@s,0;.@s<(.@getitm_len-3);set .@s,.@s+1){
        set .@op$, callfunc("dispmes_func",getd(.@getitm$+"["+(.@s+3)+"]"));
        if(.@op$=="next;"||.@op$=="Next;") { set .@op$, ""; next; }
        if(.@op$=="menu;"||.@op$=="Menu;") { if(select("Yes:No")&2) close; set .@op$, ""; }
        if(.@op$=="close;"||.@op$=="Close;") { set .@op$, ""; close; }
        if(.@op$=="item;"||.@op$=="Item;") { set .@op$, ""; getitem atoi(getd(.@getitm$)),atoi(getd(.@getitm$+"[1]")); set #itmget,#itmget+1; }
        if(.@op$=="npc;"||.@op$=="Npc;") { set .@op$, @npc$; }
        if(.@op$!="") mes .@op$;
    }
}

mes @npc$;
set .@message$, (.@blvl<=.@rblvl )?
        "You have already received this item, please come back when you are level "+.@rblvl+" for a special item."
    :
        ((.@rblvl<.@blvl )?
                "Sorry, I don't have anymore items to give you!"
            :
                "");
mes .@message$;
close;
//End


end;
OnInit:
    waitingroom "Free items!",0;

//Configure NPC Items & Dialogue HERE!
    //                    ItemID    Amount    Required-BaseLevel
    setarray .itm0$,    "501",    "10",    "1",
        "Npc;",
        "Hello, strcharinfo(0), do you want this free item?",
        "next;",    "menu;",
        "Alright!",    "item;",
        "Goodbye.",    "close;";

    setarray .itm1$,    "502",    "20",    "70",
        "Npc;",
        "Wow, strcharinfo(0), you're really strong!",
        "I won't keep you waiting.",
        "Here is your item- You've earned it!",
        "item;", "Until we meet again.", "close;";

    setarray .itm2$,    "1599",    "1",    "180",
        "Npc;",
        "You, sir, are a true god!",
        "Hh-h-here is your getitemname(1599).",
        "item;", "close;";
//End

/*Explanation:
    The first three values in each row are the only constant numbers.
    First is the item_id then the amount you want to give then the level you give it at.
    Every line after that is lucid. You can type what the npc is going to say.
    You can also use optional commands that I will list below to display information.
    Add new conditions by following my example just remember to change .itm<#>$ to the next value.
    I hope everyone can understand this x.x Keep in mind this is just the first version.
    It's still a little slow. You can change upper-case to ignore for speedup.
    
Commands Explained:
    Commands that takeup one line:
        "Npc;", -> This will display the npcs name.
        "Item;", -> Will give the player item and increase quest value.
        "Menu;", -> This will display a Yes and No menu.
        "Close;", -> This will close the script.
        "Next;", -> This will refresh chat window and display Next button.
    
    Commands that can be used in chat:
        getitemname(<itemid>) -> Shows item name in chat.
        getcharid(<type>) -> Will return character id number.
        strcharinfo(<type>) -> displays information from charinfo. EX: strcharinfo(0) = Characters Name

Skorm
*/

}



function    script    dispmes_func    {
    set .@len,callfunc("str_explode2","@explosion$",getarg(0), 3, " ", "(", ")");
    for(set .@a,0;.@a<.@len;set .@a,.@a+1) {
        for(set .@b,0;.@b<getarraysize(@cmds$);set .@b,.@b+1){
            if (compare(@explosion$[.@a],@cmds$[.@b])){
                set .@output$, callfunc("commands_func",.@b,@explosion$[(.@a+1)]);
                set @explosion$[.@a], .@output$;
                set @explosion$[(.@a+1)], "";
            }
        }
        if(!.@a&&@c) {
            callfunc "str_toarray", @explosion$[.@a], "@tmp$[0]";
            set @tmp$[0],callfunc("str_changecase", @tmp$[0], 1);
            set @explosion$[.@a],""; set .@i,0;
            while(getstrlen(@explosion$[.@a])<getarraysize(@tmp$)){
                set @explosion$[.@a],@explosion$[.@a]+@tmp$[.@i];
                set .@i,.@i+1;
            }
        }
        set .@message$, .@message$+ ((@explosion$[.@a]!=""&&.@a<(.@len-1))?
                @explosion$[.@a]+" "
            :
                @explosion$[.@a]+"");
    }
    return .@message$;
}



function    script    commands_func    {
    switch(getarg(0)){
        case 0:
            return getitemname(atoi(getarg(1)));
        case 1:
            return getcharid(atoi(getarg(1)));
        case 2:
            return strcharinfo(atoi(getarg(1)));
    }
}



/// callfunc "str_explode2" , "<array output>", "<string>"{, <Amount of Delemiter>{, "<Delemiter>"{, "<Delemiter>"}}};
function    script    str_explode2    {
    if ( !getarg(2) )
        return callfunc("str_toarray", getarg(1), getarg(0) );
    sleep2 1;
    setarray .@char$[0],
        " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
        "e", "i", "a", "s", "r", "n", "t", "o", "u", "l", "c",
        "p", "m", "d", "v", "h", "g", "f", "b", "y", "q", "k",
        "z", "x", "j", "w", "_", "-", "(", ")", ";", ",", ":",
        ".", "*", "!", "?", "'";
    set .@charsize,    getarraysize(.@char$);
    set .@tmp$,    "|~key~|";
    set .@str$,    .@tmp$ + getarg(1) ;
    set .@len,    getstrlen(getarg(1));
    set .@delem_len,    getarg(2);
    for( set .@g,0;.@g<.@delem_len;set .@g,.@g+1 ){
        setd(".@parse_len"+.@g, getstrlen(getarg(3+.@g)));
    }
    while( .@len > .@s ) {
        set .@i, 0 ;
        while( .@i < .@charsize  ) {
            if ( ! ( set(.@l,.@l+1) % 600) )
                sleep2 1;
            if ( compare( .@str$ , .@tmp$ + .@char$[.@i] ) ) {
                set .@tmp$, .@tmp$ + .@char$[.@i];
                set .@g, 0;
                while( .@g < .@delem_len ) {
                    if ( ! ( set(.@l,.@l+1) % 600) )
                        sleep2 1;
                    if ( .@char$[.@i] == getarg((3+.@g)) ) {
                        set .@p, .@p + 1;
                        set .@s, .@s + (getd(".@parse_len"+.@g)-1) ;
                        break;
                    }
                    set .@g,.@g+1;
                }
                if ( .@delem_len == .@g )
                    set .@arr$[.@p], .@arr$[.@p] + .@char$[.@i];
                break;
            }
            set .@i, .@i+1 ;
        }
        if ( .@i == .@charsize ) return 0;
        else set .@s, .@s+1 ;
    }
    deletearray getd(getarg(0));
    copyarray getd(getarg(0)), .@arr$, .@p+1;
    return .@p+1;
}



function    script    str_changecase    {
    sleep2 1;
    if ( getarg(1) ) {
        setarray .@char$[ 0 ],
            " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
            "E", "I", "A", "S", "R", "N", "T", "O", "U", "L", "C",
            "P", "M", "D", "V", "H", "G", "F", "B", "Y", "Q", "K",
            "Z", "X", "J", "W", "_", "-", "(", ")", ";", ",", ":",
            ".", "*", "!", "?", "'";
    }
    else {
        setarray .@char$[ 0 ],
            " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
            "e", "i", "a", "s", "r", "n", "t", "o", "u", "l", "c",
            "p", "m", "d", "v", "h", "g", "f", "b", "y", "q", "k",
            "z", "x", "j", "w", "_", "-", "(", ")", ";", ",", ":",
            ".", "*", "!", "?", "'";
    }
    set .@charsize, getarraysize(.@char$);
    set .@str$, "|~key~|" + getarg(0) ;
    set .@len, getstrlen(getarg(0));
    while( .@len>.@s ) {
        set .@i,0;
        while( .@i<.@charsize ) {
            if ( ! ( set(.@l,.@l+1) % 650) )
                sleep2 1;
            if ( compare( .@str$ , "|~key~|" + .@tmp$ + .@char$[.@i] ) ) {
                set .@tmp$, .@tmp$ + .@char$[.@i];
                break;
            }
            set .@i, .@i+1;
        }
        if ( .@i == .@charsize ) return "";
        else set .@s, .@s+1;
    }
    return .@tmp$;
}



function    script    str_toarray    {
    sleep2 1;
    if ( getstrlen( getarg(0) ) > 128 ) return 0;
    setarray .@char$[ 0 ],
        " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
        "e", "i", "a", "s", "r", "n", "t", "o", "u", "l", "c",
        "p", "m", "d", "v", "h", "g", "f", "b", "y", "q", "k",
        "z", "x", "j", "w", "_", "-", "(", ")", ";", ",", ":",
        ".", "*", "!", "?", "'";

    set .@charsize, getarraysize(.@char$);
    set .@tmp$, "|~key~|";
    set .@str$, .@tmp$ + getarg(0) ;
    set .@len, getstrlen(getarg(0));
    while( .@len>.@s ) {
        set .@i,0;
        while( .@i<.@charsize ) {
            if ( ! ( set(.@l,.@l+1) % 650) )
                sleep2 1;
            if ( compare( .@str$ , .@tmp$ + .@char$[.@i] ) ) {
                set .@tmp$, .@tmp$ + .@char$[.@i];
                set .@arr$[.@s], .@char$[.@i];
                break;
            }
            set .@i, .@i+1;
        }
        if ( .@i == .@charsize ) return 0;
        else set .@s, .@s+1;
    }
    deletearray getd(getarg(1));
    copyarray getd(getarg(1)), .@arr$, .@len;
    return .@len;
}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  177
  • Reputation:   9
  • Joined:  06/25/12
  • Last Seen:  

 Skorm: Hi, I was wondering to change your script to an automated ones? When the player reaches level 10, 99 and 175 they'll get their free items. Can you help me with that? Also we can set multiple items at a time right?

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

 Skorm: Hi, I was wondering to change your script to an automated ones? When the player reaches level 10, 99 and 175 they'll get their free items. Can you help me with that? Also we can set multiple items at a time right?

 

Hi, yeah I could easily do that... really you don't have to change much at all.

 

I hope you're using rAthena though because the newest version is much faster but only works with rAthena and maybe Hercules.

 

//Automated Version 1 rAthena Only
-	script	Freebie NPC	-1,{
//Configurable Char Variables
OnPCBaseLvUpEvent:
@npc$          =	"[^0000FF"+strnpcinfo(1)+"^000000]";
setarray @cmds$,	"getitemname", "getcharid", "strcharinfo",
                	"strnpcinfo" , "countitem", "blvl"       ,
                	"jlvl"       , "var"      ;
//End

//Character Vars
.@blvl      	=	BaseLevel;
.@getitm$   	=	".itm"+#itmget+"$";
.@getitm_len	=	getarraysize(getd(.@getitm$));
.@rblvl     	=	atoi(getd(.@getitm$+"[2]"));
.@itmid     	=	atoi(getd(.@getitm$));
.@itmam     	=	atoi(getd(.@getitm$+"[1]"));
@nxtrblvl    	=	atoi(getd(".itm"+(#itmget+1)+"$[2]"));
freeloop(1);
//End

//NPC Dialogue
if(.@blvl>=.@rblvl) {
	for(.@s=0;.@s<(.@getitm_len-3);.@s++){
		.@op$=callfunc("dispmes_func",getd(.@getitm$+"["+(.@s+3)+"]"));
		if(compare(.@op$,"next;")) { .@op$=""; next; }
		if(compare(.@op$,"menu;")) { if(select("Yes:No")&2) close; .@op$=""; }
		if(compare(.@op$,"close;")) { .@op$=""; close; }
		if(compare(.@op$,"item;")) {
			if(compare(.@op$,"item;(")) {
				.@s$=callfunc("find_value",.@op$);
				explode(.@op$, .@s$, ",");
				.@op_len=getarraysize(.@op$);
				while(.@t<.@op_len) {
					getitem(atoi(.@op$[.@t]),atoi(.@op$[.@t+1]));
					.@t=.@t+2;
				} #itmget++; .@op$="";
			} else {
				.@op$=""; getitem .@itmid,.@itmam; #itmget++;
			}
		}
		if(compare(.@op$,"npc;")) { .@op$=@npc$; }
		if(.@op$!="") mes .@op$;
	}
}
end;
//End

OnInit:
//Configure NPC Items & Dialogue HERE!
	//              	ItemID,	Amount,	Required-BaseLevel,
	setarray .itm0$,	"501" ,	"10"  ,	"2",
		"Item;(501,1,502,2,503,3)";

	setarray .itm1$,	"502",	"20",	"70",
		"Item;(504,1,505,2,506,3)",
		"Item;(507,1,508,2,509,3)";

	setarray .itm2$,	"1599",	"1",	"120",
		"Npc;",
		"You, sir, are a true god!",
		"Hh-h-here is your getitemname(1599).",
		"item;", "close;";
//End

/*Explanation:
	The first three values in each row are the only constant numbers.
	First is the item_id then the amount you want to give then the level you give it at.
	Every line after that is lucid. You can type what the npc is going to say.
	You can also use optional commands that I will list below to display information.
	Add new conditions by following my example just remember to change .itm<#>$ to the next value.
	I hope everyone can understand this x.x Keep in mind this is just the first version.
	It's still a little slow. You can change upper-case to ignore for speedup.
	
Commands Explained:
	Commands that takeup one line:
          	"Npc;", -> This will display the npcs name.
          	"Item;", -> Will give the player item and increase quest value.
(Optional)	"Item;(501,1,502,2,503,3)", -> Will give the player multiple items and increase quest value.
          	"Menu;", -> This will display a Yes and No menu.
          	"Close;", -> This will close the script.
          	"Next;", -> This will refresh chat window and display Next button.
	
	Commands that can be used in chat:
		getitemname(<itemid>) -> Shows item name in chat.
		getcharid(<type>) -> Will return character id number.
		strcharinfo(<type>) -> displays information from charinfo. EX: strcharinfo(0) = Characters Name
		countitem(<itemid>) -> displays the count of the itemid.
		blvl() -> Displays baselevel.
		jlvl() -> Displays joblevel.

Skorm
*/

}


function	script	dispmes_func	{
	.@message$ = getarg(0);
	explode(@explosion$, .@message$, " ");
	.@len = getarraysize(@explosion$);
	for(.@a=0;.@a<.@len;.@a++) {
		for(.@b=0;.@b<getarraysize(@cmds$);.@b++){
			if (compare(@explosion$[.@a],@cmds$[.@b])){
				.@s$ = callfunc("find_value",@explosion$[.@a]);
				.@output$ = callfunc("commands_func",.@b,.@s$);
				.@message$ = replacestr(.@message$, @cmds$[.@b]+"("+.@s$+")", .@output$);
			}
		}
	}
	return .@message$;
}

function	script	commands_func	{
	switch(getarg(0)){
		case 0: return getitemname(atoi(getarg(1)));
		case 1: return getcharid(atoi(getarg(1)));
		case 2: return strcharinfo(atoi(getarg(1)));
		case 3: return strnpcinfo(atoi(getarg(1)));
		case 4: return countitem(atoi(getarg(1)));
		case 5: return BaseLevel;
		case 6: return JobLevel;
		case 7: return getd(getarg(1));
	}
}

function	script	find_value	{
	.@l = strpos(getarg(0), "(", 0);
	.@r = strpos(getarg(0), ")", 0);
	return substr(getarg(0), (.@l+1), (.@r-1));
}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  177
  • Reputation:   9
  • Joined:  06/25/12
  • Last Seen:  

oh god I'm using hercules. >.< well I'll still try though. Thanks Skorm! i'll let you know if it works on hercules. :P


 

 

-->oh and by the way does this work on

 

// Turn this on to allow a player to level up more than once from a kill. (Note 1)
multi_level_up: yes

 

Edited by Mad Walker
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

oh god I'm using hercules. >.< well I'll still try though. Thanks Skorm! i'll let you know if it works on hercules. :P

 

-->oh and by the way does this work on

 

// Turn this on to allow a player to level up more than once from a kill. (Note 1)
multi_level_up: yes

 

I don't see why not... except for maybe if there are 2 prizes really close to each other... at different levels like a prize at level 1 and a different prize at level 2 if you killed a monster and went to level 3 you would only get the prize for level 1... I'm going to see if I can create a temporary loop to fix this.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  177
  • Reputation:   9
  • Joined:  06/25/12
  • Last Seen:  

alright thanks for the support though.  /no1

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...