Jump to content
  • 0
Ricauter

R> command when killing monsters

Question

:D I want to know if it's possible to script that when you kill X mob in Y map, it exexutes Z command, like for example to add +1 to a counter, and when that counter reaches a certain number, then it executes a certain command, or when killing a monster it buffs you, I'd greatly appreciate on some help on how to create a script of this kind :D

Share this post


Link to post
Share on other sites

26 answers to this question

Recommended Posts

  • 0

:D I want to know if it's possible to script that when you kill X mob in Y map, it exexutes Z command, like for example to add +1 to a counter, and when that counter reaches a certain number, then it executes a certain command, or when killing a monster it buffs you, I'd greatly appreciate on some help on how to create a script of this kind :D

 

Just a question: what you mean with 'X' >>> number of mobs, or a specifc one??

Share this post


Link to post
Share on other sites
  • 0

 

:D I want to know if it's possible to script that when you kill X mob in Y map, it exexutes Z command, like for example to add +1 to a counter, and when that counter reaches a certain number, then it executes a certain command, or when killing a monster it buffs you, I'd greatly appreciate on some help on how to create a script of this kind :D

 

Just a question: what you mean with 'X' >>> number of mobs, or a specifc one??

 

a specific one

Share this post


Link to post
Share on other sites
  • 0

 

 

:D I want to know if it's possible to script that when you kill X mob in Y map, it exexutes Z command, like for example to add +1 to a counter, and when that counter reaches a certain number, then it executes a certain command, or when killing a monster it buffs you, I'd greatly appreciate on some help on how to create a script of this kind :D

 

Just a question: what you mean with 'X' >>> number of mobs, or a specifc one??

 

a specific one

 

then do something like this:

 

