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

Members Online

»
0 Active | 38 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: Scripts in Mod
TFD|Gumpi
General Member
Since: Aug 28, 2008
Posts: 37
Last: May 16, 2009
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Saturday, Apr. 25, 2009 04:16 pm
Hi I want to make a sniper mod with adjustable zoom and so on. I've already found an example script but I do not know how to use it. I've already tried adding it to my mod.csv but if I do so I can't join any team the console says: "Couldn't find ui_mp/menu_opfor_mw" or something like that. I can post the script here if you want me to do so,but the script is taken from a mod ( I am only using it to learn how to add scripts I do not want to steal it) and so it should work correctly.
Share |
irishstorm
General Member
Since: Jan 19, 2009
Posts: 128
Last: Feb 25, 2011
[view latest posts]
Level 4
Category: CoD4 Scripting
Posted: Saturday, Apr. 25, 2009 04:40 pm
TFD|Gumpi writes...
Quote:
Hi I want to make a sniper mod with adjustable zoom and so on. I've already found an example script but I do not know how to use it. I've already tried adding it to my mod.csv but if I do so I can't join any team the console says: "Couldn't find ui_mp/menu_opfor_mw" or something like that. I can post the script here if you want me to do so,but the script is taken from a mod ( I am only using it to learn how to add scripts I do not want to steal it) and so it should work correctly.


did you make your folders and drop the files in?
"Couldn't find ui_mp/menu_opfor_mw" is because there is no file or folder in your mod!!! (i think)
here is the zoom script for CoD:MW
Code:
#include maps\mp\_utility;

#include maps\mp\gametypes\_hud_util;

main()
{
 self.zoomtextstring = "Press [{+activate}] to switch zoom!";
 precacheString( self.zoomtextstring );
 self.zoom_0_string = "1x";
 precacheString( self.zoom_0_string );
 self.zoom_1_string = "2x";
 precacheString( self.zoom_1_string );
 self.zoom_2_string = "4x";
 precacheString( self.zoom_2_string );
 self.zoom_3_string = "8x";
 precacheString( self.zoom_3_string );
 self.zoom_4_string = "16x";
 precacheString( self.zoom_4_string );
 self.zoom_5_string = "22x";
 precacheString( self.zoom_5_string );
 self.zoom_6_string = "28x";
 precacheString( self.zoom_6_string );
 self.zoom_7_string = "34x";
 precacheString( self.zoom_7_string );

	//maps\mp\gametypes\_globallogic::init();
	//Initialise_settings();
	Setup_zoom();
}

//lol
Check_scoped_weapon()
{
	my_curr_weapon = self getCurrentWeapon();
//	self iprintlnBold(my_curr_weapon);
	
//    if ( isSubStr( my_curr_weapon, "_acog_" ) )
//    return 7;
//    else
    if ( my_curr_weapon == "m21_mp" )
    return 1;
    else
    if ( my_curr_weapon == "aw50_mp" )
    return 1;
    else
    if ( my_curr_weapon == "barrett_mp" )
    return 1;
    else
    if ( my_curr_weapon == "dragunov_mp" )
    return 1;
    else
    if ( my_curr_weapon == "m40a3_mp" )
    return 1;
    else
    if ( my_curr_weapon == "remington700_mp" )
    return 1;
    else
    return 0;                    
}

