Jump to content
  • 0

NPC with password.


Killmesoftly

Question


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  73
  • Reputation:   6
  • Joined:  06/16/12
  • Last Seen:  

Hey good morning everyone, i would like a npc which has a simple use, uhm when you talk to the npc he will ask you to put a password and if the password is correct, you'll be teleported in a map. (example gef_fild15) if possible, i would like to implement an option to be able to change password if GM acc is 99 on the npc.. i tried to make one but.. there's an error. 

 

prontera.gat,150,150,5    script    Men In Black    811,{
mes "[Men In Black]";
mes "Enter the password.";
next;
input @lb_pass$;
if(@lb_pass$ != 123456){
mes "[Men In Black]";
mes "Incorrect password.";
close;
}
mes "[Men In Black]";
mes "Correct password, teleporting to the map..";
close2;
warp "Prontera.gat",180,150;
end;
}
Link to comment
Share on other sites

12 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  


if( select("Yes:No") == 1 ) {

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  48
  • Reputation:   1
  • Joined:  04/14/17
  • Last Seen:  

Hi everyone. I have a question too. how to make a event npc with password that if you put the password correctly, it will give you items. but the password can be reset for every event and the items can only be claimed once for every event. i saw once on some private server, i've try every script but it doesn't work /swt

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:  

Sure it is.

 

prontera.gat,150,150,5	script	Men In Black	811,{
	if(getgmlevel()>=99) {
		mes "[Men In Black]";
		mes "Hello, Mr. GM, Would you like to change the password?"; next;
		if(!(select("Yes:No")&2)) {
			mes "[Men In Black]";
			mes "Alright input a new password!";
			next;
			input .@lb_pass$;
			mes "[Men In Black]";
			mes "Password successfully changed to ["+.@lb_pass$+"].";
			set($lb_pass$,.@lb_pass$);
			close;
		}
	}
	mes "[Men In Black]";
	mes "Enter the password.";
	next;
	input .@lb_pass$;
	if(.@lb_pass$ != $lb_pass$){
		mes "[Men In Black]";
		mes "Incorrect password.";
		close;
	}
	mes "[Men In Black]";
	mes "Correct password, teleporting to the map..";
	close2;
	warp "Prontera",180,150;
	end;
}

 

Just use a constant global variable which is alright for small things like this.

 

Also your error is coming from:

if(@lb_pass$ != 123456){

You're comparing a String variable to a constant Integer.

 

Should be:

if(@lb_pass$ != "123456"){
Edited by Skorm
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  73
  • Reputation:   6
  • Joined:  06/16/12
  • Last Seen:  

Sure it is.

 

prontera.gat,150,150,5	script	Men In Black	811,{
	if(getgmlevel()>=99) {
		mes "[Men In Black]";
		mes "Hello, Mr. GM, Would you like to change the password?"; next;
		if(!select("Yes:No")&2) {
			mes "[Men In Black]";
			mes "Alright input a new password!";
			next;
			input .@lb_pass$;
			mes "[Men In Black]";
			mes "Password successfully changed to ["+.@lb_pass$+"].";
			set($lb_pass$,.@lb_pass$);
			close;
		}
	}
	mes "[Men In Black]";
	mes "Enter the password.";
	next;
	input .@lb_pass$;
	if(.@lb_pass$ != $lb_pass$){
		mes "[Men In Black]";
		mes "Incorrect password.";
		close;
	}
	mes "[Men In Black]";
	mes "Correct password, teleporting to the map..";
	close2;
	warp "Prontera",180,150;
	end;
}

 

Just use a constant global variable which is alright for small things like this.

 

Also your error is coming from:

if(@lb_pass$ != 123456){

You're comparing a String variable to a constant Integer.

 

Should be:

if(@lb_pass$ != "123456"){

 

 

Aww hey thank you so much for answering so fast, but theres something i dont understand, right after i click on the npc, hes asking me if i want to change the password, when i say yes, i put a password but then he says its wrong ( what's the main password anyway) i checked the npc but didnt see any password, and so when i choose not to change the password, he asks me for the password but i dont know what the password is XD the script is great, but shouldn't be there like a menu to ask if i want to setup a new password, change the password , to enter to the room/map, or exit.

 

thank you again for answering, have a nice day!

Edited by Killmesoftly
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:  

Change:

if(!select("Yes:No")&2) {

To:

if(!(select("Yes:No")&2)) {

 

If clicking yes doesn't take you to an input box.

 

If you just want there to be an option to only change the password once then add a check for that global variable.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  73
  • Reputation:   6
  • Joined:  06/16/12
  • Last Seen:  

aww, but he doesnt let me set or assign a password :-s 

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:  

if( select("Yes:No") == 1 ) {

 

Really weird that it wouldn't work though? 1 AND 2 = 0 | 2 AND 2 = 2.... Hmm

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  73
  • Reputation:   6
  • Joined:  06/16/12
  • Last Seen:  

if( select("Yes:No") == 1 ) {

 

aw Emistry thank you so much it did worked, thank you to both of you Skorm and Emistry. thumbs up!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

Actually I'm interested about how the script.c works, '&' should work, or maybe 0x2?

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:  

Actually I'm interested about how the script.c works, '&' should work, or maybe 0x2?

 

It does, I've used it before with multiple cases. I think Killmesoftly might've forgot to add the second parenthesis. In any case it's still better to use == even though it doesn't look as cool, because there is one less operation for the script to run. Apposed to the (!(var&2)).

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

'Switch' return value starts from 1 not from 0, isn't it?

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

'Switch' return value starts from 1 not from 0, isn't it?

switch doesnt return any value ... only the select does ...

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