Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 85 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Previous Page
subscribe
Author Topic: script help please!
Xylozi
General Member
Since: Jul 12, 2008
Posts: 218
Last: Mar 1, 2012
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Tuesday, Aug. 10, 2010 01:20 pm
Not tested, but this should allow you to have planks on a window that disappear and can be repaired by pressing the trigger_use:

Code:

main()
{
	triggerUse = getEntArray( "trig_use", "targetname" );
	for( i = 0; i < triggerUse.size; i++ )
		triggerUse[i] thread MonitorTrigger();
}

MonitorTrigger()
{
	triggerDamage = getEnt( self.target, "targetname" );
	triggerDamage thread MonitorDamage();
	
	while(1)
	{
		self waittill( "trigger", player );
		
		if( isPlayer( player ) && isAlive( player ) )
		{
			triggerDamage thread renewPlanks();
			wait 30;	// Delay between repairs
		}
	}
}
	
MonitorDamage( trigger )
{
	while(1)
	{
		self waittill( "trigger" );
		
		// on any damage, remove a plank
		self thread RemovePlank();
	}
}

renewPlanks()
{
	// Grab plank entities
	self.planks = getEntArray( self.target, "targetname" );
	
	// Goes through planks that belong to damage trigger
	for( i = 0; i < self.planks.size; i++ )
	{
		// If var is not def, assume not hidden
		if( !isDefined( self.planks[i].isHidden ) )
			self.planks[i].isHidden = false;
	
		// If hidden, unhide
		if( self.planks[i].isHidden )
		{
			self.planks[i] Solid();
			self.planks[i] Show();
			self.planks[i].isHidden = false;
		}
	}
}

RemovePlank()
{
	// Grab plank entities
	self.planks = getEntArray( self.target, "targetname" );
	
	// Work out which planks aren't hidden
	usablePlanks = []
	for( i = 0; i < self.planks.size; i++ )
	{
		if( !isDefined( self.planks[i].isHidden ) )
			self.planks[i].isHidden = false;
	
		if( !self.planks[i].isHidden )
			usablePlanks[usablePlanks.size] = self.planks[i];
	}
			
	if( usablePlanks.size > 0 )	// If all aren't hidden
	{
		// Make the plank hidden
		lostPlank = usablePlanks[randomInt(usablePlanks.size)];
		lostPlank notSolid();
		lostPlank Hide();
		lostPlank.isHidden = true;
	}
}
Share |
ukdjaj
General Member
Since: Jun 1, 2008
Posts: 2726
Last: Nov 15, 2020
[view latest posts]
Level 9
Category: CoD2 Scripting
Posted: Tuesday, Aug. 10, 2010 01:24 pm
Thanks, will try now but i got the other script working, all i did was take out the last 3 waittill ("movedone"); and it worked =)

edited on Aug. 10, 2010 09:26 am by ukdjaj

BTW tried your script, doesnt work sorry [eek]
Share |
ukdjaj
General Member
Since: Jun 1, 2008
Posts: 2726
Last: Nov 15, 2020
[view latest posts]
Level 9
Category: CoD2 Scripting
Posted: Tuesday, Aug. 10, 2010 01:40 pm
right now i have this

Code:
main()
{
thread block();
}

block()
{
plank1 = getent("plank1","targetname");
plank2 = getent("plank2","targetname");
plank3 = getent("plank3","targetname");
plank4 = getent("plank4","targetname");
trig1 = getent("trig_p1_d","targetname");
trig2 = getent("trig_p2_d","targetname");
trig3 = getent("trig_p3_d","targetname");
trig4 = getent("trig_p4_d","targetname");
trig = getent("trig_use","targetname");	
while(1)
{
trig waittill ("trigger");
plank1 hide();
plank1 notsolid();
wait 10;
trig1 waittill ("trigger");

plank1 solid();
plank1 show();
	}
}

while(1)
{
trig waittill ("trigger");
plank2 hide();
plank2 notsolid();
wait 10;
trig1 waittill ("trigger");

plank2 solid();
plank2 show();
	}
}

while(1)
{
trig waittill ("trigger");
plank3 hide();
plank3 notsolid();
wait 10;
trig1 waittill ("trigger");

plank3 solid();
plank3 show();
	}
}

while(1)
{
trig waittill ("trigger");
plank4 hide();
plank4 notsolid();
wait 10;
trig1 waittill ("trigger");
plank4 solid();
plank4 show();
	}
}


but it gives me script compile error, saying that "while(1)" is wrong. but what i think it is, is how do i end a bit and start off the next?
Share |
Restricted Access Topic is Locked
Page
Previous Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»