Script compile error - bad token

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

Moderator: Core Staff

Pedsdude
Site Admin
Site Admin
Posts: 15909
Joined: October 15th, 2004, 7:18 pm
Location: UK

Script compile error - bad token

Post by Pedsdude » September 22nd, 2008, 10:24 pm

I'm helping someone out with some scripting, and he's getting a script compile error:

ImageImage

Here's the script:

Code: Select all

main()
{
maps\mp\_load::main();

	thread trigger1();
}



trigger1()
{
trigger1 = getent ("trigger1","targetname");
while(1)
   {
	trigger1 waittill ("trigger1",player);
	player thread trigger2();
   }
}

trigger2()
{
trigger2 = getent ("trigger2","targetname");
while(1)
   {
	trigger2 waittill ("trigger2",player);
	player thread trigger3();
   }
}

trigger3()
{
trigger3 = getent ("trigger3","targetname");
while(1)
   {
	trigger3 waittill ("trigger3",player);
	user setOrigin((32,808,1024), 0.1);
   }
}
Any ideas?
Image
Image

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Script compile error - bad token

Post by Rezil » September 22nd, 2008, 11:06 pm

Line 1 is main(), are you sure he has no " in front of it? I know you checked but maybe he's still getting the error...
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

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

Re: Script compile error - bad token

Post by Drofder2004 » September 22nd, 2008, 11:28 pm

Is he using Word to save his scripts?

Something is wrong on line 1, and it is something he is typing (or is automatically being put there by a program)
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
ggcsmoke
CJ Wannabe
CJ Wannabe
Posts: 4
Joined: September 22nd, 2008, 11:30 pm
Location: England
Contact:

Re: Script compile error - bad token

Post by ggcsmoke » September 22nd, 2008, 11:39 pm

Hey,

Thanks again Pedsdude for all your help!!

The script i have is exactly the same as what is posted above. I tryed adding a random letter befor the main() and it said that that was the problem aswell. So, whats happening is, it's saying that the first letter in the script is wrong, whatever i put there.

If you want, You can look at it yourself and maybe shed some light on the situation



Thanks in advanced

Download attached
You do not have the required permissions to view the files attached to this post.
Image

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

Re: Script compile error - bad token

Post by Drofder2004 » September 23rd, 2008, 12:57 am

Ok, own up, who was using Microsoft word or some shitty word editor to do their coding?

Notepad and similar (crimson editor, ultra edit, etc)

Your file:
Byte Count: 545
File Size: 1092

My File (I retyped everything manually in Crimson Editor):
Byte Count: 533
File Size: 533

The reason yours is not exact is due to the heavy amount of invalid hidden characters created by the program used (usually these characters are for formatting)

There were some other minor errors in the coding (which is why my byte count is smaller)
mp_indoors.rar
You do not have the required permissions to view the files attached to this post.
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
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Re: Script compile error - bad token

Post by Nightmare » September 23rd, 2008, 12:58 am

I took the liberty of simplifying your code, who ever helped you with that doesn't know their stuff. That's right, you peds.

Code: Select all

main()
{
	maps\mp\_load::main();
	thread trigger();
}

trigger()
{
	trig1 = getent("trigger1","targetname");
	trig2 = getent("trigger2","targetname");
	trig3 = getent("trigger3","targetname");
	while(1)
	{
		trig1 waittill("trigger");
		trig2 waittill("trigger");
		trig3 waittill("trigger",user);
		user setOrigin((24,-552,1024));
	}
}
Also, on a final note.
Do not keep your targetnames simple!
The targetname trigger1 is way too vauge, and will probably conflict with another map.
Something I always suggest to others, is to put their map name in front.
So for example for you, instead of trigger1, make it mp_indoors_trigger1
And I am not talking about just in the script, I am also talking about in the .map file, which means you will have to recompile.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

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

Re: Script compile error - bad token

Post by Drofder2004 » September 23rd, 2008, 1:06 am

Nightmare just reminded me of something though which I haven't got time to help amend tonight.

The script you have created although in some ways correct, has a serious flaw.
Due to you not having a "opt-out" of your 'when triggered' events you are going to get serious loop issues.

Imagine, for example...
- Trigger1 thread runs.
- Player hits Trigger1, Trigger2 runs
- Player hits Trigger1 again, Trigger2 runs again.
- Player hits Trigger2, Trigger3 runs

So far we now have 4 threads running, 1 of them is a repeat. This will continue to happen, causing many repeats of the same thread. Now times this by the amount of players on the server.

Serious problems.

--

Although nightmares script above solves this problem, it also encounters a second problem. The triggers becomes non-player defined. Meaning if PlayerA hits the Trigger1, PlayerB now cannot hit Trigger1, and so on.

The script you use is fine to some degree, you just need to formulate a way of stopping the thread running multiple times. I'll let our resident genius scripter, Pedsdude to sort you out :)
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

