Thread: Say Links
View Single Post
  #44  
Old 06-11-2009, 04:46 PM
Sion
Fire Beetle
 
Join Date: Jun 2008
Location: -
Posts: 14
Default

I think it would help a lot if there was at least an option to make the saylink not actually make the player say something. If you combined that with using $client->Message("(npc) says ...") instead of quest::say("..."), you could have completely private/spam-free interactions with npcs. It would also help a lot for my passcode script idea. (see below)

Also, I came up with a kind of cheap way in perl to make the text you click different from the text that is said:

Code:
sub Saylink
{
	my $saylink = quest::saylink($_[0]);
	my $length = length(substr($saylink,46)) - 1;

	if($_[1]) { substr($saylink,46,$length,$_[1]); }
	
	return $saylink;
}
It basically just creates a new saylink with the text you want it to say and then edits the string that quest::saylink() returns to change the text that you click.

So for example you could do $saylink = Saylink("option1","[Ask about the recent attacks.]"); and it would make a saylink titled "[Ask about the recent attacks.]" and when you click it, it would make you say "option1". This can help in some cases but doesn't have much practical use until you get to more advanced stuff: Like my passcode script idea.

-Passcode script idea-
If saylinks didn't actually make the player say something, you could use them for private npc interactions. One example of this would be to set a passcode that is required in order for something to happen (being able to open a door, zone somewhere, summon an item, spawn a mob, enter an instance, etc). I tried doing this in game and it works fine. The script just creates saylinks for the digits (0-9) and then a saylink for resetting the passcode and a saylink for submitting the passcode. When you click one of the digits, it adds that digit to $passcode[$cid] which is an array of passcodes where the index is the character's id (This is so any number of players can use the script at the same time without messing each other up). When you click [reset passcode], it sets $passcode[$cid] back to empty and when you click [submit passcode], it checks $passcode[$cid] against $check, the variable that the correct passcode is stored in. If they match, access is granted and you can flag the player or do whatever you wanted to do. If they don't match, it denies them access.

Code:
$check = 52213; # the passcode to check against: can also load it from a global/file/etc

sub EVENT_SAY
{
	$cid = $client->CharacterID(); # gets the character's id and uses it as the index for the @passcode array
	@args = split(/ /, $text); # split up $text by spaces and store each word/number/etc in the @args array

	if($args[0]=~/hail/i)
	{
		InitSaylinks();
		ShowMenu();
	}
	if($args[0]=~/push/i)
	{
		$passcode[$cid] = $passcode[$cid] . $args[1];
		ShowMenu();
	}
	if($args[0]=~/reset/i)
	{
		$passcode[$cid] = "";
		ShowMenu();
	}
	if($args[0]=~/enter/i)
	{
		if($passcode[$cid] eq $check)
		{
			$client->Message(15, "Access granted!");
			$passcode[$cid] = "";
			# now do whatever you wanted to do: open door, move player to location, move player to another zone, spawn a mob, summon an item, etc
		}
		else 
		{ 
			$client->Message(13, "Wrong passcode! Access denied!"); 
			$passcode[$cid] = "";
			ShowMenu();
		}
	}
}

sub InitSaylinks
{
	my $count = 0;
	while($count < 10) { 
		$sl_push[$count] = Saylink("push " . $count, $count);
		$count++;
	}
	$sl_reset = Saylink("reset","[Reset passcode]");
	$sl_enter = Saylink("enter","[Submit passcode]");
}

sub Saylink
{
	my $saylink = quest::saylink($_[0]);
	my $length = length(substr($saylink,46)) - 1;

	if($_[1] ne "") { substr($saylink,46,$length,$_[1]); }
	
	return $saylink;
}

sub ShowMenu
{
	if($passcode[$cid]) { $client->Message(4, "You have entered: $passcode[$cid]"); }
	$client->Message(4, "Enter passcode: @sl_push $sl_reset $sl_enter");
}
It would end up looking something like this (correct passcode is 52213 in this example):
Reply With Quote