Jump to content
  • 0

Any tip?


Yomigaeru

Question


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  89
  • Reputation:   5
  • Joined:  12/25/11
  • Last Seen:  

hey ra.
 

I recently made this script:

poring_w02,101,86,3	script	Password Event NPC	405,{

if ( $event_run > 0 ) goto event_start;

if ( getgmlevel() != 99 ) {
mes "[Password Event NPC]";
mes "There is no on-going event as of the moment.";
next;
mes "[Password Event NPC]";
mes "I will inform you when a GM hosts this event.";
close2;
emotion	e_heh;
end;
}
mes "[Password Event NPC]";
mes "Hello ^CC0000"+strcharinfo(0)+"^000000!";
next;
mes "[Password Event NPC]";
mes "Current Password: ^CC0000"+$event_pword$+"^000000";
mes "Current Prize: ^CC0000"+$event_amount+"^000000 ^CC0000"+getitemname($event_prize)+"^000000";
mes "Number of Winners: ^CC0000"+$event_winners+"^000000";
next;
mes "[Password Event NPC]";
mes "How can I help you today?";
menu
	"Set Password",event_password,
	"Set Event",event_prize,
	"Set Winner Count",event_winner,
	"Start Event",event_start1;

event_winner:
next;
mes "[Password Event NPC]";
mes "How many player do you want to win this event?";
input $event_winners;
next;
mes "[Password Event NPC]";
mes "Should ^CC0000"+$event_winners+"^000000 win this event?";
menu
	"Yes",event_count_yes,
	"Reset",event_winner;

event_count_yes:
next;
mes "[Password Event NPC]";
mes "Then ^CC0000"+$event_winners+"^000000 will win this event!";
close;

event_prize:
next;
mes "[Password Event NPC]";
mes "Please insert the item ID of this event's prize.";
input $event_prize;
next;
mes "[Password Event NPC]";
mes "Now please enter how many ^CC0000"+getitemname($event_prize)+"^000000";
input $event_amount;
next;
mes "Are you sure you want to give ^CC0000"+$event_amount+"^000000 ^CC0000"+getitemname($event_prize)+"^000000 for this event?";
menu
	"Yes",event_prize_yes,
	"Reset",event_prize;

event_prize_yes:
next;
mes "[Password Event NPC]";
mes "Then ^CC0000"+$event_amount+"^000000 ^CC0000"+getitemname($event_prize)+"^000000 it is!";
close;


event_start1:
next;
mes "[Password Event NPC]";
mes "Then let's begin!";
close2;
announce "Password Event NPC: The Password Event has begun!",bc_blue;
sleep2 5000;
announce "Password Event NPC: Try to crack the password to win "+$event_amount+" "+getitemname($event_prize)+"!",bc_blue;
sleep2 5000;
announce "Password Event NPC: Only "+$event_winners$+" can win this event!",bc_blue;
sleep2 5000;
announce "Password Event NPC: Now go! Try to crack the password!";
set $event_run,1;
end;

event_start:
if ( #event_winner == 1 ) {
mes "[Password Event NPC]";
mes "Congratulations! You have already won! Try your luck again next event!";
close;
}
if ( $crack == $event_winners ) {
set $event_run,0;
set $event_winners,0;
mes "[Password Event NPC]";
mes "All prizes are given away!";
next;
mes "[Password Event NPC]";
mes "Try your luck again next event!";
close2;
sleep2 5000;
announce "Password Event NPC: All prizes have already been acquired!",bc_blue;
sleep2 5000;
announce "Password Event NPC: Better luck next time to those who didn't win!",bc_blue;
end;
}
mes "[Password Event NPC]";
mes "What is the password for today's event?";
input .@event_try$;
if ( .@event_try$ == $event_pword$ ) {
next;
mes "[Password Event NPC]";
mes "Congratulations! You win "+$event_amount+" "+getitemname($event_prize)+" !";
set #event_winner,1;
set $crack,$crack+1;
getitem $event_prize,$event_amount;
close2;
if ( Sex == 1 ) {
announce "Password Event NPC: "+strcharinfo(0)+" wins!! Let's congratulate him!",bc_blue;
end;
}
announce "Password Event NPC: "+strcharinfo(0)+" wins!! Let's congratulate her!",bc_blue;
end;
}
next;
mes "[Password Event NPC]";
mes "Sorry, wrong password!";
close;

event_password:
next;
mes "[Password Event NPC]";
mes "What password would you like to set?";
input $event_pword$;
next;
mes "[Password Event NPC]";
mes "Do you really want to set ^CC0000"+$event_pword$+"^000000 as this event's password?";
menu
	"Yes",yes_confirm,
	"Reset",event_password;

yes_confirm:
next;
mes "[Password Event NPC]";
mes "Then ^CC0000"+$event_pword$+"^000000 it is!";
close;
} 

 

my question is that how can i delete the #variable of a character after the event without the character ever talking to the same NPC.

 

