Can you make a custom local type variable for quests?
Say kills or somthing and then once it hits 4 have an npc spawn.
if some can someone tell me how you define variables in perl? How does this look? Code:
$orcmysticsdead = 0; quest::unique_spawn(npc_type,grid,guildwarset,x,y, z,heading=0) |
The only way that counter would work is if there are several of those NPCs spawned already and no new NPCs of the same version spawn in between kills. If that is the case, then yes, the variable declaration is correct. Otherwise it seems you might be better off using quest globals. Also, the spawn definition is incorrect. The reason it says heading=0 is to let you either use a number or use nothing at all which will default to 0. And don't forget your condition check and semicolons..
$orcmysticsdead = $orcmysticsdead + 1; if ($orcmysticsdead == 4){ quest::unique_spawn(999149,0,0,1652,1535,-9,69); FYI: I am just basing off your script, not your title. The title asked for local variables. Remember, that local means only in your scope. This method "bleeds" over multiple scripts making it more global. Not the preferred method, but it can work. |
Ok it works if i just use
Code:
sub EVENT_DEATH { ahh ok i have my orcs respawning fast for testing purposes. Thats probably why. Hmmm im not too firmiliar with qglobals. I guess ill have to try that |
Quote:
|
Oh, it also seems I was editing my post while you were replying. Don't forget to check the update above.
EDIT: To make it local, you declare it in the scope you want to use it. To make it private, add the "my" identifier. sub whatever { my $localvariable = 0; $localvariable = 25; } Using it that way makes a variable available to only this sub. Looking at what you are doing above, you do not want a local variable. |
Quote:
yeah i know declaring in the sub would reset it when the events triggered. I dunno it seems kind of buggy the way im doing it. I mean id need it to trigger correctly for each player. I think that means i have to do q globals right? I tried that once and gave up cause i could never make it work lol. |
If you want it for each player, you have 2 options. Qglobals or tasks
If you want to use qglobals, ensure the NPC has quest globals enabled in the npc_types table. |
Quote:
I forgot about that, thats much easier. |
Yes, you would spawn it in perl upon task completion.
If you want to use globals, this might be what you are trying to do: (untested) Code:
sub EVENT_DEATH { |
FYI: Now that I am awake and rereading this, I missed a closing ) on line 2
|
Quote:
Lemme see if i understand what your doing here so i actually learn and dont have to beg people to write scripts for me lol. If its defined you set it to orcpawndeath +1, if its not defined you just set it to 1, when it hits 4, you reset it and spawn the mob. Do i have to enter this variable in to the database at all or just enable the qglobals on the mob like you said before |
Yup, you are reading this correct. You don't enter variables into the database. Just enable the qglobals for the npc. If you don't want it per player, then just change the options from 0 to 2.
|
Quote:
|
Ok this is no longer working. I also tried to do the same thing with a different quest, different variable ect.. it doesnt work.
Can anyone help me fix it or either write it for me? All i need is Somthing to keep track of how many of a certain mob the player has killed. If the player has killed 4, spawn another mob then reset so if the player kills 4 more it will respawn again. Actually if any player in the zone kills 4 of the mob id like it to spawn so it doesnt get messed up by other people stealing mobs |
Here is a script I use for similar situations that doesnt require globals. This assumes that you want the NPCs to respawn when the last is dead(regardless of kill credit), however the mobs can still respawn normally as well.
You would have an invis controller NPC with this script... Code:
sub EVENT_SPAWN |
All times are GMT -4. The time now is 02:14 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.