Pedsdude
Site Admin
Site Admin
Posts: 15909
Joined: October 15th, 2004, 7:18 pm
Location: UK

Re: Script compile error - bad token

Post by Pedsdude » September 23rd, 2008, 1:10 am

I'm not that great at scripting to solve that issue :P

By the way, I did it in notepad, not Word, so I don't know what could have caused that.
Image
Image

User avatar
ggcsmoke
CJ Wannabe
CJ Wannabe
Posts: 4
Joined: September 22nd, 2008, 11:30 pm
Location: England
Contact:

Re: Script compile error - bad token

Post by ggcsmoke » September 23rd, 2008, 1:57 am

Lol, the is turning out to be crazy!!

I still thank Peds for helping me though :D

When you get the time Drofder, could you make the script for me please (as i have no knowledge in scripting)

What i want is....

3 buttons that have to be pressed from 1 - 3 in that order, then as soon as button 3 is hit, it tellies the player to the cords that are in the script.

Thanks in advanced


Smoke
Image

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Re: Script compile error - bad token

Post by Nightmare » September 23rd, 2008, 2:50 am

Fine, ignore the other helpful scripting guy.

Code: Select all

main()
{
	maps\mp\_load::main();

	level.codeCount=0;
   	level.code="";

   	for(i=1;i<4;i++)
	{
		trig = getent("mp_indoors_trigger"+i,"targetname");
		trig thread checkTrig(i);
	}
}

checkTrig(i)
{
	while(1)
	{
		self waittill("trigger",user);
		if(level.codeCount<3)
		{
			level.code=level.code+""+i;
			level.codeCount++;
		}
		if(level.codeCount==3&&level.code==123)
		{
			user setOrigin((24,-552,1024));
			level.codeCount=0;
		   	level.code="";
		}
		else if(level.codeCount==3&&level.code!=123)
		{
			level.codeCount=0;
		   	level.code="";
		}
	}
}
Tested and works 100%
Make sure that the targetnames for your triggers are mp_indoors_trigger1, mp_indoors_trigger2, and mp_indoors_trigger3.
If you have any other questions, feel free to ask.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

Pedsdude
Site Admin
Site Admin
Posts: 15909
Joined: October 15th, 2004, 7:18 pm
Location: UK

Re: Script compile error - bad token

Post by Pedsdude » September 23rd, 2008, 3:22 am

ggcsmoke wrote:I still thank Peds for helping me though :D
Indeed. The version I made technically does work, Drofder's just bitching about the server having multiple threads running!
Nightmare wrote:Fine, ignore the other helpful scripting guy
Who's he? :roll:
Image
Image

User avatar
ggcsmoke
CJ Wannabe
CJ Wannabe
Posts: 4
Joined: September 22nd, 2008, 11:30 pm
Location: England
Contact:

Re: Script compile error - bad token

Post by ggcsmoke » September 23rd, 2008, 11:29 am

Lol,

Thanks for all your help guys, will make sure that you will all be on the "thanks to" texture :D

Will post the finished map here so you can all look at it and if you dont have CoD1 installed, SHAME ON YOU!
coz it downs CoD4 :)
Image

JDogg
Too cool for CoDJumper
Too cool for CoDJumper
Posts: 3617
Joined: August 28th, 2007, 11:46 am
Location: Melbourne, Australia

Re: Script compile error - bad token

Post by JDogg » September 23rd, 2008, 2:48 pm

ggcsmoke wrote:Lol,

Thanks for all your help guys, will make sure that you will all be on the "thanks to" texture :D

Will post the finished map here so you can all look at it and if you dont have CoD1 installed, SHAME ON YOU!
coz it downs CoD4 :)
Right on, can't wait to see the map :).
Image
Image

Pedsdude
Site Admin
Site Admin
Posts: 15909
Joined: October 15th, 2004, 7:18 pm
Location: UK

Re: Script compile error - bad token

Post by Pedsdude » September 23rd, 2008, 3:34 pm

Guess you two and Nightmare are going to be the only people playing this map then... :roll:
Image
Image

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Re: Script compile error - bad token

Post by Nightmare » September 23rd, 2008, 4:56 pm

Code: Select all

main()
{
   maps\mp\_load::main();

   level.codeCount=0;
      level.code="";

      for(i=1;i<4;i++)
   {
      trig = getent("mp_indoors_trigger"+i,"targetname");
      trig thread checkTrig(i);
   }
}

checkTrig(i)
{
   while(1)
   {
      self waittill("trigger",user);
      if(level.codeCount<3)
      {
         level.code=level.code+""+i;
         level.codeCount++;
      }
      if(level.codeCount==3)
      {
         if(level.code==123)
                user setOrigin((24,-552,1024));
         level.codeCount=0;
         level.code="";
      }
   }
}
I looked over my code and found I could simplify it a little more. :P
Note, this has not been tested yet.

CoD1 FTW. :D
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 46 guests