OnNPCKillEvent:if(strcharinfo(3)== 'map'){   if(getmonsterinfo(killedrid,0) == 'monstername'){       sc_start 39, 60,5; //buff 39(id), 60(time), 5 (skill level)
Edited by RodRich

Share this post


Link to post
Share on other sites
  • 0

@@RodRich oh right, and how do I do the counter thing? would it be something like
 
 

OnNPCKillEvent:if(strcharinfo(3)== 'map'){if(getmonsterinfo(killedrid,0) == 'monstername'){   set mymobkills,mymobkills +1;// to count +1 kills   }end;  if (mymobkills > 99){   set mymobkills,0;             //to reset the counter and buff?   sc_start 39, 60,5;}end;

right?

and how can I make it execute a roullette? like I want it to give a random drop from an OBB without giving the OBB?

Share this post


Link to post
Share on other sites
  • 0

@@RodRich oh right, and how do I do the counter thing? would it be something like

 

 

OnNPCKillEvent:if(strcharinfo(3)== 'map'){if(getmonsterinfo(killedrid,0) == 'monstername'){   set mymobkills,mymobkills +1;// to count +1 kills   }end;  if (mymobkills > 99){   set mymobkills,0;             //to reset the counter and buff?   sc_start 39, 60,5;}end;

right?

and how can I make it execute a roullette? like I want it to give a random drop from an OBB without giving the OBB?

 

Exaclty!!

 

about you last question, I'm sorry could you say without abreviation? 'cause my english is not so good!!

Share this post


Link to post
Share on other sites
  • 0

@@RodRich oh right, and how do I do the counter thing? would it be something like

 

 

OnNPCKillEvent:if(strcharinfo(3)== 'map'){if(getmonsterinfo(killedrid,0) == 'monstername'){   set mymobkills,mymobkills +1;// to count +1 kills   }end;  if (mymobkills > 99){   set mymobkills,0;             //to reset the counter and buff?   sc_start 39, 60,5;}end;

right?

and how can I make it execute a roullette? like I want it to give a random drop from an OBB without giving the OBB?

 

Ah ok, that simple either!!

 

You can do this way:

 

OnNPCKillEvent:if(strcharinfo(3)== 'map'){if(getmonsterinfo(killedrid,0) == 'monstername'){   set mymobkills,mymobkills +1;// to count +1 kills   }}  if (mymobkills > 99){   set mymobkills,0;             //to reset the counter and buff?   sc_start 39, 60,5;   getitem,-1,1;}end;

where -1 means: a random item from OBB..

 

or if you preffer you can also use: -2,-3,-4,-5

Giving an item ID of -2 will produce the effects of Old Violet Box.

Giving an item ID of -3 will produce the effects of Old Card Album.

Giving an item ID of -4 will produce the effects of Gift Box.

Giving an item ID of -5 will produce the effects of Worn Out Scroll, which, in current SVN, drops only Jellopies anyway.

Edited by RodRich

Share this post


Link to post
Share on other sites
  • 0

thanks! but now while testing I ran intro some issues D: I'm trying the code BUT I'm getting this eror on the console:

 

[Error]: npc_parsesrcfile: Unable to parse, probably a missing TAB in file 'npc/test/test.txt', line '1'. Skipping line... * w1=prontera * w2=Script * w3=FASE1,-1{ * w4=[Error]: npc_parsesrcfile: Unknown syntax in file 'npc/test/test.txt', line '3'. Stopping... * w1=OnNPCKillEvent: * w2= * w3= * w4=

here's how it goes:

 

prontera	Script	TEST1,-1{	OnNPCKillEvent:	if(strcharinfo(3)== 'prontera'){		if(getmonsterinfo(killerid == 1973) == 'Poring'){		set f1@ks,f1@ks +1;// to count +1 kills		announce "PORINGS KILLED +1 ["f1@ks"/5]",3		}  if (f1@ks > 5){   set f1@ks,0;             //to reset the counter and buff   sc_start 10, 240000,10;}end;}}

what did I do wrong? :(

Edited by Ricauter

Share this post


Link to post
Share on other sites
  • 0

thanks! but now while testing I ran intro some issues D: I'm trying the code BUT I'm getting this eror on the console:

 

[Error]: npc_parsesrcfile: Unable to parse, probably a missing TAB in file 'npc/test/test.txt', line '1'. Skipping line... * w1=prontera * w2=Script * w3=FASE1,-1{ * w4=[Error]: npc_parsesrcfile: Unknown syntax in file 'npc/test/test.txt', line '3'. Stopping... * w1=OnNPCKillEvent: * w2= * w3= * w4=

here's how it goes:

 

prontera	Script	TEST1,-1{	OnNPCKillEvent:	if(strcharinfo(3)== 'prontera'){		if(getmonsterinfo(killerid == 1973) == 'Poring'){		set f1@ks,f1@ks +1;// to count +1 kills		announce "PORINGS KILLED +1 ["f1@ks"/5]",3		}  if (f1@ks > 5){   set f1@ks,0;             //to reset the counter and buff   sc_start 10, 240000,10;}end;}}

what did I do wrong? :(

 

You should use <tab> instead <space bar> for while that's it! =D

P.s: you don't need to put a map if you don't want!! you can do this way:

 

-<tab>script<tab>npcname<tab>-1,{
Edited by RodRich

Share this post


Link to post
Share on other sites
  • 0

I did it like this:

-<tab>Script<tab>test1<tab>-1,{<tab>OnNPCKillEvent:<tab><tab>if(strcharinfo(3)== 'prontera'){<tab><tab><tab>if(getmonsterinfo(killerid,1973) == 'Poring'){<tab><tab><tab>set f1@ks,f1@ks +1;// to count +1 kills<tab><tab><tab>announce "PORINGS KILLED +1 ["f1@ks"/5]",3}<tab>if (f1@ks > 5){<tab><tab>set f1@ks,1;             //to reset the counter and buff<tab><tab>sc_start 10, 240000,10;}}end;}

and I'm getting the same errors  -_-

Share this post


Link to post
Share on other sites
  • 0

I did it like this:

-<tab>Script<tab>test1<tab>-1,{<tab>OnNPCKillEvent:<tab><tab>if(strcharinfo(3)== 'prontera'){<tab><tab><tab>if(getmonsterinfo(killerid,1973) == 'Poring'){<tab><tab><tab>set f1@ks,f1@ks +1;// to count +1 kills<tab><tab><tab>announce "PORINGS KILLED +1 ["f1@ks"/5]",3}<tab>if (f1@ks > 5){<tab><tab>set f1@ks,1;             //to reset the counter and buff<tab><tab>sc_start 10, 240000,10;}}end;}

and I'm getting the same errors  -_-

 

I guess you're using the <tab> key form you keyboard where you wrote <tab> (you have to)

 

but this line is wrong:

<tab><tab><tab>announce "PORINGS KILLED +1 ["f1@ks"/5]",3

do this way:

<tab><tab><tab>announce "PORINGS KILLED +1 ["+f1@ks+"/5]",3;

 

@pS:

 

Maybe you can't use '@' in midle of a variable, idk, try this way first and tell me!!

Share this post


Link to post
Share on other sites
  • 0

 

I guess you're using the <tab> key form you keyboard where you wrote <tab> (you have to)

 

 

but this line is wrong:

<tab><tab><tab>announce "PORINGS KILLED +1 ["f1@ks"/5]",3

do this way:

<tab><tab><tab>announce "PORINGS KILLED +1 ["+f1@ks+"/5]",3;

 

 

 

yes xD but I mean the problem is that the console is saying that there's a syntax error on the 1st line, and that it doesn't recognize the OnNPCKillEvent: syntax  -_-  I know it was OnNPCKillEvent, but why doesn't it recognize it as valid?

Share this post


Link to post
Share on other sites
  • 0

 

 

I guess you're using the <tab> key form you keyboard where you wrote <tab> (you have to)

 

 

but this line is wrong:

<tab><tab><tab>announce "PORINGS KILLED +1 ["f1@ks"/5]",3

do this way:

<tab><tab><tab>announce "PORINGS KILLED +1 ["+f1@ks+"/5]",3;

 

 

 

yes xD but I mean the problem is that the console is saying that there's a syntax error on the 1st line, and that it doesn't recognize the OnNPCKillEvent: syntax  -_-  I know it was OnNPCKillEvent, but why doesn't it recognize it as valid?

 

Ah ok, because when you get errer from first line, the npc isn't readed.

 

I think your error is case sensitive:

-<tab>Script<tab>test1<tab>-1,{

try:

-<tab>script<tab>test1<tab>-1,{

Share this post


Link to post
Share on other sites
  • 0

@@RodRich now it went past 1st line but:

[Warning]: script_get_val: cannot access instance variable ''prontera'', defaulting to 0

[Error]: script:op_2: invalid data for operator C_EQ
[Debug]: Data: string value="prontera"
[Debug]: Data: number value=0
[Debug]: Source (NPC): test1 (invisible/not on a map)
 
I'll try on another map and update you on it :P
Edited by Ricauter

Share this post


Link to post
Share on other sites
  • 0

nope... still getting:

 

[Error]: script:op_2: invalid data for operator C_EQ
[Debug]: Data: string value="prontera"
[Debug]: Data: number value=0
[Debug]: Source (NPC): test1 (invisible/not on a map)
 
what can that be?
-	script	test1	-1,{	OnNPCKillEvent:		if(strcharinfo(3)==prontera){			if(getmonsterinfo(killerid,1008)=='Poring'){			set f1ks,f1ks +1;// to count +1 kills;			announce "PORINGS KILLED +1 ["+f1ks+"/5]",3;			}	if (f1ks >= 5){		set f1ks,f1ks=1;             //to reset the counter and buff?		sc_start 10, 240000,10;		}}end;}

edit: but I should tell you, the script loads perfectly, the error appears on the console as soon as I try to execute it, and by that I mean, when I kill a poring in prontera...

Edited by Ricauter

Share this post


Link to post
Share on other sites
  • 0

 

nope... still getting:

 

[Error]: script:op_2: invalid data for operator C_EQ
[Debug]: Data: string value="prontera"
[Debug]: Data: number value=0
[Debug]: Source (NPC): test1 (invisible/not on a map)
 
what can that be?

-	script	test1	-1,{	OnNPCKillEvent:		if(strcharinfo(3)==prontera){			if(getmonsterinfo(killerid,1008)=='Poring'){			set f1ks,f1ks +1;// to count +1 kills;			announce "PORINGS KILLED +1 ["+f1ks+"/5]",3;			}	if (f1ks >= 5){		set f1ks,f1ks=1;             //to reset the counter and buff?		sc_start 10, 240000,10;		}}end;}

edit: but I should tell you, the script loads perfectly, the error appears on the console as soon as I try to execute it, and by that I mean, when I kill a poring in prontera...

I found some issues, make this way:

 

-	script	test1	-1,{	OnNPCKillEvent:                set .@map$,"prontera";		if(strcharinfo(3)== .@map$){			if(getmonsterinfo(killerid,0)=="Poring"){ //u had put 1008, here and have to be '0'			set f1ks,f1ks +1;// to count +1 kills;			announce "PORINGS KILLED +1 ["+f1ks+"/5]",3;			}	if (f1ks >= 5){		set f1ks,0;             //if you put '1' here, the count will start at 2		sc_start 10, 240000,10;		}}end;}
Edited by RodRich

Share this post


Link to post
Share on other sites
  • 0

@@RodRich

 

I tried this:

-	script	test1	-1,{	OnNPCKillEvent:		set .@map$, "prontera";		if(strcharinfo(3)==.@map$){			if(getmonsterinfo(killerid,1008)==1008){  // It has to be 1008 (poring's ID) else it will give me a:                                                                                                                       //[Error]: buildin_getmonsterinfo: Wrong Monster ID: 0                                                                  //[Error]: script:op_2: invalid data for operator C_EQ                                                                  //[Debug]: Data: string value="null"                                                                  //[Debug]: Data: number value=1008                                                                  //[Debug]: Source (NPC): test1 (invisible/not on a map)			set f1ks,f1ks +1;// to count +1 kills;			announce "PORINGS KILLED +1 ["+ f1ks +"/5]",3;			}	if (f1ks >= 5){		set f1ks,f1ks=0;             //to reset the counter and buff		sc_start 10, 240000,10;		}}end;}

but even with that, it gives me: [Error]: buildin_getmonsterinfo: Wrong Monster ID: 0

Share this post


Link to post
Share on other sites
  • 0

@@RodRich

 

I tried this:

-	script	test1	-1,{	OnNPCKillEvent:		set .@map$, "prontera";		if(strcharinfo(3)==.@map$){			if(getmonsterinfo(killerid,1008)==1008){  // It has to be 1008 (poring's ID) else it will give me a:                                                                                                                       //[Error]: buildin_getmonsterinfo: Wrong Monster ID: 0                                                                  //[Error]: script:op_2: invalid data for operator C_EQ                                                                  //[Debug]: Data: string value="null"                                                                  //[Debug]: Data: number value=1008                                                                  //[Debug]: Source (NPC): test1 (invisible/not on a map)			set f1ks,f1ks +1;// to count +1 kills;			announce "PORINGS KILLED +1 ["+ f1ks +"/5]",3;			}	if (f1ks >= 5){		set f1ks,f1ks=0;             //to reset the counter and buff		sc_start 10, 240000,10;		}}end;}

but even with that, it gives me: [Error]: buildin_getmonsterinfo: Wrong Monster ID: 0

 

The zero doesn't mean the monster ID, that's aboout the killedrid opition, then that should be 0!!

 

try this way instead:

 

if(getmonsterinfo(killerid,0)==getmonsterinfo(1008,0)){
Edited by RodRich

Share this post


Link to post
Share on other sites
  • 0

by all the gods in heaven... doing this:

 

-	script	test1	-1,{	OnNPCKillEvent:		set .@map$, "prontera";		if(strcharinfo(3)==.@map$){			if(getmonsterinfo(killerid,1008)==getmonsterinfo(0,1008){ // aparently that las { doesn't have a closure...			set f1ks,f1ks +1;// to count +1 kills;			announce "PORINGS KILLED +1 ["+ f1ks +"/5]",3;			}	if (f1ks >= 5){		set f1ks,f1ks=0;             //to reset the counter and buff		sc_start 10, 240000,10;		}}end;}

it has an error when reloading again...

[Error]: script error in file 'npc/test/test1.txt' line 5 column 60
    parse_simpleexpr: unmatched ')'
     2:         OnNPCKillEvent:
     3:                 set .@map$, "prontera";
     4:                 if(strcharinfo(3)==.@map$){
*    5:                         if(getmonsterinfo(killerid,1008)==getmonsterinfo(0,1008){
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
     6:                         set f1ks,f1ks +1;// to count +1 kills;
     7:                         announce "PORINGS KILLED +1 ["+ f1ks +"/5]",3;
     8:                         }

Share this post


Link to post
Share on other sites
  • 0

@@Ricauter

 

That's because you didn't closed the "()"

 

copy and paste :

 

-	script	test1	-1,{	OnNPCKillEvent:		set .@map$, "prontera";		if(strcharinfo(3)==.@map$){			if(getmonsterinfo(killedrid,0)==getmonsterinfo(1008,0)){ // PLEASE THIS WAY IS THE RIGHT WAY DON'T CHANGE AGAIN '-'			set f1ks,f1ks +1;// to count +1 kills;			announce "PORINGS KILLED +1 ["+ f1ks +"/5]",3;			}	if (f1ks >= 5){		set f1ks,f1ks=0;             //to reset the counter and buff		sc_start 10, 240000,10;		}}end;}
Edited by RodRich

Share this post


Link to post
Share on other sites
  • 0

oh... I feel stupid now but it works now, and I LOVE YOU FOR THAT

 

Hahah, no problem!! ;)

 

Hey, I've just saw this line, it can bring you problem:

set f1ks,f1ks=0;  

test in your npc, if this doesn't give error, just forgot... but If does, do this way:

set f1ks,0;  

Share this post


Link to post
Share on other sites
  • 0

was testing around, there was a mistake on the script, actually:

 

if(getmonsterinfo(killedrid,0)==getmonsterinfo(1008,0))

doesn't work at all, so any monster you'd kill would increase the counter, the real script is like this:

 

if(killedrid==1002) // and replace the 1002 for any monster ID

that way, only the monster ID you choose would increase the counter.

Share this post


Link to post
Share on other sites
  • 0

was testing around, there was a mistake on the script, actually:

 

if(getmonsterinfo(killedrid,0)==getmonsterinfo(1008,0))

doesn't work at all, so any monster you'd kill would increase the counter, the real script is like this:

 

if(killedrid==1002) // and replace the 1002 for any monster ID

that way, only the monster ID you choose would increase the counter.

That's true, I hadn't thought this way!! that's better than before. But I don't know why, the other one isn't working. It should work in both ways!!

The first one checks the monster name's, and the second one checks the monster ID's

But.. :heh: 

Share this post


Link to post
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.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.