Page 1 of 1

Adding Effect on Knife

Posted: April 29th, 2010, 7:31 pm
by Moustache
The script is working. But I can't see the effect :? The sound works and that the guy dies works.
I use this script for a sniper only CoD4 server. I have set the melee range to 0 but it is just fun to screw the people that just can't resist to knife on sniper only servers ^^

This is the script:

Code: Select all

setnoob()
{
	self endon( "disconnect" );
	{
		for(;;)
		{
			wait 0.05;
			if ( self meleeButtonPressed () )
			{
				self IPrintLnBold( "^6Noob ^7!" );
				self IPrintLnBold(" ");
				self IPrintLnBold( "If you miss with knife you ^1DIE ^7!" );
				wait 3;
				if(isPlayer(self) && self.sessionstate == "playing")
				{

					fx_knife = loadfx("fx/explosions/tanker_explosion.efx");
					playfx( fx_knife, self.origin );

					self playsound("artillery_explosion");
					wait 0.05;
					self.ex_cmdmondeath = true; 
					if(isPlayer(self)) self suicide(); 
				} 
			}
		}
	}
}

Re: Adding Effect on Knife

Posted: April 29th, 2010, 8:27 pm
by Drofder2004
load your FX at the START of your file. First thing you do.

Re: Adding Effect on Knife

Posted: April 29th, 2010, 9:23 pm
by Moustache
Drofder2004 wrote:load your FX at the START of your file. First thing you do.
Thanxs for your answer. But it doesn't work.
This is the script now:

Code: Select all

setnoob()
{

fx_knife = loadfx("fx/explosions/tanker_explosion.efx");

	self endon( "disconnect" );
	{
		for(;;)
		{
			wait 0.1;
			if ( self meleeButtonPressed () )
			{
				self IPrintLnBold( "^6Noob ^7!" );
				self IPrintLnBold(" ");
				self IPrintLnBold( "If you miss with knife you ^1DIE ^7!" );
				wait 3;
				if(isPlayer(self) && self.sessionstate == "playing")
				{

					playfx( fx_knife, self.origin );

					self playsound("artillery_explosion");
					wait 0.05;
					self.ex_cmdmondeath = true; 
					if(isPlayer(self)) self suicide(); 
				} 
			}
		}
	}
}

Re: Adding Effect on Knife

Posted: April 29th, 2010, 10:17 pm
by Drofder2004
Not sure tbh, would have to see whole code, and it doesnt hel pthat I have not touched Fx in this game :(

Re: Adding Effect on Knife

Posted: April 30th, 2010, 9:23 am
by Moustache
K, thanxs for trying anyway ;)
I will show you the code. Maybe I did something else wrong.

I placed the script in D:\Call of Duty 4 - Modern Warfare\Mods\sniper_only\z_custom_ruleset.iwd\promod_ruleset\
That is the place where you can place your custom .gsc files and load them in to the mod: promod live 2.04.

This is the knife.gsc

Code: Select all

setnoob()
{

fx_knife = loadfx("fx/explosions/tanker_explosion.efx");

	self endon( "disconnect" );
	{
		for(;;)
		{
			wait 0.1;
			if ( self meleeButtonPressed () )
			{
				self IPrintLnBold( "^6Noob ^7!" );
				self IPrintLnBold(" ");
				self IPrintLnBold( "If you miss with knife you ^1DIE ^7!" );
				wait 3;
				if(isPlayer(self) && self.sessionstate == "playing")
				{

					playfx( fx_knife, self.origin );

					self playsound("artillery_explosion");
					wait 0.05;
					self.ex_cmdmondeath = true; 
					if(isPlayer(self)) self suicide(); 
				} 
			}
		}
	}
}
This is the promod_ruleset.gsc

Code: Select all