Write_message_to_hud(state)
{       
	//self iprintlnBold("Press [{+activate}] to switch zoom!");
 if (state == 1) return 0;
 self.zoomtext = NewClientHudElem(self);
 self.zoomtext.color = (0.980,0.388,0.388);
 self.zoomtext.alignX = "right";
 self.zoomtext.alignY = "top";
 self.zoomtext.x = 400;
 self.zoomtext.y = 16;
 self.zoomtext.archived = true;
 self.zoomtext.fontScale = 1.4;
 self.zoomtext.alpha = 1;
 self.zoomtext setText( self.zoomtextstring );

 self.zoom_0_text = NewClientHudElem(self);
 self.zoom_0_text.color = (0.980,0.996,0.388);
 self.zoom_0_text.alignX = "right";
 self.zoom_0_text.alignY = "top";
 self.zoom_0_text.x = 175;
 self.zoom_0_text.y = 32;
 self.zoom_0_text.archived = true;
 self.zoom_0_text.fontScale = 1.4;
 self.zoom_0_text.alpha = 1;
 self.zoom_0_text setText( self.zoom_0_string );

 self.zoom_1_text = NewClientHudElem(self);
 self.zoom_1_text.color = (0.980,0.996,0.388);
 self.zoom_1_text.alignX = "right";
 self.zoom_1_text.alignY = "top";
 self.zoom_1_text.x = 220;
 self.zoom_1_text.y = 32;
 self.zoom_1_text.archived = true;
 self.zoom_1_text.fontScale = 1.4;
 self.zoom_1_text.alpha = 1;
 self.zoom_1_text setText( self.zoom_1_string );


 self.zoom_2_text = NewClientHudElem(self);
 self.zoom_2_text.color = (0.980,0.996,0.388);
 self.zoom_2_text.alignX = "right";
 self.zoom_2_text.alignY = "top";
 self.zoom_2_text.x = 265;
 self.zoom_2_text.y = 32;
 self.zoom_2_text.archived = true;
 self.zoom_2_text.fontScale = 1.4;
 self.zoom_2_text.alpha = 1;
 self.zoom_2_text setText( self.zoom_2_string );

 self.zoom_3_text = NewClientHudElem(self);
 self.zoom_3_text.color = (0.980,0.996,0.388);
 self.zoom_3_text.alignX = "right";
 self.zoom_3_text.alignY = "top";
 self.zoom_3_text.x = 310;
 self.zoom_3_text.y = 32;
 self.zoom_3_text.archived = true;
 self.zoom_3_text.fontScale = 1.4;
 self.zoom_3_text.alpha = 1;
 self.zoom_3_text setText( self.zoom_3_string );

 self.zoom_4_text = NewClientHudElem(self);
 self.zoom_4_text.color = (0.980,0.996,0.388);
 self.zoom_4_text.alignX = "right";
 self.zoom_4_text.alignY = "top";
 self.zoom_4_text.x = 355;
 self.zoom_4_text.y = 32;
 self.zoom_4_text.archived = true;
 self.zoom_4_text.fontScale = 1.4;
 self.zoom_4_text.alpha = 1;
 self.zoom_4_text setText( self.zoom_4_string );

 self.zoom_5_text = NewClientHudElem(self);
 self.zoom_5_text.color = (0.980,0.996,0.388);
 self.zoom_5_text.alignX = "right";
 self.zoom_5_text.alignY = "top";
 self.zoom_5_text.x = 400;
 self.zoom_5_text.y = 32;
 self.zoom_5_text.archived = true;
 self.zoom_5_text.fontScale = 1.4;
 self.zoom_5_text.alpha = 1;
 self.zoom_5_text setText( self.zoom_5_string );

 self.zoom_6_text = NewClientHudElem(self);
 self.zoom_6_text.color = (0.980,0.996,0.388);
 self.zoom_6_text.alignX = "right";
 self.zoom_6_text.alignY = "top";
 self.zoom_6_text.x = 445;
 self.zoom_6_text.y = 32;
 self.zoom_6_text.archived = true;
 self.zoom_6_text.fontScale = 1.4;
 self.zoom_6_text.alpha = 1;
 self.zoom_6_text setText( self.zoom_6_string );

 self.zoom_7_text = NewClientHudElem(self);
 self.zoom_7_text.color = (0.980,0.996,0.388);
 self.zoom_7_text.alignX = "right";
 self.zoom_7_text.alignY = "top";
 self.zoom_7_text.x = 490;
 self.zoom_7_text.y = 32;
 self.zoom_7_text.archived = true;
 self.zoom_7_text.fontScale = 1.4;
 self.zoom_7_text.alpha = 1;
 self.zoom_7_text setText( self.zoom_7_string );

}

