Noob alert!
I have a number of scripts that check a single string or integer for values and act accordingly. For example, the script below prevents a script from running if the PC is in certain areas.
// Prevent if is during debate or in the inn
string sArea = GetTag(GetArea(oPC));
if ((sArea == "a_bt_int_town_hall_debate") || (sArea == "a_bt_int_inn_ground")) return;
My question is, how can a list of AND (&&) or OR (||) conditions be better scripted? I can imagine it would get very messy if I had 6 areas that would end the script above.
Thanks
An easier way?
Débuté par
El Condoro
, janv. 22 2011 06:48
#1
Posté 22 janvier 2011 - 06:48
#2
Posté 22 janvier 2011 - 08:13
For better readability you can make the list go vertical rather than into limbo off to the right. Something like:
if (sArea == "Area1" ||
sArea == "Area2" ||
sArea == "Area3" ||
sArea == "Area4")
I think that's pretty much it as far as I know. But I'm kind of a noob myself. Good luck.
if (sArea == "Area1" ||
sArea == "Area2" ||
sArea == "Area3" ||
sArea == "Area4")
I think that's pretty much it as far as I know. But I'm kind of a noob myself. Good luck.
Modifié par GhostOfGod, 22 janvier 2011 - 08:13 .
#3
Posté 22 janvier 2011 - 08:26
I'm wondering if it's as simple as using a colon.
if (sArea == "Area1" : "Area2" : "Area3" etc. )
if (sArea == "Area1" : "Area2" : "Area3" etc. )
#4
Posté 22 janvier 2011 - 09:04
An easier way might be to include a certain string combination that your script could check for in the area tag. For example, if you wanted those areas to not be cleaned OnEnter or whatever, you might tag an area "Area2_NOCLN" or something. Then you use FindSubString(GetTag(oArea)) to check for it.
#5
Posté 22 janvier 2011 - 11:36
Both GoG's and MC's suggestions are valid. Personally I use GoG's method (for easier readability as stated there). For an alternative of MC's idea, I do something like: tagging the area/object with a specific "code" (like the "*_NOCLN" idea), but instead of using the FindSubString() function, I use:
if(GetStringRight(GetTag(oArea), 5) == "NOCLN") return;
if(GetStringRight(GetTag(oArea), 5) == "NOCLN") return;
Modifié par _Knightmare_, 22 janvier 2011 - 11:37 .
#6
Posté 22 janvier 2011 - 12:15
Or you can put a variable on the area and then just check for that variable with GetLocalInt. This could be better in case you did not want to change area tags from some reason. Otherwise its the same.
#7
Posté 22 janvier 2011 - 01:43
I have used the area tags in other scripts already so ShaDoOoW's use of local variables on the area may be the way to go. Thanks for the tips, guys. Cheers.





Retour en haut