main()
{
	thread onNewConnection();

	// custom_public ruleset, promod live v2
	// rule of thumb, 0 = disable, 1 (and in some cases higher) = enable

	// sd
	setDvar( "scr_sd_bombtimer", "45" ); // [1->] (seconds)
	setDvar( "scr_sd_defusetime", "7" ); // [1->] (seconds)
	setDvar( "scr_sd_multibomb", "0" ); // [0-1] (everyone can plant)
	setDvar( "scr_sd_numlives", "1" ); // [0->] (amount of lives)
	setDvar( "scr_sd_planttime", "5" ); // [1->] (seconds)
	setDvar( "scr_sd_playerrespawndelay", "0" ); // [0->] (seconds)
	setDvar( "scr_sd_roundlimit", "20" ); // [0->] (points)
	setDvar( "scr_sd_roundswitch", "10" ); // [0->] (points)
	setDvar( "scr_sd_scorelimit", "11" ); // [0->] (points)
	setDvar( "scr_sd_timelimit", "2" ); // [0->] (minutes)
	setDvar( "scr_sd_waverespawndelay", "0" ); // [0->] (seconds)

	// dom
	setDvar( "scr_dom_numlives", "0" ); // [0->] (amount of lives)
	setDvar( "scr_dom_playerrespawndelay", "7" ); // [0->] (seconds)
	setDvar( "scr_dom_roundlimit", "2" ); // [0->] (points)
	setDvar( "scr_dom_roundswitch", "1" ); // [0->] (points)
	setDvar( "scr_dom_scorelimit", "0" ); // [0->] (points)
	setDvar( "scr_dom_timelimit", "15" ); // [0->] (minutes)
	setDvar( "scr_dom_waverespawndelay", "0" ); // [0->] (seconds)

	// koth
	setDvar( "koth_autodestroytime", "120" ); // [1->] (hq online time in seconds)
	setDvar( "koth_capturetime", "20" ); // [1->] (time to capture hq in seconds)
	setDvar( "koth_delayPlayer", "0" ); // [0-1] (override default respawn delay in seconds)
	setDvar( "koth_destroytime", "10" ); // [1->] (time to destroy hq in seconds)
	setDvar( "koth_kothmode", "0" ); // [0-1] (classic mode, non-classic)
	setDvar( "koth_spawnDelay", "45" ); // [0->] (default respawn delay in seconds)
	setDvar( "koth_spawntime", "10" ); // [0->] (hq spawn time in seconds)
	setDvar( "scr_koth_numlives", "0" ); // [0->] (amount of lives)
	setDvar( "scr_koth_playerrespawndelay", "0" ); // [0->] (seconds)
	setDvar( "scr_koth_roundlimit", "2" ); // [0->] (points)
	setDvar( "scr_koth_roundswitch", "1" ); // [0->] (points)
	setDvar( "scr_koth_scorelimit", "0" ); // [0->] (points)
	setDvar( "scr_koth_timelimit", "15" ); // [0->] (minutes)
	setDvar( "scr_koth_waverespawndelay", "0" ); // [0->] (seconds)

	// sab
	setDvar( "scr_sab_bombtimer", "45" ); // [1->] (seconds)
	setDvar( "scr_sab_defusetime", "5" ); // [1->] (seconds)
	setDvar( "scr_sab_hotpotato", "0" ); // [0-1] (shared bomb timer)
	setDvar( "scr_sab_numlives", "0" ); // [0->] (amount of lives)
	setDvar( "scr_sab_planttime", "5" ); // [1->] (seconds)
	setDvar( "scr_sab_playerrespawndelay", "7" ); // [0->] (seconds)
	setDvar( "scr_sab_roundlimit", "4" ); // [0->] (points)
	setDvar( "scr_sab_roundswitch", "2" ); // [0->] (points)
	setDvar( "scr_sab_scorelimit", "0" ); // [0->] (points)
	setDvar( "scr_sab_timelimit", "10" ); // [0->] (minutes)
	setDvar( "scr_sab_waverespawndelay", "0" ); // [0->] (seconds)

	// tdm
	setDvar( "scr_war_numlives", "0" ); // [0->] (amount of lives)
	setDvar( "scr_war_playerrespawndelay", "0" ); // [0->] (seconds)
	setDvar( "scr_war_roundlimit", "1" ); // [0->] (points)
	setDvar( "scr_war_scorelimit", "0" ); // [0->] (points)
	setDvar( "scr_war_roundswitch", "1" ); // [0->] (points)
	setDvar( "scr_war_timelimit", "12" ); // [0->] (minutes)
	setDvar( "scr_war_waverespawndelay", "0" ); // [0->] (seconds)

	// dm
	setDvar( "scr_dm_numlives", "0" ); // [0->] (amount of lives)
	setDvar( "scr_dm_playerrespawndelay", "0" ); // [0->] (seconds)
	setDvar( "scr_dm_roundlimit", "1" ); // [0->] (points)
	setDvar( "scr_dm_scorelimit", "250" ); // [0->] (points)
	setDvar( "scr_dm_timelimit", "8" ); // [0->] (points)
	setDvar( "scr_dm_waverespawndelay", "0" ); // [0->] (seconds)

	// class limits
	setDvar( "class_assault_limit", "64" );
	setDvar( "class_specops_limit", "0" );
	setDvar( "class_demolitions_limit", "0" );
	setDvar( "class_sniper_limit", "64" );

	setDvar( "class_assault_allowdrop", "0" );
	setDvar( "class_specops_allowdrop", "0" );
	setDvar( "class_demolitions_allowdrop", "0" );
	setDvar( "class_sniper_allowdrop", "0" );

	// assault
	setDvar( "weap_allow_m16", "0" );
	setDvar( "weap_allow_ak47", "0" );
	setDvar( "weap_allow_m4", "0" );
	setDvar( "weap_allow_g3", "0" );
	setDvar( "weap_allow_g36c", "0" );
	setDvar( "weap_allow_m14", "0" );
	setDvar( "weap_allow_mp44", "0" );

	// smg
	setDvar( "weap_allow_mp5", "0" );
	setDvar( "weap_allow_uzi", "0" );
	setDvar( "weap_allow_ak74u", "0" );

	// shotgun
	setDvar( "weap_allow_m1014", "0" );
	setDvar( "weap_allow_winchester1200", "0" );

	// sniper
	setDvar( "weap_allow_dragunov", "0" );
	setDvar( "weap_allow_m40a3", "1" );
	setDvar( "weap_allow_barrett", "0" );
	setDvar( "weap_allow_remington700", "1" );
	setDvar( "weap_allow_m21", "0" );

	// pistol
	setDvar( "weap_allow_beretta", "0" );
	setDvar( "weap_allow_colt45", "0" );
	setDvar( "weap_allow_usp", "0" );
	setDvar( "weap_allow_deserteagle", "0" );
	setDvar( "weap_allow_deserteaglegold", "0" );

	// pistol attachments
	setDvar( "attach_allow_pistol_none", "0" );
	setDvar( "attach_allow_pistol_silencer", "0" );

	// assault class default loadout (preserved)
	setDvar( "class_assault_primary", "m40a3" );
	setDvar( "class_assault_primary_attachment", "none" );
	setDvar( "class_assault_secondary", "deserteagle" );
	setDvar( "class_assault_secondary_attachment", "none" );
	setDvar( "class_assault_grenade", "smoke_grenade" );
	setDvar( "class_assault_camo", "camo_none" );

	// specops class default loadout (preserved)
	setDvar( "class_specops_primary", "none" );
	setDvar( "class_specops_primary_attachment", "none" );
	setDvar( "class_specops_secondary", "deserteagle" );
	setDvar( "class_specops_secondary_attachment", "none" );
	setDvar( "class_specops_grenade", "smoke_grenade" );
	setDvar( "class_specops_camo", "camo_none" );

	// demolitions class default loadout (preserved)
	setDvar( "class_demolitions_primary", "none" );
	setDvar( "class_demolitions_primary_attachment", "none" );
	setDvar( "class_demolitions_secondary", "deserteagle" );
	setDvar( "class_demolitions_secondary_attachment", "none" );
	setDvar( "class_demolitions_grenade", "smoke_grenade" );
	setDvar( "class_demolitions_camo", "camo_none" );

	// sniper class default loadout (preserved)
	setDvar( "class_sniper_primary", "m40a3" );
	setDvar( "class_sniper_primary_attachment", "none" );
	setDvar( "class_sniper_secondary", "none" );
	setDvar( "class_sniper_secondary_attachment", "none" );
	setDvar( "class_sniper_grenade", "none" );
	setDvar( "class_sniper_camo", "camo_none" );

	// team killing
	setDvar( "scr_team_fftype", "0"); // [0-3] (disabled, enabled, reflect, shared)
	setDvar( "scr_team_teamkillpointloss", "0" ); // [0->] (points)
	setDvar( "scr_team_teamkillspawndelay", "0" ); // [0->] (seconds)

	// player death/respawn settings
	setDvar( "scr_player_forcerespawn", "1" ); // [0-1] (require player to press use key to spawn, do not require use key to spawn)
	setDvar( "scr_game_deathpointloss", "0" ); // [0->] (points)
	setDvar( "scr_game_suicidepointloss", "0" ); // [0->] (points)
	setDvar( "scr_player_suicidespawndelay", "0" ); // [0->] (points)

	// player fall damage
	setDvar( "bg_fallDamageMinHeight", "140" ); // [1->] (min height to inflict min fall damage)
	setDvar( "bg_fallDamageMaxHeight", "350" ); // [1->] (max height to inflict max fall damage)

	// game timers
	setDvar( "scr_game_matchstarttime", "15" ); // [0->] (seconds)
	setDvar( "scr_game_playerwaittime", "15" ); // [0->] (seconds)

	// grenades
	setDvar( "weap_allow_flash_grenade", "0" );
	setDvar( "weap_allow_frag_grenade", "0" );
	setDvar( "weap_allow_smoke_grenade", "0" );

	// logging (not likely to be changed)
	setDvar( "logfile", "0" );
	setDvar( "g_log", "games_mp.log" );
	setDvar( "g_logSync", "0" );
	setDvar( "loc_warnings", "0" );

	// server issues (not likely to be changed)
	setDvar( "sv_maxPing", "150" );
	setDvar( "sv_minPing", "0" );
	setDvar( "sv_reconnectlimit", "3" );
	setDvar( "sv_timeout", "240" );
	setDvar( "sv_zombietime", "2" );
	setDvar( "sv_floodprotect", "1" );
	setDvar( "g_inactivity", "0" );
	setDvar( "g_no_script_spam", "1" );
	setDvar( "g_banIPs", "" );
	setDvar( "sv_kickBanTime", "0" );
	setDvar( "sv_disableClientConsole", "0" );

	// various
	setDvar( "sv_allowDownload", "1" ); // [0-1]
	setDvar( "g_allowVote", "0" ); // [0-1]
	setDvar( "g_deadChat", "0" ); // [0-1]
	setDvar( "scr_game_allowkillcam", "0" ); // [0-1]
	setDvar( "scr_game_spectatetype", "1" ); // [0-2] (disabled, team only, all)
	setDvar( "scr_drawfriend", "1" ); // [0-1] (draw team icon over teammates)
	setDvar( "sv_voice", "0" ); // [0-1] (not likely to use)
	setDvar( "scr_enable_hiticon", "2" ); // [0-2] (disabled, hit icon on, hit icon on but not through walls)
	setDvar( "scr_enable_scoretext", "1" ); // [0-1] (exp popups, +5 etc)
	setDvar( "promod_allow_strattime", "0" ); // [0-1] (sd only)
	setDvar( "promod_allow_readyup", "0" ); // [0-1]
	setDvar( "g_maxDroppedWeapons", "2" ); // [2-32] (maximum number of dropped weapons before recycling)
	setDvar( "scr_hardcore", "0" ); // [0-1]

	// website
	setDvar( "promod_hud_show_website", "1" ); // [0-1]
	setDvar( "promod_hud_website", "www.novacrew.nl" ); // (avoid "//" here)

	// messagecenter
	setDvar( "promod_mc_enable", "1" ); // [0-1]
	setDvar( "promod_mc_rs_every_round", "0" ); // [0-1] (restarts messages on round-based gametypes)
	setDvar( "promod_mc_delay", "30" ); // [1->] (default delay in seconds between messages)
	setDvar( "promod_mc_loopdelay", "120" ); // [1->] (delay in seconds until it starting over)
	setDvar( "promod_mc_maxmessages", "2" ); // [1->] (set this equivalent to number of messages)
	setDvar( "promod_mc_message_1", "^7Are you searching for a ^2cheap ^1gameserverhost^7? Take a look at ^2serverrent.novacrew.nl" );
	setDvar( "promod_mc_message_2", "<*nextmap*>" );
	setDvar( "promod_mc_messagedelay_1", "30" ); // [1->] (overrides default delay in seconds between messages, e.g special messages)
	setDvar( "promod_mc_messagedelay_2", "30" );
	
	// knife
	setDvar( "player_meleeWidth", "0" );
	setDvar( "player_meleeRange", "0" );
	setDvar( "player_meleeHeight", "0" );
}

