Require expert qglobal Help
I need a bit of help with understanding why a certain part of my qglobal is not working properly. I'm posting (below) the entire quest script (player.pl in the C:\EQEmu\quests\templates folder) just in case it's need. You can scroll past the sub EVENT_ENTERZONE section to the sub EVENT_TIMER--and in particular to the "if ($qglobals{kingdomfaction} == 1)" section under that EVENT--which is where the issue is.
Every "positive" action in that section works as it should: i.e., (1) it checks the faction of the player and sets a global flag for them that casts the correct level buff to members of the faction who hold the ring, and it changes the flag and stops casting buffs to the members of the faction that lost the ring; (2) it simultaneously confers guild membership ("quest::setguild(1,1);") to those of the right faction. However, for some reason it doesn't perform the corresponding "negative" actions that follow loss of the ring, such as fading the buff of those who are now of the wrong faction ("$client->BuffFadeBySpellID();"), or changing their guild membership to the designated guild ("quest::setguild(0,1);"). Any help would be most appreciated. Code:
sub EVENT_ENTERZONE |
Normally when I debug a quest script to see what went wrong, I will just put a say message for each part of the script leading up to what I think is the problem area. Then, I just watch to see how far the say messages get and work on the part right after it stops sending the say messages. In the case of player.pl, you can't use the say messages, but you can use quest::ze() to do zone emotes for debugging your player.pl. I would recommend adding in zone emotes for each of your elsifs around your problem areas and see if it gets to that point. If it isn't making it that far even, maybe you need to try placing a few other zone emotes until you can find it. This technique actually works really well for script troubleshooting, since the script will run all of the way up to the breaking point.
|
Using an IDE with code highlighting might help too, in case you're not. Could tell you if you're missing any brackets as well.
|
I don't think there's any question about just where it's failing. It performs every function up to (but not including) the following "elsif" section. Nothing in this section is working:
Code:
elsif ($client->FindBuff(5257) || $client->FindBuff(3467) || $client->FindBuff(1447) || $client->FindBuff(3692) || $client->FindBuff(312)) |
I've never had much confidence in elsif statements, thats just me. I'll normally use if statements and/or contradicting if statements to make it work. Not sure how true this is, never tested it, but I found this on one of the quest wiki things.
Quote:
I could be wrong but I see this as: Player zones in and it checks for item 13732 If player has item 13732 he/she gets aggro from a mob every 20 seconds until they leave the zone. If they delete/lose item 13732 they still get aggro cause it only checks for the item when they zone in. This timer repeats every 20 seconds If player doesn't have item 13732 when they zone in If checks for the global set by some other npc or script not listed here. I'd use quest::setglobal("kingdomfaction", 1, 5, "F"); for this one (All zones, All NPC, This player only) Depending on the value of the global it checks for factionlevel and player level So to make it simple a player will get a different buff depending on the qglobal/faction>850/playerlevel If the player's factionlevel is less than 850 it checks to see if they have the buff depending on qglobal setting If the player has the buff it debuffs them and changes their guild only if the qglobal was set at 1 If the player doesn't have the buff it does nothing. This timer repeats every one second |
Thanks Capheus, I'll try the final "elsif" as an "else" instead, just as soon as I can get my global watchers in place again (deleted in my recent code update).
Quote:
Once that faction is displaced by another faction in the global flag, the first faction should be removed from the guild and placed in a different guild (that's one of the parts not currently working). Simultaneously, the script should fade the buff found on any player of the first faction (again, this is one of the parts not currently working). Instead, the buff stays until it fades due to expired buff duration. Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
Ok good that clarified a few things. And yes try to work out the if,elsif,else thing. If it were me I would just stick with if and get rid of the elsif and else statements. Now for the global.
With quest::setglobal("kingdomfaction", 1, 5, "F"); Its all zones, all npc and this player only With quest::setglobal("kingdomfaction", 1, 7, "F"); Its all zones, all npc and all players If you have several players each with this global, it could possibly confuse itself between players. Or another way of looking at it, it might not be able to tell which player should have what global setting, it is calling all the players the same person (if that remotely makes sense). A global setting of 5 instead of 7 will give each person their own global setting/designation. |
Okay, after hours of testing I found the problem. In the original, the final "elsif" looked like this:
Code:
elsif ($client->FindBuff(5257) || $client->FindBuff(3467) || $client->FindBuff(1447) || $client->FindBuff(3692) || $client->FindBuff(312)) Code:
elsif ($client->FindBuff(5257 || 3467 || 1447 || 3692 || 312)) |
Scratch that last post--the original was right after all. It's just that the condition (if ($qglobals{kingdomfaction} == 1)) had not been met when I was testing it. Once I met the condition, and tested it with a character whose faction level was below acceptable, it worked like a charm.
|
All times are GMT -4. The time now is 05:29 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.