Stream Posted January 25, 2008 Share Posted January 25, 2008 First I apologise for the dodgy title, I couldn't think of what to call this. What I'm wondering is - Is there anyway of having a conditional in a script that checks to see if the PC is within a certain range of an NPC? I have this script so far which works fine but I'd like it to only work if the PC is within say 5 meters of the NPC; void main() { object oNPC = GetObjectByTag("kas25_secura"); if ((GetPartyMemberByIndex(1) == OBJECT_INVALID) && (GetPartyMemberByIndex(2) == OBJECT_INVALID) && (GetGlobalBoolean("test_test")==0)) { AssignCommand(oNPC, ActionStartConversation(GetFirstPC(), "", 0, 0, 0, "", "", "", "", "", "", 0, 0xFFFFFFFF, 0xFFFFFFFF, 0)); SetGlobalBoolean("test_test",1); } else { if ((GetGlobalBoolean("test_test")==0)) ExecuteScript("Deadly_Exit_1", OBJECT_SELF, 1002); } } I'm not sure if this is possible or not, I hope it is do I'll have to rethink how to implement the script. Kind Regards --Strean Link to comment Share on other sites More sharing options...
lactose_ Posted January 26, 2008 Share Posted January 26, 2008 Try this: void main() { object oNPC = GetObjectByTag("kas25_secura"); if ((GetPartyMemberByIndex(1) == OBJECT_INVALID) && (GetPartyMemberByIndex(2) == OBJECT_INVALID) && (GetGlobalBoolean("test_test")==0)) [color=Yellow]&& (GetDistanceBetween(oNPC, OBJECT_SELF) <= 5.0)[/color] { AssignCommand(oNPC, ActionStartConversation(GetFirstPC(), "", 0, 0, 0, "", "", "", "", "", "", 0, 0xFFFFFFFF, 0xFFFFFFFF, 0)); SetGlobalBoolean("test_test",1); } else { if ((GetGlobalBoolean("test_test")==0)) ExecuteScript("Deadly_Exit_1", OBJECT_SELF, 1002); } } Link to comment Share on other sites More sharing options...
Stream Posted January 26, 2008 Author Share Posted January 26, 2008 Yeah that's got it working right now, thanks very much for your help --Stream Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.