Similar to my topic on mw3 resources, I am going to share the mod that was running on Aspire ffa sniper server on bo2.
It contains code for:
- Setting server dvars that change movement and scoping mechanics to make the gameplay faster.
- Removing disallowed weapons and weapon attachments.
- Increased movement speed when holding knife.
- Setting sniper damage to 1000 so hitmarkers are removed, and disabling all other damage types. (bug: players will not die when falling off map such as hijacked.)
- Info text at bottom of screen to inform player of mod functionality and rules. It flips between texts every 6 seconds and does not repeat texts on respawn.
- Simple watermark to display discord link.
Use it as a learning resource or take whatever parts you want and put it on your server.
#include maps\mp\gametypes\_hud_util;
/*
* Aspire sniper mod bo2
* Author: ColouRz
* Version: 1.0
* Date: 9 sep 2021
*/
init()
{
level.playerDamageStub = level.callbackplayerdamage;
level.callbackplayerdamage = ::Callback_PlayerDamageHook;
setup_server_dvars();
level thread onplayerconnect();
player thread onplayerspawned();
}
onplayerconnect()
{
for ( ;; )
{
level waittill( "connecting", player );
player thread onplayerspawned();
}
}
onplayerspawned()
{
level endon( "game_ended" );
self endon( "disconnect" );
self.info_font = self createFontString( "Objective", 1 );
self.info_font setPoint( "BOTTOM", "BOTTOM", 0, 35 );
i = 0;
for(;;)
{
self waittill( "spawned_player" );
self simple_watermark();
self apply_weapon_restrictions();
self freezeControls(false);
self thread update();
self.info_font setText("");
if(i < 4)
{
self thread info_text(self.info_font,i);
i++;
}
}
}
setup_server_dvars()
{
level.killstreaksenabled = 0;
setdvar("sv_allowAimAssist","0");
setdvar("g_maxDroppedWeapons", "0"); // dont work
setdvar("scr_disable_weapondrop","1"); // dont work
setDvar( "player_breath_gasp_lerp", "0.001" );
setDvar( "player_breath_gasp_time", "0.001" );
setDvar( "player_breath_gasp_scale", "0.001" );
setDvar( "jump_slowdownEnable", "0");
setDvar( "jump_spreadAdd", "0");
setDvar( "jump_height", "44");
setDvar( "bg_viewBobMax", "0");
setDvar( "bg_swingSpeed", "1");
setDvar( "bg_weaponBobMax", "0.5");
setDvar( "friction", "1");
//setDvar( "player_sprintSpeedScale", "1.5");
//setDvar( "player_sprintStrafeSpeedScale", "1.5");
//setDvar( "player_strafeSpeedScale", "1.5");
setDvar("player_sprintCameraBob","0.4");
//setDvar("player_sprintForwardMinimum","1");
setDvar("player_sprintRechargePause","0");
//setDvar("player_sprintMinTime","0.05");
//setDvar( "player_sprintThreshold", "1");
setDvar( "player_sprintUnlimited", "1");
setDvar("bg_forceAnimOverrideTimerCheck", "0");
setDvar("bg_viewKickMax", "0");
setDvar("cg_drawBreathHint", "0");
setDvar("cg_drawHoldBreathHint", "0");
setDvar("cg_gun_x", "5");
setDvar("cg_gun_y", "-1");
setDvar("cg_gun_z", "-1");
//setDvar("cg_scoreboardMyColor", "1 0 0 0.5");
setDvar("player_adsExitDelay", "0");
setDvar("player_clipSizeMultiplier", "10");
setDvar("sv_FakeRemoteClient", "1");
setDvar("g_useholdspawndelay", "0");
setDvar("perk_mantleReduction", "5");
setDvar("perk_fastLadderClimbMultiplier", "3");
setDvar("scr_game_medalsenabled", "0");
setDvar("scr_gunxpscale", "0.1");
setDvar("scr_xpscale", "0.1");
setDvar("r_fog", "0");
setDvar("r_fog_disable", "1");
setDvar( "fx_enable", "0");
setDvar( "r_detail", "0");
setDvar( "r_distortion", "0");
setDvar( "r_dof_enable", "0");
setDvar( "r_drawSun", "0");
setDvar( "ragdoll_enable", "0");
setDvar( "ui_customModeName", "^4Aspire ^7Sniper ^2Arcade");
}
apply_weapon_restrictions()
{
self endon( "disconnect" );
self endon( "death" );
self disableoffhandweapons();
wait 0.1; // wait for player to pull out weapon.
weapon = self getcurrentweapon();
if(isSubStr(weapon, "ballista") || isSubStr(weapon, "dsr"))
{
weapon_parts = strtok(weapon,"+");
weapon_allowed = true;
for(i = 1; i < weapon_parts.size; i++)
{
if(weapon_parts[i] == "steadyaim" || weapon_parts[i] == "acog") // bo2 compilator only allows 2 conditions.
{
weapon_parts[i] = "illegal";
weapon_allowed = false;
}
else if(weapon_parts[i] == "silencer" || weapon_parts[i] == "is")
{
weapon_parts[i] = "illegal";
weapon_allowed = false;
}
else if(weapon_parts[i] == "ir" || weapon_parts[i] == "vzoom")
{
weapon_parts[i] = "illegal";
weapon_allowed = false;
}
}
if(!weapon_allowed)
{
self takeweapon(weapon);
new_weapon = weapon_parts[0];
for(i = 1; i < weapon_parts.size; i++)
{
if(weapon_parts[i] != "illegal")
new_weapon += "+" + weapon_parts[i];
}
self giveweapon(new_weapon);
self switchtoweapon(new_weapon);
}
}
else
{
self takeweapon(weapon);
self giveweapon("ballista_mp+fmj+swayreduc");
self switchtoweapon("ballista_mp+fmj+swayreduc");
}
// Secondary
weps = self getweaponslistprimaries();
if(weps.size == 3)
{
self takeweapon(weps[1]);
}
weps = self getweaponslistprimaries();
if(weps[0] != "none" && weps[1] != "knife_held_mp")
{
self takeweapon(weps[0]);
self giveweapon("knife_held_mp");
}
}
update()
{
self endon( "disconnect" );
self endon( "death" );
for(;;)
{
currentWeapon = self getcurrentweapon();
if ( isSubStr(currentWeapon, "ballista") || isSubStr(currentWeapon, "dsr") )
{
self setclientdvar("g_speed","200");
}
else if(currentWeapon == "knife_held_mp")
{
self setclientdvar("g_speed","230");
}
wait 0.05;
}
}
Callback_PlayerDamageHook( einflictor, eattacker, idamage, idflags, smeansofdeath, sweapon, vpoint, vdir, shitloc, timeoffset, boneindex ) {
self endon( "disconnect" );
if(isSubStr(sweapon, "ballista") || isSubStr(sweapon, "dsr"))
{
idamage = 1000;
// calling the damage function below only if allowed weapons are used, meaning no hitmarkers, flinch or blood is given by disallowed weapons which is nice.
[[level.playerDamageStub]]( einflictor, eattacker, idamage, idflags, smeansofdeath, sweapon, vpoint, vdir, shitloc, timeoffset, boneindex );
}
}
info_text(info_font,i)
{
self endon( "disconnect" );
self endon( "death" );
texts = [];
texts[0] = "Knife makes you run faster";
texts[1] = "Allowed = Ballista, DSR, Ballistics CPU, Mags, FMJ";
texts[2] = "Use a sniper with allowed attachments to avoid having to pull out your weapon each respawn";
texts[3] = "Mod made by Aspire ColouRz, enjoy :)";
info_font setText("^2"+texts[i]);
wait 6;
info_font setText("");
}
simple_watermark()
{
self.website = self createFontString( "Objective", 1 );
self.website setPoint( "TOP", "RIGHT", 10, -210 );
self.website setText( "^5stats: team-aspire.eu" );
self.discord = self createFontString( "Objective", 1 );
self.discord setPoint( "TOP", "RIGHT", 10, -220 );
self.discord setText( "^5discord.gg/yRvWUPC" );
}
print(txt)
{
self iPrintLnBold(txt);
wait 1;
}