PDA

View Full Version : PC Global variable ?


KhaN
05-24-2004, 09:32 AM
I would like to know if there is a way to flag/set a variable available for a PC. This variable is attribued to a character and available on all NPC.

Scorpious2k
05-24-2004, 10:30 AM
setglobal will do it (assuming qglobal is set for the npc to get the global)

setglobal(varname,value,options,duration)

use option 5 for all zones, 1 for just this zone. This table might help with the option values:

------------------------------------------------------------------
value npcid player zone
------------------------------------------------------------------
0 this this this
1 all this this
2 this all this
3 all all this
4 this this all
5 all this all
6 this all all
7 all all all

Swampdog
05-24-2004, 02:17 PM
Aye.. Thats exactly what I posted in our forums a little bit ago for the one pet quest that I reserver a global for KhaN. :P

Great job on coding the quest::XXXglobals Scorp and Tark.. While we are on the subject, is there a function that you guys have set up where we can call a getglobals kinda function to check a variable setting for the current player? We are trying to set up a couple of quests which will create a static variable for that player upon completion of quest and the information would be pulled back.

I took a look at the code that is used by the NPCs up higher in parser.ccp. Basically looking to get a function done which will process the charID and for the existance of a specified variable name and if it exsists return the value. If this is something you guys have already and wouldn't mind sharing, it would be awesome! My sleep deprived state has me pulling hair out trying to figure it out. Sounds like it would be easy, but I haven't really dealt with handling the database interaction and not having a solid understanding of those functions I think is my downfall... :wink:

animepimp
05-24-2004, 03:46 PM
Look at Tark's original post demonstrating this. When you store the variable you give it a name like "var1". Then you can access it with $var1 and in an if you can do define $var1 to see if it exists. So you have to use methods to create it but its accessed like any other variable in perl.

Swampdog
05-24-2004, 05:56 PM
Yeah... I know how to access it within the perl quest code.. But there are some things we would like to set as permanent variables which are created through completion of a quest but accessed within the server code. So I'm trying to program a function that can retrieve the values from the quest_globals table and manipulate/compare against within different parts of the code. Does that make sense? Probably not.. Going on 48 hours without sleep..

I'll look at the code tomorrow after some sleep and try to post a better description then. Who knows, with sleep I might be able to figure it out as well... LOL

Scorpious2k
05-24-2004, 10:30 PM
Quest globals weren't really designed that way. They are supposed to appear like "magic", transparent to the quest script itself.

The bigger problem is in the perl implementation. It isn't really possible to pass a value back from the parser to the quest script. I'm looking at XS and will probably have something in to play with soon, which will eventually make it possible for the perl script to interact with the server functions.

Th quest global will still work for you though. Just use option 1 or 5 depending on if you want it world wide or zone specific, and the player specific variable will be available to NPCs you choose. Any NPC can change it, and those with qglobal set can check it.

Swampdog
05-25-2004, 05:11 AM
Thanks for the response Scorp.. What we are looking at doing with the current project is develop a quest which, once completed, will allow the player to permenantly name their pet. I'm going to be using the setglobal with option 5 so it is available to all NPCs in all zones and is player specific for each player.

So it will be saving the value in the quest_globals table where it should be available to pluck it out. My problem is plucking it out. I've looked at the code for GetRandPetName in spells.cpp and looked at your code in parser.cpp. I should be able to use the database query routine to grab the value and if it exsists to use it instead of grabbing a random name. I think I need to dig into the sql database interface and learn more about what the command structs you are using in the code for setglobal is doing when called so I can run a SELECT query and grab the value from quest_global.