Page 1 of 1

Objective script "Bad Syntax"

Posted: August 28th, 2006, 7:35 pm
by Moriar
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

Posted: August 28th, 2006, 8:15 pm
by Guest
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...

Posted: August 28th, 2006, 8:16 pm
by Guest
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!)

Posted: August 28th, 2006, 8:17 pm
by profinuyasha
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

Posted: August 29th, 2006, 12:14 am
by Drofder2004
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;

Posted: August 29th, 2006, 5:43 pm
by Moriar
could you please makte the whole script?

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

Posted: August 29th, 2006, 5:55 pm
by Moriar
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

Posted: August 30th, 2006, 4:18 am
by Drofder2004
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.