Update_active_zoom(act_num)
{
 self.zoom_0_text.color = (0.980,0.996,0.388);
 self.zoom_1_text.color = (0.980,0.996,0.388);
 self.zoom_2_text.color = (0.980,0.996,0.388);
 self.zoom_3_text.color = (0.980,0.996,0.388);
 self.zoom_4_text.color = (0.980,0.996,0.388);
 self.zoom_5_text.color = (0.980,0.996,0.388);
 self.zoom_6_text.color = (0.980,0.996,0.388);
 self.zoom_7_text.color = (0.980,0.996,0.388);

if (act_num == 0)
 self.zoom_0_text.color = (0.980,0.388,0.388);
else if (act_num == 1)
 self.zoom_1_text.color = (0.980,0.388,0.388);
else if (act_num == 2)
 self.zoom_2_text.color = (0.980,0.388,0.388);
else if (act_num == 3)
 self.zoom_3_text.color = (0.980,0.388,0.388);
else if (act_num == 4)
 self.zoom_4_text.color = (0.980,0.388,0.388);
else if (act_num == 5)
 self.zoom_5_text.color = (0.980,0.388,0.388);
else if (act_num == 6)
 self.zoom_6_text.color = (0.980,0.388,0.388);
else if (act_num == 7)
 self.zoom_7_text.color = (0.980,0.388,0.388);
}

Destroy_newhudel()
{

self.zoomtext destroy();
self.zoom_0_text destroy();
self.zoom_1_text destroy();
self.zoom_2_text destroy();
self.zoom_3_text destroy();
self.zoom_4_text destroy();
self.zoom_5_text destroy();
self.zoom_6_text destroy();
self.zoom_7_text destroy();

}

Update_Zoom_Fov(sniper_zoom_mode)
{
		if (sniper_zoom_mode == 0) {self setclientDvar ("cg_fovmin", "51");} else
		if (sniper_zoom_mode == 1) {self setclientDvar ("cg_fovmin", "40");} else
		if (sniper_zoom_mode == 2) {self setclientDvar ("cg_fovmin", "30");} else
		if (sniper_zoom_mode == 3) {self setclientDvar ("cg_fovmin", "20");} else
		if (sniper_zoom_mode == 4) {self setclientDvar ("cg_fovmin", "11");} else
		if (sniper_zoom_mode == 5) {self setclientDvar ("cg_fovmin", "7");} else
		if (sniper_zoom_mode == 6) {self setclientDvar ("cg_fovmin", "4");} else
		if (sniper_zoom_mode == 7) {self setclientDvar ("cg_fovmin", "1");}
}


