Hello!
So, today I saw that NoFaTe released pre-release of new client and that he made an extension system! I decided to mess around with it a bit, and created this "iSnipe" mod (which isn't nowhere near same like CoD's one, but still it's nice)! And as NoFaTe stated, there are just few functions that we can use at this point, but I hope there will be more in future!
[syntax lang="csharp" lines=""]using System;
using System.Collections.Generic;
using System.Text;
using System.Timers;
using Nexus;
namespace iSnipe
{
public class iSnipe : RomeExt
{
public static DamageInfo info; //damage information class
public static RomeSoldier soldier; //player-soldier information class
public static Timer timer = new Timer(100); //initialising our timer which will be called 10 times a second
public override void OnLevelLoading(string name, bool is_singleplayer) //our callback that gets called by server when loading a level
{
if (!is_singleplayer) //check if there's more than 1 player
{
SetInstantSpawnEnabled(true); //allow instant spawn after death
SetUnlimitedMagsEnabled(false); //disallow unlimited bullet magazines
SetUnlimitedAmmoEnabled(false); //disallow unlimited ammo storage
SetVehiclesEnabled(false); //disallow all vehicles in server
SetWeaponsEnabled(false, new List<string> { "M24" }); //disallow all weapons except M24 sniper rifle
SetAllowedKits(new List<string>() { "KIT_RECON" }); //disallow all kits except Recon kit
info.ExplosionDamage = false; //explosions will now do 0 damage
info.DemolitionDamage = false; //destroyed building which will collapse won't do any damage to players beneath them
info.Stamina = 0x7F800000; //set stamina to infinity a.k.a never stop sprinting
}
}
public override void OnLevelLoaded() //our callback that gets called by server when level has been loaded
{
TimerCheck(); //calling a timer check
}
public void TimerCheck() //our timer check
{
timer.Elapsed += new ElapsedEventHandler(OnTimedEvent); //call event when 0.1 second passed
timer.Interval = 100; //interval is set to 0.1 second
timer.Enabled = true; //enable elapsed event handler
}
public void OnTimedEvent(object source, ElapsedEventArgs e) //our timed event for each 0.1 second
{
OnPlayerUpdate(soldier, info); //call update function
}
public void OnPlayerUpdate(RomeSoldier r_sold, DamageInfo d_info) //our update callback thats called each 100 milliseconds
{
//do stuff here
}
public override void OnExtensionLoaded() //our callback that gets called when extension is loaded
{
//do stuff here
}
}
}
[/syntax]
There are quite of few stuff missing, like anti-camping and limiting the marksmanship mode with a timer, but I'll add that in later versions of this mod! Though anti-camping can already be made with provided vectors and other functions, I just "canceled" that part for future! You can also see that some functions are empty (like "OnPlayerUpdate") -> that's because of the previously named reasons and lack of flexibility, but I can guarantee you that they'll be used in future updates of this extension!
And as a note, I haven't yet tested this mod, so if anyone wanna host it we can try it out together (just find me on TS)!
Also, I was not sure for meanings of some functions, but I tried to guess what they are doing and I've commented them nicely!
Have fun and merry christmas!
Regards,
Fiki!