Aller au contenu

Photo

Teleporting PCs on client enter


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

#1
Grani

Grani
  • Members
  • 554 messages

I want to teleport a PC to a waypoint as soon as it enters the module, but I can't assign any commands to it until the PC actually "materializes" in the area it logs in (either the module's starting area or the spot the PC last logged out in).

 

One solution that would probably work would be to use the area OnEnter event instead of the module-wide OnClientEnter, but this would require me to put an OnEnter script in every area's module event, not to mention modify the OnEnter scripts that some areas already have to include this functionality.

 

I've tried using a loop that continues until GetArea(oPC) returns a valid object and then make the jump, but it didn't work for reasons I haven't investigated further.

 

So, any ideas?



#2
KMdS!

KMdS!
  • Members
  • 189 messages

Here is a simple Function to teleport a PC to any valid location you may pass using the lDest variable.

void Transport(object oPC, location lDest)
{
    if (!GetIsObjectValid(oPC))
        return;
    if (!GetIsObjectValid(GetArea(oPC)))
    {
        DelayCommand(1.0, Transport(oPC));
    }
    else if(GetTag(GetArea(oPC)) != "Tag of area desired")
    {
        AssignCommand(oPC, JumpToLocation(lDest));    
    }
}

Because of the AssignCommand,It will jump the player to the location after the algorythm terminate and will reattempt every 1.0 seconds until the PC is in a valid location. You can call this from either the onenter module event or the onenter area event.

 

As to implementation from your areas onenter, but best is to place in your modules onenter event as it is the first event to fire on a pc. You can create an include script something like HCR had.

// inc_on_ae
 
int preEvent()
{
    Transport(oPC, lDest);
    return TRUE;
}
 
void postEvent()
{
    return TRUE;
}
Place an include into the event script you desire affected and place preEvent() as the very first call in your void main  and the postEvent() as the last call. Place any routine you wish to run within those functions and you can affect all event scripts containing the include. If you wish not to affect a certain area, just place a conditional pertaining to the area as a check.
 
I set an area check in the include script example above to make sure the PC is only jumped once. If not exactly what you need, I can modify if I know more about what you need.
 
If you don't want the pc to see anything until they arrive on destination a black out and fade from black can be set up as well.


#3
Tarot Redhand

Tarot Redhand
  • Members
  • 2 674 messages

Why does it have to be in the OnEnter/OnClientEnter? What's wrong with a "holding" area for when a PC accesses the module? Then it is a simple matter to use an OnExit script for this area to teleport them to precisely where you want them to go.

 

TR



#4
Shadooow

Shadooow
  • Members
  • 4 468 messages

I use starting area OnEnter as "First Client Enter" event, where I am teleporting them to last position. Its better solution that doing this with delays in normal OnClientEnter trust me.



#5
Grani

Grani
  • Members
  • 554 messages

The thing is, PCs that log out will return to the place they logged out in, so I can't use a starting area OnEnter or OnExit only. I'd need to account for all areas in the module.

I want them to be teleported even if they logged in and logged out.



#6
Grani

Grani
  • Members
  • 554 messages

 

Here is a simple Function to teleport a PC to any valid location you may pass using the lDest variable.

void Transport(object oPC, location lDest)
{
    if (!GetIsObjectValid(oPC))
        return;
    if (!GetIsObjectValid(GetArea(oPC)))
    {
        DelayCommand(1.0, Transport(oPC));
    }
    else if(GetTag(GetArea(oPC)) != "Tag of area desired")
    {
        AssignCommand(oPC, JumpToLocation(lDest));    
    }
}

Because of the AssignCommand,It will jump the player to the location after the algorythm terminate and will reattempt every 1.0 seconds until the PC is in a valid location. You can call this from either the onenter module event or the onenter area event.

 

As to implementation from your areas onenter, but best is to place in your modules onenter event as it is the first event to fire on a pc. You can create an include script something like HCR had.

// inc_on_ae
 
int preEvent()
{
    Transport(oPC, lDest);
    return TRUE;
}
 
void postEvent()
{
    return TRUE;
}
Place an include into the event script you desire affected and place preEvent() as the very first call in your void main  and the postEvent() as the last call. Place any routine you wish to run within those functions and you can affect all event scripts containing the include. If you wish not to affect a certain area, just place a conditional pertaining to the area as a check.
 
I set an area check in the include script example above to make sure the PC is only jumped once. If not exactly what you need, I can modify if I know more about what you need.
 
If you don't want the pc to see anything until they arrive on destination a black out and fade from black can be set up as well.

 

 

Thanks, that's a good idea. :)



#7
henesua

henesua
  • Members
  • 3 863 messages

so this is not for recording last PC location and teleporting them to it when they enter the module after reset?



#8
Grani

Grani
  • Members
  • 554 messages

so this is not for recording last PC location and teleporting them to it when they enter the module after reset?

 

Not really - what I needed was teleporting PCs to an area no matter whether they log in for the first time after reset or come back after logging out.



#9
henesua

henesua
  • Members
  • 3 863 messages

Interesting feature. I might bother you about it for some answers when i catch you in chat.


  • Grani aime ceci

#10
Failed.Bard

Failed.Bard
  • Members
  • 774 messages

Would using nwnx to remove the players turd on exit be an option?  That should reset their location on login to the module start location.



#11
Tarot Redhand

Tarot Redhand
  • Members
  • 2 674 messages

For those that don't know, the above is not being rude. Bioware employees in their infinite wisdom decided to call a certain data type a turd and is an acronym of "Temporary User Resource Data".

 

TR


  • Asymmetric, Grymlorde et Grani aiment ceci

#12
KMdS!

KMdS!
  • Members
  • 189 messages

OMG, ROFL, I think we all appreciate the heads up Tarot.

 

Anyway, removing the "turd" would have the player logging back into the default start location as you posted, Failed, unless you actually edited the info using something like moneo, or posibly Leto from within the module, but that is something most likely beyond the experience of most.