|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quests::Q&A This is the quest support section |
|
|
|
09-19-2009, 08:04 PM
|
Hill Giant
|
|
Join Date: May 2005
Posts: 134
|
|
server first announcements thru quest system
i'm trying to set up so that when a player hits max level on your server, and they are the first to do so, it does a server wide announcement of it.
heres what i've got so far. i have it placed in quests/templates/player.pl, but I can't get it to work for some reason. can some one take a look at it, and tell me whats wrong pls?
Code:
sub EVENT_LEVEL_UP {
my $maxlvl = 50
if(!defined($qglobals{warmaxlvl}) && $ulevel == $maxlvl && $class eq 'Warrior') {
quest::setglobal("warmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel warrior!");
}
if(!defined($qglobals{clrmaxlvl}) && $ulevel == $maxlvl && $class eq 'Cleric') {
quest::setglobal("clrmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel cleric!");
}
if(!defined($qglobals{palmaxlvl}) && $ulevel == $maxlvl && $class eq 'Paladin') {
quest::setglobal("palmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel paladin!");
}
if(!defined($qglobals{rngmaxlvl}) && $ulevel == $maxlvl && $class eq 'Ranger') {
quest::setglobal("rngmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel ranger!");
}
if(!defined($qglobals{skmaxlvl}) && $ulevel == $maxlvl && $class eq 'ShadowKnight') {
quest::setglobal("skmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel shadow knight!");
}
if(!defined($qglobals{drumaxlvl}) && $ulevel == $maxlvl && $class eq 'Druid') {
quest::setglobal("drumaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel druid!");
}
if(!defined($qglobals{mkmaxlvl}) && $ulevel == $maxlvl && $class eq 'Monk') {
quest::setglobal("mkmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel monk!");
}
if(!defined($qglobals{brdmaxlvl}) && $ulevel == $maxlvl && $class eq 'Bard') {
quest::setglobal("brdmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel bard!");
}
if(!defined($qglobals{rogmaxlvl}) && $ulevel == $maxlvl && $class eq 'Rogue') {
quest::setglobal("rogmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel rogue!");
}
if(!defined($qglobals{shmmaxlvl}) && $ulevel == $maxlvl && $class eq 'Shaman') {
quest::setglobal("shmmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel shaman!");
}
if(!defined($qglobals{necmaxlvl}) && $ulevel == $maxlvl && $class 'Necromancer') {
quest::setglobal("necmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel necromancer!");
}
if(!defined($qglobals{wizmaxlvl}) && $ulevel == $maxlvl && $class eq 'Wizard') {
quest::setglobal("wizmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel wizard!");
}
if(!defined($qglobals{magmaxlvl}) && $ulevel == $maxlvl && $class eq 'Magician') {
quest::setglobal("magmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel magician!");
}
if(!defined($qglobals{encmaxlvl}) && $ulevel == $maxlvl && $class eq 'Enchanter') {
quest::setglobal("encmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel enchanter!");
}
if(!defined($qglobals{bstmaxlvl}) && $ulevel == $maxlvl && $class eq 'Beastlord') {
quest::setglobal("bstmaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel beastlord!");
}
if(!defined($qglobals{bermaxlvl}) && $ulevel == $maxlvl && $class eq 'Berserker') {
quest::setglobal("bermaxlvl",1,2,"F");
quest::shout2("$name has made the server first level $ulevel berserker!");
}
}
|
|
|
|
09-19-2009, 08:32 PM
|
|
Demi-God
|
|
Join Date: Mar 2009
Location: Umm
Posts: 1,492
|
|
for starters, you need one more } at the very end
|
09-19-2009, 10:23 PM
|
Hill Giant
|
|
Join Date: May 2005
Posts: 134
|
|
just curious, sorry if this seems ignorant, but why do I need one more }? accordin to notepad++ the sub is closed, and every if statement is closed as well.
|
|
|
|
09-19-2009, 10:42 PM
|
|
Legendary Member
|
|
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
|
|
Instead of copy pasting the code 15 times, you could do something like this:
Code:
sub EVENT_LEVEL_UP {
my $maxlvl = 50;
my @classlist = ("Warrior", "Cleric", "Paladin", "Ranger", "ShadowKnight", "Druid", "Monk", "Bard", "Rogue", "Shaman", "Necromancer", "Wizard", "Magician", "Enchanter", "Beastlord", "Berserker");
foreach my $curclass (@classlist) {
if(!defined($qglobals{$curclass."maxlvl"}) && $ulevel == $maxlvl && $curclass eq $class) {
quest::setglobal($curclass."maxlvl",$name,2,"F");
quest::shout2("$name has made the server first level $ulevel $class!");
return;
}
}
}
I think that may work. I'm storing the player's name in the variable instead of just a boolean flag in hopes that who knows, one day $pglobal will be loadable on NPC's.
If that ever occurs, I wrote a reporter NPC too, $qglobals are a little weird scope wise, NPC's don't load no NPC ID vars (aka Player vars). I may ask the coders to add a $pglobal that when you talk to a NPC, it loads non-NPC ID globals for the zone are loaded into $pglobal{}. Would be handy for this situation, and I can think of a few others.
This code doesn't work, but I wrote it anyways if the theory of player global vars non-NPC specific ever get written in.
Code:
sub EVENT_SAY
{
if ($text=~/Hail/i) { #Initial Hail
my @classlist = ("Warrior", "Cleric", "Paladin", "Ranger", "ShadowKnight", "Druid", "Monk", "Bard", "Rogue", "Shaman", "Necromancer", "Wizard", "Magician", "Enchanter", "Beastlord", "Berserker");;
my $buffer = "";
foreach my $curclass (@classlist) {
$buffer = $buffer . $pglobals{$curclass."maxlvl"} . " [$curclass], " if (defined($qglobals{$curclass."maxlvl"}));
if (defined($qglobals{Bardmaxlvl})) { $buffer = $buffer . $pglobals{Bardmaxlvl} . " [$curclass], "; }
}
if (length($buffer) > 3) {
$buffer = substr $buffer, 0, length($buffer)-3;
quest::say("Server First Classes: " . $buffer);
}
quest::say("end");
}
}
|
|
|
|
|
|
|
09-19-2009, 10:57 PM
|
Hill Giant
|
|
Join Date: May 2005
Posts: 134
|
|
Quote:
Originally Posted by Shin Noir
Instead of copy pasting the code 15 times, you could do something like this:
Code:
sub EVENT_LEVEL_UP {
my $maxlvl = 50;
my @classlist = ("Warrior", "Cleric", "Paladin", "Ranger", "ShadowKnight", "Druid", "Monk", "Bard", "Rogue", "Shaman", "Necromancer", "Wizard", "Magician", "Enchanter", "Beastlord", "Berserker");
foreach my $curclass (@classlist) {
if(!defined($qglobals{$curclass."maxlvl"}) && $ulevel == $maxlvl && $curclass eq $class) {
quest::setglobal($curclass."maxlvl",$name,2,"F");
quest::shout2("$name has made the server first level $ulevel $class!");
return;
}
}
}
I think that may work. I'm storing the player's name in the variable instead of just a boolean flag in hopes that who knows, one day $pglobal will be loadable on NPC's.
|
I put this in to quests/template/player.pl. restarted server, and still nothing, makes me feel like i'm not putting this in the correct spot, or that #level 50 isn't triggering the sub EVENT_LEVEL_UP. idk which, any enlightenment would be appreciated.
|
|
|
|
09-19-2009, 11:42 PM
|
|
Legendary Member
|
|
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
|
|
It should. There may be an issue with scripts in the zone folder conflicting with the templates folder, just for testing try to put the player.pl inside the zone you're inside, and #reloadpl
|
09-19-2009, 11:52 PM
|
|
Legendary Member
|
|
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
|
|
Some quest coder should help me out here.. I'm not very familiar with it. :/ but!
LoadPlayerScript() function in embparser.cpp
it does this whole..
Code:
string filename= "quests/";
filename += zone;
filename += "/player.pl";
string packagename = "player";
packagename += "_";
packagename += zone;
build of the quests\zone\player.pl directory.. tries to eval it
Code:
try {
perl->eval_file(packagename.c_str(), filename.c_str());
}
then if it doesn't load,
Code:
if(!isloaded(packagename.c_str()))
{
filename = "quests/";
filename += QUEST_TEMPLATES_DIRECTORY;
filename += "/player.pl";
try templates. So if I'm not corrected, if a /<zone>/player.pl exists, it stops the parser from loading /templates/player.pl?
|
09-19-2009, 11:56 PM
|
Hill Giant
|
|
Join Date: May 2005
Posts: 134
|
|
did as suggested, tried it with the guild lobby, cut/paste the player.pl and #reloadpl, and worked. cut/paste back into templates folder, #reloadpl, doesn't work. now what I don't understand is there isn't anything in the guild lobby folder, cept the guildhall instance creation script, so i'm not seeing what would be conflicting with the EVENT_LEVEL_UP. btw is there a way to broadcast, instead of having "$name shouts, blah blah blah". was looking more for a system msg world wide, then having the player shout it world wide.
|
09-20-2009, 12:30 AM
|
|
Legendary Member
|
|
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
|
|
Try $client->Message(13, "Message here");
|
09-20-2009, 12:37 AM
|
|
Legendary Member
|
|
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
|
|
I really hate that 5 minute edit limit. So new post!
I'm working on a quest cheat sheet wiki. Not newb friendly, but a good quick reference is my objective.
This link should go to the $client->function() section, the message one and show the different color types noted in source.
|
09-20-2009, 12:55 AM
|
Hill Giant
|
|
Join Date: May 2005
Posts: 134
|
|
does $client->Message() broadcast worldwide, or just to the client that triggered the event?
|
|
|
|
09-20-2009, 01:05 AM
|
|
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
Yes, it will try to load the player.pl from the zone folder and if not there, it will load it from templates if one exists there. It would be nice if both could load and run simultaneously so you could have global stuff for player.pl as well as zone specific stuff.
I believe that for any scripts located in the templates folder, the server has to be restarted for them to take effect. Not 100% sure on that, but I think that was the conclusion I came to last time I tried playing around with it.
Also, some notes on your compilation of quest wiki pages:
EVENT_ENTER and EVENT_EXIT are both related to proximities, so they don't work from the player.pl. They are triggered when the client enters or exists a proximity around an NPC.
EVENT_SCALE_CALC is for item quest files, specifically for items with something set in the charmfile field. This event is for setting how much you want an item's stats to scale based on a percentage. Here is an example of a custom quest I made for a custom charm I have on my server:
/quests/items/CHRMTitanium.pl
Code:
sub EVENT_SCALE_CALC
{
if (defined($qglobals{titanium_relic})) {
$questitem->SetScale($qglobals{titanium_relic}/10);
}
else {
$questitem->SetScale(0);
}
}
Note that the quest is stored in a folder name "items" instead of a zone name. Also, note that CHRMTitanium from the file name is what needs to be placed in the charmfile field for the item.
|
|
|
|
09-20-2009, 01:07 AM
|
|
Legendary Member
|
|
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
|
|
Thanks trevius. and @ nightsta, hmm, that's a good question. Pretty sure it's possible, but can't think of a script I can pull up to find the function.
|
09-20-2009, 01:14 AM
|
Hill Giant
|
|
Join Date: May 2005
Posts: 134
|
|
Quote:
Originally Posted by trevius
Yes, it will try to load the player.pl from the zone folder and if not there, it will load it from templates if one exists there. It would be nice if both could load and run simultaneously so you could have global stuff for player.pl as well as zone specific stuff.
|
so basically what your saying is, for this to work, I have to go through every zone and place my level up script in each player.pl? that'll completely defeat the purpose of what i'm tryin to do. i'm tryin to make something similar to the achievement styles of wow. including leveling, mob slaying, and several other things, which requires the use of quest globals and things such as this. if I have to put my scripts into each and every zone player.pl, that'll be WAY to much work. is there any way of changing the source to read from both? or what is stopping it from using both scripts?
|
09-20-2009, 01:27 AM
|
|
Legendary Member
|
|
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
|
|
To use the scale event you utilize "quests/items/" folder? Interesting. Wonder how I'll categorize that.
Sorry for derailing topic nightsta. I'm unsure at your answer, we'll see!
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 09:25 AM.
|
|
|
|
|
|
|
|
|
|
|
|
|