Author Topic: How to restrict port to leader from certain areas  (Read 401 times)

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
How to restrict port to leader from certain areas
« on: July 28, 2011, 03:51:20 pm »


               Hi,

Can anyone help. I need to restrict the use of port to leader, how would I implement this restriction in the port to leader script.  I need it to check for certain areas so ie if in area "JAIL"  return and do nothing maybe float some txt "Not Possible in this area"

Thanks
               
               

               
            

Legacy_CID-78

  • Sr. Member
  • ****
  • Posts: 261
  • Karma: +0/-0
How to restrict port to leader from certain areas
« Reply #1 on: July 28, 2011, 04:53:05 pm »


               it's better to have a local int, which you can turn ON/OFF. You simply turn the variable ON/OFF when exiting/entering such a area instead. That way it will work in a more diverse environment.

and all you neeed to do is check the variable before you active the power.
               
               

               
            

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
How to restrict port to leader from certain areas
« Reply #2 on: July 28, 2011, 05:12:54 pm »


               Can you help me with this please
               
               

               
            

Legacy_CID-78

  • Sr. Member
  • ****
  • Posts: 261
  • Karma: +0/-0
How to restrict port to leader from certain areas
« Reply #3 on: July 28, 2011, 05:44:35 pm »


               hey you got all the stuff. you need to do the job.
               
               

               
            

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
How to restrict port to leader from certain areas
« Reply #4 on: July 28, 2011, 06:04:07 pm »


               I would not ask for the help if i could script

Thanks anyway
               
               

               
            

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
How to restrict port to leader from certain areas
« Reply #5 on: July 28, 2011, 06:38:15 pm »


               Ok I have had a go and cannot get this to work, Can anyone please help. this is what I have

void main()
{
  object oPC;
  oPC = GetItemActivator();
  if (!GetIsPC(oPC)) return;
  object oArea = OBJECT_SELF;

  if (GetLocalInt(oArea, "NOPORT") == 1)
  {
  return;
  SendMessageToPC(oPC, "You cannot use that item in jail...");
  }


  location lStart;
  object oSTART = GetWaypointByTag("Home");
  lStart = GetLocation(oSTART);


  AssignCommand(oPC, ClearAllActions());
  AssignCommand(oPC, ActionJumpToLocation(lStart));
  }
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
How to restrict port to leader from certain areas
« Reply #6 on: July 28, 2011, 07:02:27 pm »


               if (GetLocalInt(oArea, "NOPORT") == 1)
{
return;
SendMessageToPC(oPC, "You cannot use that item in jail...");
}

needs to be:

if (GetLocalInt(oArea, "NOPORT") == 1)
{
SendMessageToPC(oPC, "You cannot use that item in jail...");
return;
}

Otherwise it'll exit without sending the message.

Also, change:
object oArea = OBJECT_SELF;
to:
object oArea = GetArea (oPC);

OBJECT_SELF in this script is likely the module.
               
               

               


                     Modifié par Failed.Bard, 28 juillet 2011 - 06:03 .
                     
                  


            

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
How to restrict port to leader from certain areas
« Reply #7 on: July 28, 2011, 07:20:51 pm »


               Thanx Bard

All working now
               
               

               
            

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
How to restrict port to leader from certain areas
« Reply #8 on: July 28, 2011, 07:21:38 pm »


               '<img'>
               
               

               


                     Modifié par Madasahatter, 28 juillet 2011 - 06:21 .
                     
                  


            

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
How to restrict port to leader from certain areas
« Reply #9 on: July 28, 2011, 09:21:28 pm »


               Ok Thanks to Bard im now using this for my leader potion -

void main()
{

object oPC;
oPC = GetItemActivator();
object oItem     = GetItemActivated();
object oTarget   = GetItemActivatedTarget();
if (!GetIsPC(oPC)) return;
object oArea = GetArea (oPC);

if (GetLocalInt(oArea, "NOPORT") == 1)
{
SendMessageToPC(oPC, "You cannot use that item in jail...");
return;
}

object oLead;
location lLead;
oLead = GetFactionLeader(oPC);
lLead = GetLocation(oLead);

if (GetAreaFromLocation(lLead)==OBJECT_INVALID) return;
AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, ActionJumpToLocation(lLead));
}


Problem I have is that I need to restrict its use so that if the party leader in in jail they cannot port there. I would be greatfull If anyone could help me alter this script.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
How to restrict port to leader from certain areas
« Reply #10 on: July 28, 2011, 10:19:36 pm »


               could try something like so:


