Author Topic: PC check  (Read 319 times)

Legacy_Surek

  • Full Member
  • ***
  • Posts: 169
  • Karma: +0/-0
PC check
« on: June 13, 2013, 06:07:27 am »


               I was hopeing somone can help.This is supposed to check if any other pcs are in the area if so stop script if no other pcs continue with script. but it does not compile please let me know what I did wrong and how to fix it. Sorry i'm dumb when it comes to scripting don't laugh please   ':unsure:'

void main(){object oPC = GetEnteringObject();if (!GetIsPC(oPC)) return;
int GetIsOtherPCsInArea(object oArea = OBJECT_SELF){ object oPC = GetFirstObjectInArea(oArea);if(!GetIsPC(oPC))oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC,oPC); return (GetIsPC(oPC)) ? TRUE : FALSE;}




object A = CreateObject(OBJECT_TYPE_CREATURE, "corruptguard", GetLocation(GetWaypointByTag("SP_A")));object B = CreateObject(OBJECT_TYPE_CREATURE, "bandit", GetLocation(GetWaypointByTag("SP_B")));object C = CreateObject(OBJECT_TYPE_CREATURE, "bandit", GetLocation(GetWaypointByTag("SP_C")));}} 
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
PC check
« Reply #1 on: June 13, 2013, 07:30:09 am »


               

Surek wrote...

I was hopeing somone can help.This is supposed to check if any other pcs are in the area if so stop script if no other pcs continue with script. but it does not compile please let me know what I did wrong and how to fix it. Sorry i'm dumb when it comes to scripting don't laugh please   ':unsure:'

void main(){object oPC = GetEnteringObject();if (!GetIsPC(oPC)) return;
int GetIsOtherPCsInArea(object oArea = OBJECT_SELF){ object oPC = GetFirstObjectInArea(oArea);if(!GetIsPC(oPC))oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC,oPC); return (GetIsPC(oPC)) ? TRUE : FALSE);}




object A = CreateObject(OBJECT_TYPE_CREATURE, "corruptguard", GetLocation(GetWaypointByTag("SP_A")));object B = CreateObject(OBJECT_TYPE_CREATURE, "bandit", GetLocation(GetWaypointByTag("SP_B")));object C = CreateObject(OBJECT_TYPE_CREATURE, "bandit", GetLocation(GetWaypointByTag("SP_C")));}} 


the extra  )   is the only thing i see at a quick glance


edit:   I guess it was not extra just in the wrong spot move to after the FALSE.
               
               

               


                     Modifié par Lightfoot8, 13 juin 2013 - 06:33 .
                     
                  


            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
PC check
« Reply #2 on: June 13, 2013, 02:42:34 pm »


               You've got a function defined within your main function. I think what you are trying to do is something like this: (Probably gets format mangled and I may have the logic you want backwards - I couldn't quite parse your description...)


int GetIsOtherPCsInArea(object oArea = OBJECT_SELF)
{
   object oPC = GetFirstObjectInArea(oArea);
   if(!GetIsPC(oPC))
      oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC,oPC);
   return (GetIsPC(oPC)) ? TRUE : FALSE;
}

void main()
{
   object oPC = GetEnteringObject();
   if (!GetIsPC(oPC)) return;

   if (GetIsOtherPCsInArea()) return;

         object A = CreateObject(OBJECT_TYPE_CREATURE, "corruptguard", GetLocation(GetWaypointByTag("SP_A")));
   object B = CreateObject(OBJECT_TYPE_CREATURE, "bandit", GetLocation(GetWaypointByTag("SP_B")));
   object C = CreateObject(OBJECT_TYPE_CREATURE, "bandit", GetLocation(GetWaypointByTag("SP_C")));
}
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
PC check
« Reply #3 on: June 13, 2013, 02:43:34 pm »


               That is to say this:

if (GetIsOtherPCsInArea()) return;

may want to be :

if (!GetIsOtherPCsInArea()) return;