Page 1 of 2
Script compile error - bad token
Posted: September 22nd, 2008, 10:24 pm
by Pedsdude
I'm helping someone out with some scripting, and he's getting a script compile error:

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?
Re: Script compile error - bad token
Posted: September 22nd, 2008, 11:06 pm
by Rezil
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...
Re: Script compile error - bad token
Posted: September 22nd, 2008, 11:28 pm
by Drofder2004
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)
Re: Script compile error - bad token
Posted: September 22nd, 2008, 11:39 pm
by ggcsmoke
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
Re: Script compile error - bad token
Posted: September 23rd, 2008, 12:57 am
by Drofder2004
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
Re: Script compile error - bad token
Posted: September 23rd, 2008, 12:58 am
by Nightmare
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.
Re: Script compile error - bad token
Posted: September 23rd, 2008, 1:06 am
by Drofder2004
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

Re: Script compile error - bad token
Posted: September 23rd, 2008, 1:10 am
by Pedsdude
I'm not
that great at scripting to solve that issue
By the way, I did it in notepad, not Word, so I don't know what could have caused that.
Re: Script compile error - bad token
Posted: September 23rd, 2008, 1:57 am
by ggcsmoke
Lol, the is turning out to be crazy!!
I still thank Peds for helping me though
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
Re: Script compile error - bad token
Posted: September 23rd, 2008, 2:50 am
by Nightmare
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.
Re: Script compile error - bad token
Posted: September 23rd, 2008, 3:22 am
by Pedsdude
ggcsmoke wrote:I still thank Peds for helping me though

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?

Re: Script compile error - bad token
Posted: September 23rd, 2008, 11:29 am
by ggcsmoke
Lol,
Thanks for all your help guys, will make sure that you will all be on the "thanks to" texture
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

Re: Script compile error - bad token
Posted: September 23rd, 2008, 2:48 pm
by JDogg
ggcsmoke wrote:Lol,
Thanks for all your help guys, will make sure that you will all be on the "thanks to" texture
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

.
Re: Script compile error - bad token
Posted: September 23rd, 2008, 3:34 pm
by Pedsdude
Guess you two and Nightmare are going to be the only people playing this map then...

Re: Script compile error - bad token
Posted: September 23rd, 2008, 4:56 pm
by Nightmare
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.

Note, this has not been tested yet.
CoD1 FTW.
