Author |
Topic: Problem moving door Script compile error |
|
Category: CoD4 Scripting Posted: Thursday, Apr. 23, 2009 02:34 pm |
|
Try something like this. I made the self.doormodel parts into doormodel - taking out the self part.
Code: main();
{
doortriggers = getentarray("deur_open","targetname");
for(i=0;i< doortriggers.size;i++)
doortriggers[i] thread door_think();
}
door_think()
{
self.doormoving = false;
self.doorclosed = true;
doormodel = getent(self.target, "targetname");
while (1)
{
self waittill("trigger");
if(!self.doormoving)
self thread door_move();
}
}
door_move()
{
self.doormoving = true;
if(self.doorclosed)
{
doormodel moveto ((3077.5,819.5,0.0),1);
doormodel waittill("movetodone");
self.doorclosed = false;
}
else
{
doormodel moveto ((3077.5,819.5,0.0),1);
doormodel waittill("movetodone");
self.doorclosed = true;
}
self.doormoving = false;
}
If that doesn't work, then try just puting something like self.doormodel = undefined; at the top of door_think.
Also, you do have your triggers targeting the doormodel right? If you don't, then thats going to cause problems since the script is thinking they are and is trying to get the triggers target. |
|
|
|
dutchman16 |
General Member Since: May 8, 2006 Posts: 177 Last: Apr 29, 2009 [view latest posts] |
|
|
|
dutchman16 |
General Member Since: May 8, 2006 Posts: 177 Last: Apr 29, 2009 [view latest posts] |
|
|
|
DeekCiti |
|
General Member Since: Mar 13, 2008 Posts: 1293 Last: Jul 9, 2016 [view latest posts] |
|
|
Category: CoD4 Scripting Posted: Thursday, Apr. 23, 2009 06:51 pm |
|
The door script should have worked fine the way it was originally. I've used that same script many, Many times the way it was, there is no need to start changing it around.
As long as you built the door correctly and a door exists and the trigger has the same targetname as in your script you shouldn't have any problems.
The first script you posted had been edited and lines moved around, where did you find that? Or did you do that?
Also, change the script back to the way it was by looking in the previous posts. You changed the name now the script is messed up and is no longer a variable. Also what kind of door is this, you have it set up on a moveto function. If changing it back doesn't work, try this script, its the nearly the same, just copy and paste/replace. it will do exactly what you had your original script doing in post 1.
Code: main()
{
thread scripted_door();
}<br />
<br />
scripted_door()<br />
<br />
{
doortrigger = getentarray("deur_open","targetname");
for(i=0;i< doortrigger.size;i++)
{
doortrigger [i] thread door_think();
}
}<br />
<br />
door_think()
{
self.doormoving = false;
self.doorclosed = true;
self.doormodel = getent(self.target, "targetname");<br />
<br />
while (1)
{
self waittill("trigger");
if(!self.doormoving)
self thread door_move();
}
}<br />
<br />
door_move()
{
self.doormoving = true;
if(self.doorclosed)
{
self.doormodel moveto ((3077.5,819.5,0.0),1);
self.doormodel waittill("movedone");
self.doorclosed = false;
}
else
{
self.doormodel moveto ((3077.5,819.5,0.0),1);
self.doormodel waittill("movedone");
self.doorclosed = true;
}
self.doormoving = false;
}
|
|
|
|
dutchman16 |
General Member Since: May 8, 2006 Posts: 177 Last: Apr 29, 2009 [view latest posts] |
|
|
Category: CoD4 Scripting Posted: Friday, Apr. 24, 2009 04:43 pm |
|
Deekciti when I try your script it gives this error:
Url: http://img9.imageshack.us/my.php?image=probleem2h.jpg
Scripts:
_deur.gsc
Code: main()
{
thread scripted_door();
}
scripted_door()
{
doortrigger = getentarray("deur_open","targetname");
for(i=0;i< doortrigger.size;i++)
{
doortrigger [i] thread door_think();
}
}
door_think()
{
self.doormoving = false;
self.doorclosed = true;
self.doormodel = getent(self.target, "targetname");
while (1)
{
self waittill("trigger");
if(!self.doormoving)
self thread door_move();
}
}
door_move()
{
self.doormoving = true;
if(self.doorclosed)
{
self.doormodel moveto ((3077.5,819.5,0.0),1);
self.doormodel waittill("movedone");
self.doorclosed = false;
}
else
{
self.doormodel moveto ((3077.5,819.5,0.0),1);
self.doormodel waittill("movedone");
self.doorclosed = true;
}
self.doormoving = false;
}
mp_modern-dawnville.gsc
Code:
main()
{
maps\mp\_load::main();
maps\mp\_deur::main();
//setExpFog(500, 3500, .5, 0.5, 0.45, 0);
ambientPlay("ambient_middleeast_ext");
//VisionSetNaked( "mp_vacant" );
game["allies"] = "sas";
game["axis"] = "marines";
game["attackers"] = "axis";
game["defenders"] = "allies";
game["allies_soldiertype"] = "woodland";
game["axis_soldiertype"] = "woodland";
setdvar( "r_specularcolorscale", "1" );
setdvar("r_glowbloomintensity0",".1");
setdvar("r_glowbloomintensity1",".1");
setdvar("r_glowskybleedintensity0",".1");
//setdvar("compassmaxrange","1500");
}
edited on Apr. 24, 2009 12:46 pm by dutchman16 |
|
|
|
|
|
dutchman16 |
General Member Since: May 8, 2006 Posts: 177 Last: Apr 29, 2009 [view latest posts] |
|
|
|
DeekCiti |
|
General Member Since: Mar 13, 2008 Posts: 1293 Last: Jul 9, 2016 [view latest posts] |
|
|
|
dutchman16 |
General Member Since: May 8, 2006 Posts: 177 Last: Apr 29, 2009 [view latest posts] |
|
|
|