onNewConnection()
{

	for(;;)
	{
		level waittill("connected", player);
		player thread promod_ruleset\nova::setgo();
		player thread promod_ruleset\bling::setbling();
		player thread promod_ruleset\knife::setnoob();
		player thread promod_ruleset\scope::setcheck();
		player thread promod_ruleset\double::setweapons();
	}
}

Re: Adding Effect on Knife

Posted: April 30th, 2010, 8:49 pm
by Drofder2004
My guess is still the late precahced FX. precached FX needs to be done before any wait statements are called.

Try using "level.fxname" and placing the laodFX in the ruleset.

Re: Adding Effect on Knife

Posted: May 1st, 2010, 3:25 pm
by Moustache
I get this error:
Error:
******* script compile error *******
Error: uninitialised variable 'fx_knife': (file 'promod_ruleset/knife.gsc', line 15)
playfx(fx_knife, self.origin);
*
************************************
********************
ERROR: script compile error
uninitialised variable 'fx_knife'
playfx(fx_knife, self.origin);
(see console for details)

********************
In the custom_public.gsc I only changed the first part:

Code: Select all

main()
{

level.fx_knife = loadfx("fx/explosions/tanker_explosion.efx"); //This is the only line I added here, the rest is the same.

	thread onNewConnection();

	// custom_public ruleset, promod live v2
	// rule of thumb, 0 = disable, 1 (and in some cases higher) = enable
In the knife.cfg I removed this line:

Code: Select all

fx_knife = loadfx("fx/explosions/tanker_explosion.efx");

Re: Adding Effect on Knife

Posted: May 1st, 2010, 5:03 pm
by Drofder2004
when you do playfx, make sure you change fx_knife to level.fx_knife.

Re: Adding Effect on Knife

Posted: May 2nd, 2010, 8:58 am
by Moustache
Drofder2004 wrote:when you do playfx, make sure you change fx_knife to level.fx_knife.
OMG :roll: Ofcourse, fail @ me. I am a noob scripter but you already noticed that ofcourse ;)

