Aller au contenu

Photo

How to restrict port to leader from certain areas


  • Veuillez vous connecter pour répondre
13 réponses à ce sujet

#1
Madasahatter

Madasahatter
  • Members
  • 111 messages
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

#2
CID-78

CID-78
  • Members
  • 1 124 messages
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.

#3
Madasahatter

Madasahatter
  • Members
  • 111 messages
Can you help me with this please

#4
CID-78

CID-78
  • Members
  • 1 124 messages
hey you got all the stuff. you need to do the job.

#5
Madasahatter

Madasahatter
  • Members
  • 111 messages
I would not ask for the help if i could script

Thanks anyway

#6
Madasahatter

Madasahatter
  • Members
  • 111 messages
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));
}

#7
Failed.Bard

Failed.Bard
  • Members
  • 774 messages
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 .


#8
Madasahatter

Madasahatter
  • Members
  • 111 messages
Thanx Bard

All working now

#9
Madasahatter

Madasahatter
  • Members
  • 111 messages
:)

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


#10
Madasahatter

Madasahatter
  • Members
  • 111 messages
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.

#11
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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));
}

#12
Baaleos

Baaleos
  • Members
  • 1 330 messages
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.

#13
ffbj

ffbj
  • Members
  • 593 messages
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 .


#14
ffbj

ffbj
  • Members
  • 593 messages
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.