Objective script "Bad Syntax"

Have questions about CoD/UO mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
User avatar
Moriar
CJ Newbie
CJ Newbie
Posts: 88
Joined: March 12th, 2006, 8:15 pm
Location: The Netherlands

Objective script "Bad Syntax"

Post by Moriar » August 28th, 2006, 7:35 pm

I dont get this,

Im not very good in scripting, I know some basics, but I dont get it, whats wrong with this script?
BTW: this is the only script in the map (has the same name as the map, so it should work)


This is an objective script

Code: Select all

main()
{
	thread objective()

objective()

trig_obj = getent ("smile1objectivestart","targetname");
trig_loc = getent ("smile1objectiveend","targetname");
obj = getent ("smile1knife","targetname");

while(1)
{
trig_obj waittill ("trigger",user);
user.holdobj = 1;
user thread watchobj();
obj hide();
trig_obj thread maps\mp\_utility::triggerOff();

user iprintln("Use the knife to get yourself through the shrubs!");
while(user.holdobj == 1)
{
	if(user isTouching(trig_loc))
	{
		user iprintln("You have chopped all parts of the shrubs and you are able to walk through it");
		user iprintln("Well done!");
		wait 2;
		smile1obstakel moveZ (-100, 1);
		smile1obstakel waittill ("movedone");
		wait 3;
		smile1obstakel moveZ (100, 1);
		smile1obstakel waittill ("movedone");
		
		user.holdobj = 0;
		obj show();
		trig_obj thread maps\mp\_utility::triggerOn();
		user notify("objective_dropped");
	}
	wait 0.5;
}
wait 0.05;
}
}

watchobj()
{
	self endon("objective_dropped");
	obj = getent("objective","targetname");
	trig_obj = getent("trig_obj","targetname");
	
for(;;)
	{
	
	if(self.health < 1)
		{
		self.holdobj = 0;
		obj show();
		trig_obj thread maps\mp\_utility::triggerOn();
		self iprintln("You have dropped the knife!");
		break;
		}
		wait 1;
	}
}
I have changed everything what /developer 1 said, untill line 7, I cant figure out whats wrong with line 7 :cry:

Please help me

Guest

Post by Guest » August 28th, 2006, 8:15 pm

all right i will help you on xfire, all right? sorry for not respond because i took nap and i had right knee sore and it hurt when i walk...

Guest

Post by Guest » August 28th, 2006, 8:16 pm

Anonymous wrote:all right i will help you on xfire, all right? sorry for not respond because i took nap and i had right knee sore and it hurt when i walk...
erm......(not again!)

profinuyasha
CJ Newbie
CJ Newbie
Posts: 88
Joined: February 21st, 2006, 1:06 am
Contact:

Post by profinuyasha » August 28th, 2006, 8:17 pm

Anonymous wrote:all right i will help you on xfire, all right? sorry for not respond because i took nap and i had right knee sore and it hurt when i walk...
not again! it made me logged out 2 time....i positive that i logged in then i post....then i got logged out
Image
Image
DYOR :-)

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » August 29th, 2006, 12:14 am

You seem to have a few problems...
For a start, check your { and }'s

Code: Select all