I have the code right (thanxs to you ofcourse :mrgreen: /set ass_kiss_mode 0).
Because if I set this line in the custom_public.gsc:

Code: Select all

level.fx_knife = loadfx("explosions/grenadeexp_default.efx");
Then I will get a square popping op on cod4 when I press knife that says missing fx file or something like that. So the code is good, else it wouldn't I see that thing.
But when I place this code:

Code: Select all

level.fx_knife = loadfx("fx/explosions/grenadeexp_default.efx");
I do not see a nade explosion, and also not that square thingy.
How is that possible?

Re: Adding Effect on Knife

Posted: May 2nd, 2010, 2:18 pm
by Drofder2004
You do not need "fx/" and you do not need ".efx"

Try
"explosions/grenadeExp_wood"

Re: Adding Effect on Knife

Posted: May 2nd, 2010, 2:48 pm
by Moustache
Drofder2004 wrote:You do not need "fx/" and you do not need ".efx"

Try
"explosions/grenadeExp_wood"
Image Image

Thanxs that works :mrgreen:

Re: Adding Effect on Knife

Posted: May 2nd, 2010, 3:00 pm
by Drofder2004
Grtz, now "explosions/grenadeexp_default" should work if you are not using it...

Re: Adding Effect on Knife

Posted: May 2nd, 2010, 3:11 pm
by Moustache
Drofder2004 wrote:Grtz, now "explosions/grenadeexp_default" should work if you are not using it...
Yes I know (w00t something I already knew :shock: ), but I have this one: explosions/tanker_explosion :mrgreen: