Jump to content
  • 0

problem with My npc treasure chest


angelwarrior

Question


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  29
  • Reputation:   0
  • Joined:  02/21/16
  • Last Seen:  

Hi guys,

I am making a script called treasurechest is simple you kill a chest(woechest) and you can get an item or spawn a mimic. But because i am noob scripter i don't know why it doesn't works.

-	script	cofresdeltesoro	-1,0,5{
OnNPCKillEvent:
if (killedrid == 1732) {
	set var, rand(1,10);
switch (var) {
	case 1:
        getitem 909,1;
        close;
        
    	case 2:
        getitem 7126,1;
        close;
        
    	case 3:
        getitem 7300,1;
        close;
        
	case 4: 
		getitem 909,1;
		close;
			
	case 5:
		getitem 2610,1;
		close;

	case 6:
		getitem 728,1;
		close;

	case 7:
		getitem 909,1;
		close;

	case 8:
		getitem 909,1;
		close;

	case 9:
		getitem 7126,1;
		close;

	case 10:
		atcommand "@monster 1474";
		close;
	}	
	break;
} // End if
end;
}

Where  is error? or how i can do it?

Console map doesn´t says nothing

The script should be global cause treasure chests will are in many maps.

Edited by angelwarrior
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  155
  • Reputation:   5
  • Joined:  03/30/13
  • Last Seen:  

Edit those close; commands and write break; instead. C:

___

EDIT:

Also, that last break; (after the switch (){}) may cause an 'unexpected break; usage' error, in that case you just comment that to troubleshoot.

Edited by Echoes
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  29
  • Reputation:   0
  • Joined:  02/21/16
  • Last Seen:  

Edit those close; commands and write break; instead. C:

___

EDIT:

Also, that last break; (after the switch (){}) may cause an 'unexpected break; usage' error, in that case you just comment that to troubleshoot.

mmm I try change that close; for end; but nothing happend :

-	script	cofresdeltesoro	-1,0,5{
OnNPCKillEvent:
if (killedrid == 1732) {
	set var, rand(1,10);
switch (var) {
	case 1:
        getitem 909,1;
        end;
        
    	case 2:
        getitem 7126,1;
        end;
        
    	case 3:
        getitem 7300,1;
        end;
        
	case 4: 
		getitem 909,1;
		end;
			
	case 5:
		getitem 2610,1;
		end;

	case 6:
		getitem 728,1;
		end;

	case 7:
		getitem 909,1;
		end;

	case 8:
		getitem 909,1;
		end;

	case 9:
		getitem 7126,1;
		end;

	case 10:
		atcommand "@monster 1474";
		end;
	}	
	break;
} // End if
end;
}

Can you make the modification that you mention please? or teach me with an example =)

Edited by angelwarrior
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   431
  • Joined:  01/26/16
  • Last Seen:  

Fixed that for you. BTW, indent your code properly. You won't need those unnecessary blank lines if you indent your code properly.

-	script	cofresdeltesoro	-1,0,5{
end;

OnNPCKillEvent:
	if (killedrid == 1732) {
		set .@var, rand(1,10); // Use scope variable instead when dealing with "use once and forget" variable like this. [secretdataz]
		switch (.@var) {
			case 1:
				getitem 909,1;
				break;
			case 2:
				getitem 7126,1;
				break;
			case 3:
				getitem 7300,1;
				break;
			case 4: 
				getitem 909,1;
				break;
			case 5:
				getitem 2610,1;
				break;
			case 6:
				getitem 728,1;
				break;
			case 7:
				getitem 909,1;
				break;
			case 8:
				getitem 909,1;
				break;
			case 9:
				getitem 7126,1;
				break;
			case 10:
				atcommand "@monster 1474";
				break;
			}	
		} // End if
	end;
}

Here's GitHub Gist link of this script in case rA forum mess up with the indents.

Edited by secretdataz
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  155
  • Reputation:   5
  • Joined:  03/30/13
  • Last Seen:  

-	script	cofresdeltesoro	-1,{
OnNPCKillEvent:
	if(killedrid == 1732)
		set .@var,rand(1,10);
	switch(.@var){
		case 1:	getitem 909,1;	break;
		case 2:	getitem 7126,1;	break;
		case 3:	getitem 7300,1;	break;
		case 4:	getitem 909,1;	break;
		case 5:	getitem 2610,1;	break;
		case 6:	getitem 728,1;	break;
		case 7:	getitem 909,1;	break;
		case 8:	getitem 909,1;	break;
		case 9:	getitem 7126,1;	break;
		case 10:	atcommand "@monster 1474";	break;
	}
	end;
}	

Working perfectly for me..

Try to use this as a guide, understand it and you will improve your scripting skills c:

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  29
  • Reputation:   0
  • Joined:  02/21/16
  • Last Seen:  

Fixed that for you. BTW, indent your code properly. You won't need those unnecessary blank lines if you indent your code properly.

-	script	cofresdeltesoro	-1,0,5{
end;

OnNPCKillEvent:
	if (killedrid == 1732) {
		set .@var, rand(1,10); // Use scope variable instead when dealing with "use once and forget" variable like this. [secretdataz]
		switch (.@var) {
			case 1:
				getitem 909,1;
				break;
			case 2:
				getitem 7126,1;
				break;
			case 3:
				getitem 7300,1;
				break;
			case 4: 
				getitem 909,1;
				break;
			case 5:
				getitem 2610,1;
				break;
			case 6:
				getitem 728,1;
				break;
			case 7:
				getitem 909,1;
				break;
			case 8:
				getitem 909,1;
				break;
			case 9:
				getitem 7126,1;
				break;
			case 10:
				atcommand "@monster 1474";
				break;
			}	
		} // End if
	end;
}

Here's GitHub Gist link of this script in case rA forum mess up with the indents.

I kill it monster and it Doesn't work :(

Map doesn't says nothing

-	script	cofresdeltesoro	-1,{
OnNPCKillEvent:
	if(killedrid == 1732)
		set .@var,rand(1,10);
	switch(.@var){
		case 1:	getitem 909,1;	break;
		case 2:	getitem 7126,1;	break;
		case 3:	getitem 7300,1;	break;
		case 4:	getitem 909,1;	break;
		case 5:	getitem 2610,1;	break;
		case 6:	getitem 728,1;	break;
		case 7:	getitem 909,1;	break;
		case 8:	getitem 909,1;	break;
		case 9:	getitem 7126,1;	break;
		case 10:	atcommand "@monster 1474";	break;
	}
	end;
}	

Working perfectly for me..

Try to use this as a guide, understand it and you will improve your scripting skills c:

 

Thank you . It work for me too. But i do not know that you can put a " ;  after a command and other command with ; before. You optimized the spaces o.o

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  155
  • Reputation:   5
  • Joined:  03/30/13
  • Last Seen:  

Thank you . It work for me too. But i do not know that you can put a " ;  after a command and other command with ; before. You optimized the spaces o.o

 

Yeah, since the server reads the script linearly, you can have a whole NPC in one line (on theory). And for the optimized lines, like there:

case 4:	getitem 909,1;	break;

The way I do this is: case 4:(TAB)getitem 909,1;(TAB)break;  The tabs sort the script a bit, making it more friendly to the sight.

 

Glad you liked it.

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