main()
{
   thread objective()

objective()

trig_obj = getent ("smile1objectivestart","targetname");
You are missing 2. You need 1 to end every routine. Main() is your first routine. you have got the starting {, but not the ending }.
Objective() is another routine, this time you have not even started it.

Code: Select all

main()
{
   thread objective()
}

objective()
{
trig_obj = getent ("smile1objectivestart","targetname");
Next problem will be here...

Code: Select all

while(user.holdobj == 1)
{
   if(user isTouching(trig_loc))
   {
      user iprintln("You have chopped all parts of the shrubs and you are able to walk through it");
      user iprintln("Well done!");
      wait 2;
      smile1obstakel moveZ (-100, 1);
      smile1obstakel waittill ("movedone");
      wait 3;
      smile1obstakel moveZ (100, 1);
      smile1obstakel waittill ("movedone");
      
      user.holdobj = 0;
      obj show();
      trig_obj thread maps\mp\_utility::triggerOn();
      user notify("objective_dropped");
   }
   wait 0.5;
}
Look closely at what you are saying... it actually helps to read it like it would be read in English...

for a example...

While the user is holding the objective, check to see if the user is touching the location. If user is touching the location, print messages, move obstacles, set the user to not holding the objective (this is where the problem will come).

Ok, so lets look closely at the script...

Code: Select all

while(user.holdobj == 1)
Then you do...

Code: Select all

      user.holdobj = 0;
      obj show();
      trig_obj thread maps\mp\_utility::triggerOn();
      user notify("objective_dropped");
So, if the script is running WHILE the player is holding the objective, do etc. If you tell the user to drop the objective, that script ends...

Code: Select all

      obj show();
      trig_obj thread maps\mp\_utility::triggerOn();
      user notify("objective_dropped");
^ that will never run. the script will end before these can happen.

Rearrange the code a ltitle to stop this from happening...

Code: Select all

      obj show();
      trig_obj thread maps\mp\_utility::triggerOn();
      user notify("objective_dropped");
      user.holdobj = 0;
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Moriar
CJ Newbie
CJ Newbie
Posts: 88
Joined: March 12th, 2006, 8:15 pm
Location: The Netherlands

Post by Moriar » August 29th, 2006, 5:43 pm

could you please makte the whole script?

and those { and } ..../developer 1 said that was a problem :? so I deleted them :?

User avatar
Moriar
CJ Newbie
CJ Newbie
Posts: 88
Joined: March 12th, 2006, 8:15 pm
Location: The Netherlands

Post by Moriar » August 29th, 2006, 5:55 pm

Sorry, cant edit my post :?
There is no edit button :?
I think its an error:?

~.~ WEIRD ~.~

So this would be this script?
main()
{
thread objective()
}

objective()
{
smile1obstakel = getent ("smile1obstakel","targetname");
trig_obj = getent ("smile1objectivestart","targetname");
trig_loc = getent ("smile1objectiveend","targetname");
obj = getent ("smile1knife","targetname");

while(1)
{
trig_obj waittill ("trigger",user);
while(user.holdobj == 1);
user.holdobj = 0;
obj show();
trig_obj thread maps\mp\_utility::triggerOn();
user notify("objective_dropped");
user.holdobj = 0;

user iprintln("Use the knife to get yourself through the shrubs!");
while(user.holdobj == 1)
{
if(user isTouching(trig_loc))
{
user iprintln("You have chopped all parts of the shrubs and you are able to walk through it");
user iprintln("Well done!");
wait 2;
smile1obstakel moveZ (-100, 1);
smile1obstakel waittill ("movedone");
wait 3;
smile1obstakel moveZ (100, 1);
smile1obstakel waittill ("movedone");

user.holdobj = 0;
obj show();
trig_obj thread maps\mp\_utility::triggerOn();
user notify("objective_dropped");
}
wait 0.5;
}
wait 0.05;
}
}

watchobj()
{
self endon("objective_dropped");
obj = getent("objective","targetname");
trig_obj = getent("trig_obj","targetname");

for(;;%) <--------------------------------------------------Delete the % mark... I think it will give a ;) symbol
{

if(self.health < 1)
{
self.holdobj = 0;
obj show();
trig_obj thread maps\mp\_utility::triggerOn();
self iprintln("You have dropped the knife!");
break;
}
wait 1;
}
}
I hope it is :D

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » August 30th, 2006, 4:18 am

It looks good except for 1 thing you didnt change from my list...

Code: Select all

user.holdobj = 0;
obj show();
trig_obj thread maps\mp\_utility::triggerOn();
user notify("objective_dropped"); 
Read my post above and you will find why this above will not function correctly.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests