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

Members Online

»
0 Active | 66 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 4
Category: CoD4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Scripting help for my mod
damo56
General Member
Since: May 29, 2009
Posts: 29
Last: Aug 20, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Saturday, Aug. 14, 2010 11:09 pm
im making a mod where a single player has to try and blow up others with c4 sort of like tag that kids play. as soon as he kills somebody that person then has to kill somebody. all other players have to avoid dieing.

there are a couple of things i need help with.

i want to make the code below work. the parts that cause an error are commented out atm but the other parts arent doing anything either. sorry its a bit messy.

Code:
doAbility() 
{ 	
if(self.pers["team"] == "axis") 	//if team = axis (taggers)
	{ 		
	origin = self GetOrigin(); 	//get player origin for earthquake effect	
	self freezeControls( true );	//freeze controls during the ability
	self SetClientDvar( "god", "1" ); 	//give him god mode so he isnt affected by the shellshock	
	//self moveZ( 300, 2, 1, 0 );	//hoping to make him go in the air 300 units	
	//self rotateYaw( 720, 2, 0.5, 0.5 ) 	//do a double spin	
	wait 2; 		
	//self moveZ( -300, 0.5, 0, 0 ); 	//then hit the ground hard	
	Earthquake( 5, 1, origin, 2000 ); 	//causing an earthquake	
	players = level.players; 		
	players ShellShock( "jeepride_bridgebang", 15 ); 	//that causes shellshock	
	wait 3; 		
	self freezeControls( false ); 	//unfreeze him	
	self SetClientDvar( "god", "0" ); 	//take off god mode
	}
}



another thing that doesnt seem to be working is the "if team = "team"" statements ie
Code:
if(self.pers["team"] == "axis")
//do stuff



finally i want to know how to change the player from one team to the other when they are tagged or tagged someone.



its a lot of stuff but i would appreciate if you could help.

edited on Aug. 14, 2010 07:10 pm by damo56
Share |
ukdjaj
General Member
Since: Jun 1, 2008
Posts: 2726
Last: Nov 15, 2020
[view latest posts]
Level 9
Category: CoD4 Scripting
Posted: Saturday, Aug. 14, 2010 11:38 pm
cant really help you but try

Code:

if(player.pers["team"] == "axis")

that should work for that
Share |
BraX
General Member
Since: Apr 29, 2008
Posts: 413
Last: May 26, 2012
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Sunday, Aug. 15, 2010 07:58 am
ukdjaj writes...
Quote:
cant really help you but try

Code:

if(player.pers["team"] == "axis")

that should work for that
It wont work because player is undefined.

Code:
doAbility() 
{ 
	self endon( "disconnect" );
	self endon( "death" );
	if( isDefined( self.mover ) ) self.mover delete();	
	if(self.pers["team"] == "axis") 	//if team = axis (taggers)
	{ 		
		origin = self GetOrigin(); 	//get player origin for earthquake effect	
		self freezeControls( true );	//freeze controls during the ability
		self SetClientDvar( "god", "1" ); 	//give him god mode so he isnt affected by the shellshock	
		self.mover = spawn( "script_model", self.origin ); //spawn mover
		self.mover moveZ( 300, 2, 1, 0 );	//hoping to make him go in the air 300 units	
		self.mover rotateYaw( 720, 2, 0.5, 0.5 ) 	//do a double spin	
		wait 2; 	
		self.mover moveZ( -300, 0.5 ); 	//then hit the ground hard
		wait 2;
		self unlink();
		self.mover delete();		
		Earthquake( 5, 1, self.origin, 2000 ); 	//causing an earthquake	
		
		players = getEntArray( "player|, "classname" );
		for( i = 0; i < players.size; i++ )		
			players[i] ShellShock( "jeepride_bridgebang", 15 ); 	//that causes shellshock	
		
		wait 3; 		
		self freezeControls( false ); 	//unfreeze him	
		self SetClientDvar( "god", "0" ); 	//take off god mode
	}
}



Tips
1. You cannot use move functions on player entity, allways link player to script_model entity and then move that entity.
2. Remember to add endons() in thread, without them your script wouldn't end when someone disconnect or dies and this will cause server to crash.
3. Do not put undefined variables, you had one undefined "origin" in earthQuake() func.
4. Remember to put all assets in mod.csv like shellshock, models, scripts etc..
Share |
damo56
General Member
Since: May 29, 2009
Posts: 29
Last: Aug 20, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Sunday, Aug. 15, 2010 09:11 am
thanks ill give it a try. how would you put the .shock file in the mod.csv? everything else is in the csv.

do you think i should use a menu to trigger this or maybe use a button like the grenade button (grenades are taken away).
Share |
Uzumakibro93
General Member
Since: Sep 6, 2009
Posts: 118
Last: Jul 5, 2011
[view latest posts]
Level 4
Category: CoD4 Scripting
Posted: Sunday, Aug. 15, 2010 09:29 am
Brax, you had a small error I noticed

Code:
doAbility() 
{ 
	self endon( "disconnect" );
	self endon( "death" );
	if( isDefined( self.mover ) ) self.mover delete();	
	if(self.pers["team"] == "axis") 	//if team = axis (taggers)
	{ 		
		origin = self GetOrigin(); 	//get player origin for earthquake effect	
		self freezeControls( true );	//freeze controls during the ability
		self SetClientDvar( "god", "1" ); 	//give him god mode so he isnt affected by the shellshock	
		self.mover = spawn( "script_model", self.origin ); //spawn mover
		self.mover moveZ( 300, 2, 1, 0 );	//hoping to make him go in the air 300 units	
		self.mover rotateYaw( 720, 2, 0.5, 0.5 ) 	//do a double spin	
		wait 2; 	
		self.mover moveZ( -300, 0.5 ); 	//then hit the ground hard
		wait 2;
		self unlink();
		self.mover delete();		
		Earthquake( 5, 1, self.origin, 2000 ); 	//causing an earthquake	
		
		players = getEntArray( "player", "classname" );
		for( i = 0; i < players.size; i++ )		
			players[i] ShellShock( "jeepride_bridgebang", 15 ); 	//that causes shellshock	
		
		wait 3; 		
		self freezeControls( false ); 	//unfreeze him	
		self SetClientDvar( "god", "0" ); 	//take off god mode
	}
}


Please replace your current script with this one. You had

Quote:
players = getEntArray( "player|, "classname" );


when it should have been a " instead of a |.

Thank you, Kyle Mulliger.
Share |
damo56
General Member
Since: May 29, 2009
Posts: 29
Last: Aug 20, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Sunday, Aug. 15, 2010 12:36 pm
i looked through the script and noticed that there is no "linkto". do you need a linkto?
Share |
damo56
General Member
Since: May 29, 2009
Posts: 29
Last: Aug 20, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Friday, Aug. 20, 2010 09:02 am
ok i put in the code but it didnt work so i commented out everything and uncommented things until i knew the things that werent working. this is what i have now.

Code:

{  	
      self endon( "disconnect" ); 	
      self endon( "death" ); 	
      if(self.pers["team"] == "axis") 	//if team = axis (taggers) 	
      { 		 		
            self freezeControls( true );	//freeze controls during the ability 		
            self SetClientDvar( "god", "1" ); 	//give him god mode so he isnt affected by the shellshock	 		
            self.mover = Spawn( "script_model", self getorigin() ); //spawn mover 		
            self linkTo( self.mover ); 		
            self.mover moveZ( 300, 3, 1, 0 );	//hoping to make him go in the air 300 units	 		
            wait 2; 	 		
            self.mover moveZ( -200, 0.5 ); 	//then hit the ground hard
            self unlink(); 		
            wait 1; 		
            self.mover delete();		 		
            Earthquake( 5, 1, self getorigin(), 2000 ); 	//causing an earthquake	 		 		
            //players = getEntArray( "player", "classname" ); 		
            //for( i = 0; i < players.size; i++ )		 		
            //	players[i] ShellShock( "artillery_rumble", 15 ); 	//that causes shellshock	 		 		
            wait 3; 		 		
            self freezeControls( false ); 	//unfreeze him	 		
            self SetClientDvar( "god", "0" ); 	//take off god mode 	
      }
}


as you can see the shellshock isnt working.
Share |
Xylozi
General Member
Since: Jul 12, 2008
Posts: 218
Last: Mar 1, 2012
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Friday, Aug. 20, 2010 09:11 am
Try this:

Code:

#include common_scripts\utility;


doAbility()
{
      self endon( "disconnect" ); 	
      self endon( "death" ); 
	  
      if( self.pers["team"] == "axis" ) 
      { 		 		
            self freezeControls( true );	
            self SetClientDvar( "god", "1" );
			
            self.mover = Spawn( "script_model", ( 0, 0, 0 ) );	
			self.mover.origin = self.origin;
			self.mover.angles = self.angles;
			
            self linkTo( self.mover ); 	
			self.mover thread onConditions( self );
			
            self.mover moveZ( 300, 3, 1, 0 );
          	self.mover waittill( "movedone" );
            self.mover moveZ( -300, 0.5 ); 
			self.mover waittill( "movedone" );
			
            self Unlink(); 			
			self.mover Delete();
			
            earthquake( 5, 1, self.origin, 2000 ); 		
			players = getEntArray( "player", "classname" ); 		
            for( i = 0; i < players.size; i++ )		 		
				players[i] ShellShock( "artillery_rumble", 15 ); 
			
            wait 3; 	
	 		
            self freezeControls( false ); 	 		
            self SetClientDvar( "god", "0" ); 	
      }
}

onConditions( owner )
{
	owner waittill_any( "disconnect", "death", "joined_spectator" );
	self Delete();
}
Share |
damo56
General Member
Since: May 29, 2009
Posts: 29
Last: Aug 20, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Friday, Aug. 20, 2010 11:06 am
ok IT WORKS!!! tyvm but i still have 1 issue. whenever the map changes the ability doesnt work. its probally somewhere else in my code but i thought id ask just in case.
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 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

»