Setup_zoom()
{
	if(isdefined(self.zoomtext)){Destroy_newhudel();}
	if(isdefined(self.zoom_0_text)){Destroy_newhudel();}//just to secure
	if(isdefined(self.zoom_1_text)){Destroy_newhudel();}//just to secure
	if(isdefined(self.zoom_2_text)){Destroy_newhudel();}//just to secure

	//*******************************
	//********inizoom****************
	//*******************************
	messagestate = 0;
	sniper_zoom_switch_wait = 0;
	sniper_zoom_mode = -1;
	press_use_text_showed = 0;
	my_curr_weapon = self getCurrentWeapon();
	//thisweapon_max_zoom = getdvarint("sv_max_sniperzoom");
	//if (!isdefined(thisweapon_max_zoom)){thisweapon_max_zoom = 8;};
	if(Check_scoped_weapon() == 1){	self setclientDvar ("cg_fovmin", "51");}

     while(1)
    {

	//*******************************
	//********setzoom****************
	//*******************************


	if ( (self ADSButtonPressed()) && (self playerADS() == 1) && (Check_scoped_weapon() == 1))
	  {

		if (press_use_text_showed != 1) 	/////check that the zoomtext isn't showed every loop
			{
			Update_Zoom_Fov(sniper_zoom_mode);
			thread Write_message_to_hud(press_use_text_showed);
			press_use_text_showed = 1;
			Update_active_zoom(sniper_zoom_mode);
			}

	     if ( self UseButtonPressed() && (sniper_zoom_switch_wait == 0) )
	    	{
		sniper_zoom_mode = sniper_zoom_mode+1;
		
		if (sniper_zoom_mode <= -1) {sniper_zoom_mode = 0;}
		if (sniper_zoom_mode >= 8) {sniper_zoom_mode = 0;}
		Update_Zoom_Fov(sniper_zoom_mode);

		Update_active_zoom(sniper_zoom_mode);
		sniper_zoom_switch_wait = 1;
		}

		if (self UseButtonPressed() == 0) 
			{
			sniper_zoom_switch_wait = 0;
			}		/////check for the release of the Fbutton
	  }
	else
	{
	if (press_use_text_showed == 1) 
		{
		Destroy_newhudel();
		press_use_text_showed = 0;
		}	
	}
	
	//*******************************
	//********end setzoom************
	//*******************************
	if(Check_scoped_weapon() != 1){self setclientDvar ("cg_fovmin", "10");}
	
	self endon("disconnect");
	self endon("death");
	self endon("joined_spectators");
     wait 0.001;
    }
 }
Share |
TFD|Gumpi
General Member
Since: Aug 28, 2008
Posts: 37
Last: May 16, 2009
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Saturday, Apr. 25, 2009 05:38 pm
I have fixed the menu bug now it was caused by the z_mod.iwi so it had nothing to do with the zoom script. Can you tell me where I have to put the zoom script to get it working ?
Share |
irishstorm
General Member
Since: Jan 19, 2009
Posts: 128
Last: Feb 25, 2011
[view latest posts]
Level 4
Category: CoD4 Scripting
Posted: Saturday, Apr. 25, 2009 08:11 pm
TFD|Gumpi writes...
Quote:
I have fixed the menu bug now it was caused by the z_mod.iwi so it had nothing to do with the zoom script. Can you tell me where I have to put the zoom script to get it working ?


go to where ever you have your cod4 installed the go to raw then maps then mp then gametypes look for tdm.gsc put that in modname/maps/mp/gametypes if folder is not there make them
then open it with notepad or whatever you use i would recommend using notepad++ and look for onSpawnPlayer() and at the end put
thread maps\mp\gametypes\_zoom::main();
so it should look like this
Code:
onSpawnPlayer()
{
	spawnPoints = maps\mp\gametypes\_spawnlogic::getTeamSpawnPoints( self.pers["team"] );
	spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_DM( spawnPoints );

	self spawn( spawnPoint.origin, spawnPoint.angles );
	thread maps\mp\gametypes\snipermod_zoom::main();
	
}

this works in cod5 so it should work XD

and then drag the _zoom.gsc into /maps/mp/gametypes and then compile should work XD

edited on Apr. 25, 2009 04:12 pm by irishstorm

edited on Apr. 25, 2009 04:14 pm by irishstorm
Share |
TFD|Gumpi
General Member
Since: Aug 28, 2008
Posts: 37
Last: May 16, 2009
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Saturday, Apr. 25, 2009 10:03 pm
Ok the script is working so far, but I can not use all the zoom levels all except the last 3 are working. How can I get the last 3 ones working ?
Share |
_INSANE_
General Member
Since: Nov 7, 2008
Posts: 352
Last: Jul 10, 2011
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Sunday, Apr. 26, 2009 03:36 am
You have to add in the raw weapon files for each sniper, open the raw files up in notepad or something, and search for adsZoomFov .... and after the /slash ... change the number to 0
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

»