Sniper Only script

This is a simple server side script to sniper servers works with all game modes SC or HC doesn’t matter and it can be edited as you like and added to any pre-existing scripts/iwd7 you have.

sniper()
{
       while(1)
       {
self waittill("weapon_change", weapon);     /// wait until player changes weapon to prevent class changing when they first spawn.
self TakeAllWeapons();     /// clear player weapons 
self ClearPerks();     /// clear all player perks 
self SetPerk("specialty_extraammo");     /// give the player Bandolier perk
self SetPerk("specialty_bulletdamage");     /// give the player Stopping Power perk
self SetPerk("specialty_bulletaccuracy");     /// give the player Steady Aim perk
self GiveWeapon("m40a3_mp");     /// give the player M40A3 Sniper
self GiveWeapon( "remington700_mp" );      /// give the player R700 Sniper
self GiveMaxAmmo("m40a3_mp");      /// give the player max ammo for M40A3
self GiveMaxAmmo( "remington700_mp" );     /// give the player max ammo for R700
setDvar("aim_automelee_enabled", 0);     /// Disable Knife
setDvar("player_meleeRange", 0);     /// Disable Knife 
wait 0.05;

       }
}

You don’t like the perks?

Change them, here’s the names for all the perks you need.

"specialty_weapon_c4"
"specialty_specialgrenade"
"specialty_weapon_rpg"
"specialty_weapon_claymore"
"specialty_fraggrenade"
"specialty_extraammo"
"specialty_detectexplosive"

"specialty_bulletdamage"
"specialty_armorvest"
"specialty_fastreload"
"specialty_rof"
"specialty_twoprimaries"
"specialty_gpsjammer"
"specialty_explosivedamage"

"specialty_longersprint"
"specialty_bulletaccuracy"
"specialty_pistoldeath"
"specialty_grenadepulldeath"
"specialty_bulletpenetration"
"specialty_holdbreath"
"specialty_quieter"
"specialty_parabolic"

You can also remove 1 or 2 perks or remove all of them!

To remove sway (make the snipers always steady like promod) add these :

setDvar( "player_breath_gasp_lerp", "0.001" );
setDvar( "player_breath_gasp_time", "0.001" );
setDvar( "player_breath_gasp_scale", "0.001" );
self SetClientDvar( "cg_drawBreathHint", "0" );    /// to remove the hold shift hint
so it look like this :


sniper()
{
       while(1)
       {
self waittill("weapon_change", weapon);     /// wait until player changes weapon to prevent class changing when they first spawn.
self TakeAllWeapons();     /// clear player weapons 
self ClearPerks();     /// clear all player perks 
self SetPerk("specialty_extraammo");     /// give the player Bandolier perk
self SetPerk("specialty_bulletdamage");     /// give the player Stopping Power perk
self SetPerk("specialty_bulletaccuracy");     /// give the player Steady Aim perk
self GiveWeapon("m40a3_mp");     /// give the player M40A3 Sniper
self GiveWeapon( "remington700_mp" );      /// give the player R700 Sniper
self GiveMaxAmmo("m40a3_mp");      /// give the player max ammo for M40A3
self GiveMaxAmmo( "remington700_mp" );     /// give the player max ammo for R700
setDvar("aim_automelee_enabled", 0);     /// Disable Knife
setDvar("player_meleeRange", 0);     /// Disable Knife 
setDvar( "player_breath_gasp_lerp", "0.001" );
setDvar( "player_breath_gasp_time", "0.001" );
setDvar( "player_breath_gasp_scale", "0.001" );
wait 0.05;

       }
}

Ok, now how do you use this and where?

Go to maps/mp/gametypes/_weapons.gsc (or .gsx depends on 1.7a or 1.8x … iwd or main_shared)

Find onPlayerSpawned() and thread it there

It will look something like this:

onPlayerSpawned()
{
self endon("disconnect");

for(;
{
self waittill("spawned_player");

self.concussionEndTime = 0;
self.hasDoneCombat = false;
self thread watchWeaponUsage();
self thread watchGrenadeUsage();
self thread watchWeaponChange();

self.droppedDeathWeapon = undefined;
self.tookWeaponFrom = [];

self thread updateStowedWeapon();
self thread sniper();
}
}

Now scroll to the end of the file and copy paste the code > save

DONE !

Credits to Dann
https://old.cod4x.ovh/index.php?/forums/topic/178-release-a-simple-server-side-sniper-only-script/&tab=comments#comment-1028