Failure to build two portals

So i did some research and made a string DESTINATION: objecttag which is my portal the variable is in both portals the destination that is… so im trying to build a code for onused and not sure if i’m doing it the right way i want to teleport from each of those two portals ((Shafts of lights)) if we have wyvern blood in inventory, i keep getting errors so far

#include “x0_i0_transport”
#include “nw_i0_plot”

void main()
{
object oPC = GetLastUsedBy();
if(HasItem(oPC, “X3_IT_WYVERNBLD”) == TRUE)
if( !GetIsObjectValid(oDestination)) return;
object oDestination = GetObjectByTag(GetLocalString(OBJECT_SELF, “DestinationTAG”));
}
TransportToWaypoint(oPC, oDestination);
return;
}

else
{
// The PCSpeaker does not have wyverns blood.
// Do stuff here
}
}

That’s actually looking pretty good. :smiley: Go research!

OK, problems:

Each opening bracket { corresponds to a closing bracket }. At the line just below where you declare and define object oDestination, void main is closing. The same goes for your if condition - you’re using a closing bracket without a corresponding opening one.

In the validity check, you’re trying to use object oDestination before it has been declared. Move the declaration of oDestination up above. For cleanness, I’d suggest declaring the tag separately at the top as well.

Example:

#include "x0_i0_transport"
#include "nw_i0_plot"

void main()
{
    object oPC = GetLastUsedBy();
    string sItemTag = "X3_IT_WYVERNBLD";
    string sTag = GetLocalString(OBJECT_SELF, "DestinationTAG");
    object oDestination = GetObjectByTag(sTag);

    // If the destination object does not exist, abort.
    if(!GetIsObjectValid(oDestination))
        return;

    // The player has the required item.
    if(HasItem(oPC, sItemTag))
        {
        TransportToWaypoint(oPC, oDestination);
        }
    // The player does not have the required item.
    else
        {
        // Do stuff here
        }
}

Sidenote: You can post your code like this to keep the formatting, for readability: [code] insert code here [/code]

SHARE
TWEET

meow
A GUEST MAY 31ST, 2018 0 NEVER

NOTE: Your guest paste has been posted. If you sign up for a free account, you can edit and delete your pastes!
rawdownloadcloneembedreportprint text 0.39 KB
#include “x0_i0_transport”
#include “nw_i0_plot”

void main()
{
object oPC = GetLastUsedBy();
object oDestination = GetObjectByTag(GetLocalString(OBJECT_SELF, “DESTINATION”));
if(HasItem(oPC, “X3_IT_WYVERNBLD”) == TRUE)
if( !GetIsObjectValid(oDestination)) return;
}
TransportToWaypoint(oPC, oDestination);

}

else
{
void SendMessageToPC(oPC,“I need Wyvern Blood”); }

}
}

My new code but doesnt work still

It works thanks so much i learn :slight_smile:

1 Like

A couple of quick notes here.

Get notepad++ and Fancy Colors. The reason why is that you can then copy and paste your code into np++. Why would you do that? Notepad++ has a nifty feature whereby if you position your mouse cursor next to one of these - ( or { - it highlights the matching one in red thus making it easy to check that what you think you have enclosed is what you actually have. If you have any problem with getting fancy colors to work just pm me and I’ll guide you through installing it (hint there is a trick to it).

The other thing is to do with posting code in these forums. If you put [code] before your code and [/code] after it will retain its formatting. There are other tips to using these forums to be found in this pinned thread.

TR

1 Like

Sweeet thanks :slight_smile: great forums and community!