//#include "x2_inc_switches"
void main()
{
    //If this is a tag based script for an activated item then you should also
    //have this check in the script and uncomment the include above.
    //int iEvent = GetUserDefinedItemEventNumber();
    //if (iEvent != X2_ITEM_EVENT_ACTIVATE) return;

    object oPC = GetItemActivator();
    object oItem = GetItemActivated();
    object oTarget = GetItemActivatedTarget();
    if (!GetIsPC(oPC)) return;
    object oArea = GetArea(oPC);

    if (GetLocalInt(oArea, "NOPORT") == 1)
    //if you are only restricting potion use from jail you really only need to
    //compare the tag of the area. So you could also use the line below:
    //if (GetTag(oArea) == "Tag of jail area")
    {
        SendMessageToPC(oPC, "You cannot use that item in jail...");
        return;
    }

    object oLead = GetFactionLeader(oPC);
    location lLead = GetLocation(oLead);
    if (GetAreaFromLocation(lLead)  ==  OBJECT_INVALID ||
        GetTag(GetArea(oLead)) == "Tag of jail area")
    {
        SendMessageToPC(oPC, "Your leader is not in a valid area or is in jail. You can not port.");
        return;
    }

    AssignCommand(oPC, ClearAllActions());
    AssignCommand(oPC, ActionJumpToLocation(lLead));
}
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
How to restrict port to leader from certain areas
« Reply #11 on: July 28, 2011, 10:36:44 pm »


               I do something like this in my Server.

I have 'worlds' within my server.

When one player is on one world, they can only port to players on the same planet.
Otherwise, they get an 'Out of Range' message.


to do this, just set a Local Int on the areas, the int value, determines the world.
if the World_Val  for player1's area = the World_Val of player2's Area - allow the port.
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
How to restrict port to leader from certain areas
« Reply #12 on: July 29, 2011, 12:38:44 am »


               Doing a local on the area No_Port is the way I do it too. But I would leave the message simply you cannot portal into or out of this area. Rather than just jail. For in the future you may wish to add another no port area. I don't allow porting into or out of underground areas for instance. The reason for this is multi-faceted. For instance say you have a thief or someone with invisibility. Then that player as party leader sneaks into where the boss monster is, sends a tell to the party who then buff up and port to the party leader ready to fight the boss without having gone through any outer defenses that boss might of had. In further regard to your jail I did make a bail-out for those in jail where you can bail them out for 500 gold x their level.
               
               

               


                     Modifié par ffbj, 28 juillet 2011 - 11:40 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
How to restrict port to leader from certain areas
« Reply #13 on: July 29, 2011, 12:56:55 am »


               For completeness here is mine:

//leader crystal  by ffbj
#include "x2_inc_switches"
#include "x3_inc_horse"
void main()
 { int nEvent =GetUserDefinedItemEventNumber();
     if (!nEvent == X2_ITEM_EVENT_ACTIVATE)
     return;
       {
       object  oPC =  GetItemActivator();
       object oItem = GetItemActivated();
       object oArea = GetArea(oPC);
       object oPCL = GetFactionLeader(oPC);
       object oArea1 = GetArea (oPCL);
       object oDatabase = GetItemPossessedBy(oPC, "database");
    if ((GetLocalInt(oDatabase, "MountedI") > 0) || (HorseGetIsMounted(oPC)))
          {
       SendMessageToPC(oPC, "You must Dismount to use this item.");
       return;
          }
       if (oArea == oArea1)
        {
       DelayCommand(1.0, AssignCommand(oPC, JumpToObject(GetFactionLeader(oPC))));
        return;
        }
       if ((GetLocalInt(oArea, "No_Port") == 1)|| (GetLocalInt(oArea1, "No_Port") == 1))
                {
               SendMessageToPC(oPC, "You can't teleport into/out of this area.");
               return;
                }
 
           {
         effect eFly;
         effect eFlyWind;
         eFly = EffectDisappear();
         eFlyWind = EffectVisualEffect(VFX_IMP_PULSE_WIND);
         DelayCommand(1.0,ApplyEffectToObject(DURATION_TYPE_INSTANT, eFly, oPC));
         DelayCommand(1.2, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eFlyWind, GetLocation(oPC)));
         DelayCommand(2.0, FadeToBlack(oPC, FADE_SPEED_FASTEST));
         DelayCommand(3.2, FadeFromBlack(oPC, FADE_SPEED_FASTEST));
         DelayCommand(3.4, AssignCommand(oPC, JumpToObject(GetFactionLeader(oPC))));
         }
}
}
It checks if the activator or the leader is in a No_Port area.  Done simply by putting the variable No_Port set to 1 on the area. It also checks if the activator is mounted, and won't let you teleport either.  Of course that's specific to my world as all mounted PC's have an item which marks them as mounted.  For many items I don't allow mounted players to use them.  It does a different sort of animation for whether the PC and leader are in the same area.  Then it simply teleports the activator.  Otherwise it does the leaping into the air animation.  This is in line with my restriction of portalling only when both PC's are in outdoor area.