World of Harry Potter Forums
http://forums.wohp.net/

Script Help?
http://forums.wohp.net/viewtopic.php?f=1&t=1587
Page 1 of 1

Author:  D_Black [ Sun Mar 02, 2008 6:25 pm ]
Post subject:  Script Help?

I am having trouble writing a script for a mod I am toying around with. Its suppose to be a simple transition restriction script; or so I thought.

I keep getting the following error message on Line 10: "ERROR: VARIABLE DEFINED WITHOUT TYPE"
Code:
void main()
{

object oPC = GetLastUsedBy();

if (!GetIsPC(oPC)) return;

if (GetItemPossessedBy(oPC, "RRToken")== OBJECT_INVALID)
   {
   sDeny="This portal needs the RR Token to activate. You apparently do not possess an RR Token.";

   SendMessageToPC(oPC, sDeny);

   return;
   }

object oTarget;
location lTarget;
oTarget = GetWaypointByTag("RRenter");

lTarget = GetLocation(oTarget);

if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

AssignCommand(oPC, ClearAllActions());

AssignCommand(oPC, ActionJumpToLocation(lTarget));

}


Thank you to anyone who can help. :)

Author:  Freydis_The_Valkyrie [ Sun Mar 02, 2008 7:05 pm ]
Post subject: 

Whoa... That looks like Java.

Shouldn't that first line be "public static void main(String[] args)"?

Author:  Insanity [ Mon Mar 03, 2008 9:15 am ]
Post subject: 

Nah, pretty much all NWN scripts start with
Code:
void main()

Author:  ChanceFerrin [ Mon Mar 03, 2008 3:44 pm ]
Post subject: 

D_Black, Could you a bit more specific? What are you dealing with Exactly? I know it a Transition Restriction, but for what?

Author:  D_Black [ Mon Mar 03, 2008 4:32 pm ]
Post subject: 

Its to be placed on a placeable object in the "On Used" of the script categories.

Not sure exactly what specifics you're looking for. If you mean its function then its suppose to be an item that when clicked transports you t a different area. Except if you don't have the required item to transition than you get a system message saying that you can't pass unless you have the item...

Author:  diabosatan [ Mon Mar 03, 2008 5:36 pm ]
Post subject: 

There you go, in case you need more help, ask. :)



Quote:
void main()
{

object oPC = GetLastUsedBy();

if (!GetIsPC(oPC)) return;

if (GetItemPossessedBy(oPC, "RRToken")== OBJECT_INVALID)
{

//Every single variable you use must be declared. :)
string sDeny;

sDeny="This portal needs the RR Token to activate. You apparently do not possess an RR Token.";

SendMessageToPC(oPC, sDeny);

return;
}

object oTarget;
location lTarget;
oTarget = GetWaypointByTag("RRenter");

lTarget = GetLocation(oTarget);

if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

AssignCommand(oPC, ClearAllActions());

AssignCommand(oPC, ActionJumpToLocation(lTarget));

}




If you want something more organized.


Quote:
//DiaboSatan likes to help :D

void main()
{

object oPC = GetLastUsedBy();
//Checks if the player has the item, if positive jump him to "RRenter"
if (GetItemPossessedBy(oPC, "RRToken")!=OBJECT_INVALID)
{
object oTarget = GetWaypointByTag("RRenter");
location lTarget = GetLocation(oTarget);
AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, ActionJumpToLocation(lTarget));
}
//If negative, he'll get that message.
else
{
string sDeny="This portal needs the RR Token to activate. You apparently do not possess an RR Token.";
SendMessageToPC(oPC, sDeny);
}
}

Author:  JBMT [ Mon Mar 03, 2008 7:46 pm ]
Post subject: 

I love how it emoticon'd the smiley in your code comment.

Author:  diabosatan [ Tue Mar 04, 2008 4:17 am ]
Post subject: 

Neither Delphi nor Dev C++ are able to do that emoticon, by the way :D
hahahahaha

Author:  D_Black [ Thu May 22, 2008 9:32 pm ]
Post subject: 

I finally got around to testing out that script and it works great. Thanks for the help. :D

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/