If i add it in the if ( getgmlevel() != script then if the player is not online when the next event starts then the npc will not let him play since he already got the variable from last event.

 

so, any tips? 

 

Thanks for future replies.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  254
  • Reputation:   72
  • Joined:  07/10/13
  • Last Seen:  

Check if the player is online.

If yes, use attachrid and unset the variable.

If no, change the value in the MySQL table.

I am currently not at home; as soon as I am, I will edit this post and let you know what the table's name is.

Edit: The table you need to modify is called global_reg_value.

Edited by Xynvaroth
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  89
  • Reputation:   5
  • Joined:  12/25/11
  • Last Seen:  

sorry but im not familiar in this whole sql scriptings. can you just please edit my script?

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:  

sorry but im not familiar in this whole sql scriptings. can you just please edit my script?

 

I suggest saving the winning characters to an NPC based array...

 

//deletearray .event_winner[0],128;
poring_w02,101,86,3	script	Password Event NPC	405,{

	if ( $event_run > 0 ) goto event_start;

	if ( getgmlevel() != 99 ) {
		mes "[Password Event NPC]";
		mes "There is no on-going event as of the moment.";
		next;
		mes "[Password Event NPC]";
		mes "I will inform you when a GM hosts this event.";
		close2;
		emotion	e_heh;
		end;
	}
	mes "[Password Event NPC]";
	mes "Hello ^CC0000"+strcharinfo(0)+"^000000!";
	next;
	mes "[Password Event NPC]";
	mes "Current Password: ^CC0000"+$event_pword$+"^000000";
	mes "Current Prize: ^CC0000"+$event_amount+"^000000 ^CC0000"+getitemname($event_prize)+"^000000";
	mes "Number of Winners: ^CC0000"+$event_winners+"^000000";
	next;
	mes "[Password Event NPC]";
	mes "How can I help you today?";
	menu
		"Set Password",event_password,
		"Set Event",event_prize,
		"Set Winner Count",event_winner,
		"Start Event",event_start1;

event_winner:
	next;
	mes "[Password Event NPC]";
	mes "How many player do you want to win this event?";
	input $event_winners;
	next;
	mes "[Password Event NPC]";
	mes "Should ^CC0000"+$event_winners+"^000000 win this event?";
	menu
		"Yes",event_count_yes,
		"Reset",event_winner;

event_count_yes:
	next;
	mes "[Password Event NPC]";
	mes "Then ^CC0000"+$event_winners+"^000000 will win this event!";
	close;

event_prize:
	next;
	mes "[Password Event NPC]";
	mes "Please insert the item ID of this event's prize.";
	input $event_prize;
	next;
	mes "[Password Event NPC]";
	mes "Now please enter how many ^CC0000"+getitemname($event_prize)+"^000000";
	input $event_amount;
	next;
	mes "Are you sure you want to give ^CC0000"+$event_amount+"^000000 ^CC0000"+getitemname($event_prize)+"^000000 for this event?";
	menu
		"Yes",event_prize_yes,
		"Reset",event_prize;

event_prize_yes:
	next;
	mes "[Password Event NPC]";
	mes "Then ^CC0000"+$event_amount+"^000000 ^CC0000"+getitemname($event_prize)+"^000000 it is!";
	close;


event_start1:
	next;
	mes "[Password Event NPC]";
	mes "Then let's begin!";
	close2;
	announce "Password Event NPC: The Password Event has begun!",bc_blue;
	sleep2 5000;
	announce "Password Event NPC: Try to crack the password to win "+$event_amount+" "+getitemname($event_prize)+"!",bc_blue;
	sleep2 5000;
	announce "Password Event NPC: Only "+$event_winners$+" can win this event!",bc_blue;
	sleep2 5000;
	announce "Password Event NPC: Now go! Try to crack the password!";
	set $event_run,1;
	end;

event_start:
	while(set(.@a,.@a+1)<=getarraysize(.event_winner))
		if ( .event_winner[.@a-1] == getcharid(3) ) {
			mes "[Password Event NPC]";
			mes "Congratulations! You have already won! Try your luck again next event!";
			close;
		}
	if ( $crack == $event_winners ) {
		set $event_run,0;
		set $event_winners,0;
		mes "[Password Event NPC]";
		mes "All prizes are given away!";
		next;
		mes "[Password Event NPC]";
		mes "Try your luck again next event!";
		close2;
		sleep2 5000;
		announce "Password Event NPC: All prizes have already been acquired!",bc_blue;
		sleep2 5000;
		announce "Password Event NPC: Better luck next time to those who didn't win!",bc_blue;
		end;
	}
	mes "[Password Event NPC]";
	mes "What is the password for today's event?";
	input .@event_try$;
	if ( .@event_try$ == $event_pword$ ) {
		next;
		mes "[Password Event NPC]";
		mes "Congratulations! You win "+$event_amount+" "+getitemname($event_prize)+" !";
		set .event_winner[(set(.i,.i+1)-1)],getcharid(3);
		set $crack,$crack+1;
		getitem $event_prize,$event_amount;
		close2;
		if ( Sex == 1 ) {
			announce "Password Event NPC: "+strcharinfo(0)+" wins!! Let's congratulate him!",bc_blue;
			end;
		}
		announce "Password Event NPC: "+strcharinfo(0)+" wins!! Let's congratulate her!",bc_blue;
		end;
	}
	next;
	mes "[Password Event NPC]";
	mes "Sorry, wrong password!";
	close;

event_password:
	next;
	mes "[Password Event NPC]";
	mes "What password would you like to set?";
	input $event_pword$;
	next;
	mes "[Password Event NPC]";
	mes "Do you really want to set ^CC0000"+$event_pword$+"^000000 as this event's password?";
	menu
		"Yes",yes_confirm,
		"Reset",event_password;

yes_confirm:
	next;
	mes "[Password Event NPC]";
	mes "Then ^CC0000"+$event_pword$+"^000000 it is!";
	close;
} 

Then you can call

deletearray .event_winner[0],128;

When you want to start the event over and clear the winners without the trouble of finding if they're online.

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