Author |
Topic: script help please! |
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, Aug. 10, 2010 12:12 pm |
|
ok i am trying to make a script a bit like WaW where as theres a plank of wood, you bash / shoot it it disapears after 20 seconds you can use the trigger use to show the wood again
Code: main()
{
thread block();
}
block()
{
plank = getent("plank","targetname");
trig_damage = getent("trig_damage","targetname");
trig_use = getent("trig_use","targetname");
while (1)
{
trig_damage waittill ("trigger");
plank hide();
wait 20;
plank waittill ("movedone");
trig_use waittill ("trigger");
plank show();
plank waittill ("movedone");
}
}
this is my script, i shoot the plank, it disapears but i have 2 errors
1. after 20 seconds it does not show again.
2. it disapears, but it makes it in to chaulk texture (because i cant walk through it)
|
|
|
|
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, Aug. 10, 2010 12:22 pm |
|
Right, i have fixed both of them errors, by using the notsold(); and solid(); function and taking out trig_use waittil ("movedone");
i now have this
Code: main()
{
thread block();
}
block()
{
plank = getent("plank","targetname");
trig_damage = getent("trig_damage","targetname");
trig_use = getent("trig_use","targetname");
while (1)
{
trig_damage waittill ("trigger");
plank hide();
plank notsolid();
wait 1; //change this so i dont have to wait 20 seconds when testing!
trig_use waittill ("trigger");
plank solid();
plank show();
plank waittill ("movedone");
trig_damage waittill ("movedone");
trig_use waittill ("movedone");
}
}
new error though, it works fine but after i show it again i go to shoot it and it does nothing. but it should because
)
)
loops it right so it should start over?
anyway im going to check the introduction to scripting again lol to see if i have got it right.
ALL HELP APPRECIATED!
Thanks, Ukdjaj |
|
|
|
hyper1234 |
|
General Member Since: Mar 17, 2009 Posts: 358 Last: Apr 14, 2011 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, Aug. 10, 2010 12:26 pm |
|
Well, first of all, the hide function does exactly what it says on the tin, it hides it. So its hidden, but still structural.
To solve that, you need to use the function:
Code: plank delete();
However, then you have deleted it so it won't come back. However, you could use the function:
Code: plank notsolid();
Then make it solid again as so:
Code: plank solid();
As for the other issue, your hiding the plank, then waiting 20 seconds and then what? After 20 seconds somebody can press the trigger_use and it shows again? Thats what it looks like.
Maybe try reduce the waiting time to like 5 seconds for testing, wait 5 seconds after it has been hidden, then use the trigger_touch to make it show again and solid. Also, throw an iprintlnbold bold in there to see if when you press the trigger_use it actually works, if it doesn't print anything, the trigger isn't working properly, try the script below (no promises and not tested)
Code: main()
{
thread block();
}
block()
{
plank = getent("plank","targetname");
trig_damage = getent("trig_damage","targetname");
trig_use = getent("trig_use","targetname");
trig_damage show();
trig_use hide();
while (1)
{
trig_damage waittill ("trigger");
plank hide();
plank notsolid();
trig_damage hide();
wait 5;
trig_use show();
trig_use waittill ("trigger");
self iprintlnbold("Test");
plank show();
plank solid();
trig_use hide();
trig_damage show();
}
} |
|
|
|
hyper1234 |
|
General Member Since: Mar 17, 2009 Posts: 358 Last: Apr 14, 2011 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, Aug. 10, 2010 12:28 pm |
|
ukdjaj writes...Quote:
new error though, it works fine but after i show it again i go to shoot it and it does nothing. but it should because
)
)
loops it right so it should start over?
No, the
}
}
Closes the the first two sets of { in your script, the
Code: while(1)
{
Loops it. i thought that might be a probl#em in that it doesn't work over and over.
|
|
|
|
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, Aug. 10, 2010 12:33 pm |
|
so how would i go about looking it at the end of a script?
Code: }
}
}
and using Code: for( ;; ) instead of while(1);? or something else?
edited on Aug. 10, 2010 08:34 am by ukdjaj |
|
|
|
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
|
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, Aug. 10, 2010 12:51 pm |
|
right i tried what you said (but added it to mine didint just copy yours )
Code: main()
{
thread block();
}
block()
{
plank = getent("plank","targetname");
trig_damage = getent("trig_damage","targetname");
trig_use = getent("trig_use","targetname");
trig_use hide();
trig_damage show();
while (1)
{
trig_damage waittill ("trigger");
plank hide();
plank notsolid();
trig_damage hide();
wait 1;
trig_use show();
trig_use waittill ("trigger");
iprintlnbold ("test")
plank solid();
plank show();
trig_use hide();
trig_damage show();
plank waittill ("movedone");
trig_damage waittill ("movedone");
trig_use waittill ("movedone");
}
}
i get a script compile error that says line 24 plank solid();
but when i put // in front of iprintlnbold ("test") it works =) |
|
|
|
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
|
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
|
ukdjaj |
|
General Member Since: Jun 1, 2008 Posts: 2726 Last: Nov 15, 2020 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, Aug. 10, 2010 01:09 pm |
|
this is what i have so far
Code: main()
{
thread block();
}
block()
{
plank = getent("plank","targetname");
trig_damage = getent("trig_damage","targetname");
trig_use = getent("trigger_use","targetname");
for( ;; )
{
trig_damage waittill ("trigger");
trig_use hide();
plank hide();
plank notsolid();
trig_damage hide();
wait 1;
trig_use show();
trig_use waittill ("trigger");
iprintlnbold ("test");
plank solid();
plank show();
trig_use hide();
trig_damage show();
plank waittill ("movedone");
trig_damage waittill ("movedone");
trig_use waittill ("movedone");
}
}
its back to the start, it sitll says test but it doesn't loop it. how would i loop it?
edited on Aug. 10, 2010 09:17 am by ukdjaj
FYI the hide(); and the show(); dont seem to work for the triggers. so i just did this
Code: main()
{
thread block();
}
block()
{
plank = getent("plank","targetname");
trig_damage = getent("trig_damage","targetname");
trig = getent("trigopen","targetname");
trig hide();
for( ;; )
{
trig_damage waittill ("trigger");
plank hide();
plank notsolid();
wait 1;
trig waittill ("trigger");
iprintlnbold ("test");
plank solid();
plank show();
plank waittill ("movedone");
trig_damage waittill ("movedone");
trig waittill ("movedone");
}
}
BTW should i be using while(1) for my loop at the start or doesnt it matter? |
|
|
|