using System;
namespace SAMP.API
{
public class GameMode
{
#region Class Variables
private static bool _bGameModeInitialized = false;
private static bool _bPlayerPedAnims = false;
private static int _nClassCount = 0;
private static int _nTeamCount = 0;
private static string _strGameModeText = string.Empty;
#endregion
#region Events & Delegates
public delegate void OnInitHandler(object sender, EventArgs e);
public delegate void OnExitHandler(object sender, EventArgs e);
public static event OnInitHandler OnInit;
public static event OnExitHandler OnExit;
#endregion
#region Accessors & Mutators
[Obsolete("This property is deprecated. Please see the SAMP.API.Player.OnClickMap event.", true)]
///
/// Gets or sets whether RCON admins will be teleported to their waypoint when they set one.
///
public static bool AllowAdminTeleport { get { return false; } set { } }
[Obsolete("This property is deprecated.", true)]
///
/// Gets or sets the amount of money dropped when a player dies.
///
public static int DeathDropAmount { get { return 0; } set { } }
[Obsolete("This property is deprecated due to crashes it caused.", true)]
///
/// Gets or sets the zone / area names being shown on screen as a player enters the area.
///
public static bool ZoneNames { get { return false; } set { } }
///
/// Gets the amount of player classes used in the gamemode.
///
public static int ClassCount
{
get { return _nClassCount; }
}
// Pointless property, but meh - I tried to port everything.
///
/// Gets or sets the amount of teams used in the gamemode.
///
/// You can pass 2 billion here if you like, this function has no effect at all.
public static int TeamCount
{
get { return _nTeamCount; }
set { _nTeamCount = value; Core.Natives.SetTeamCount(value); }
}
///
/// Gets or sets the name of the gamemode, which appears in the list of servers.
///
public static string Text
{
get { return _strGameModeText; }
set { _strGameModeText = value; Core.Natives.SetGameModeText(value); }
}
///
/// Gets or sets whether to use standard player walking animation (animation of CJ)
///
/// Only works when placed under the SAMP.API.GameMode.Init event.
public static bool UsePlayerPedAnims
{
get { return _bPlayerPedAnims; }
set
{
// This property only works under Init event
if(!_bGameModeInitialized)
{
_bPlayerPedAnims = value;
// Check the value was true. We don't want to call the function
// if they didn't intend it to be true.
if(value)
Core.Natives.UsePlayerPedAnims();
}
else
throw new Exception("The GmaeMode has already been initialized.");
}
}
#endregion
#region Public Methods
///
/// Adds a class to class selection.
///
/// The skin which the player will spawn with.
/// The spawnpoint of this class.
/// The direction in which the player should face after spawning.
/// The first spawn-weapon for the player.
/// The amount of ammunition for the primary spawnweapon.
/// The second spawn-weapon for the player.
/// The amount of ammunition for the secondary spawnweapon.
/// The third spawn-weapon for the player.
/// The amount of ammunition for the third spawnweapon.
/// Returns the ID of the class which was just added.
/// Classes are used so players may spawn with a skin of their choice and so on.
/// SAMP.API.GameMode.AddPlayerClass(SAMP.API.Skin.cj, new Vector3(1958.33f, 1343.12f, 15.36f), 269.15, 26, 36, 28, 150, 0, 0);
public int AddPlayerClass(Skin skin, Vector3 spawnPoint, float angle, int weapon1, int weapon1_ammo, int weapon2, int weapon2_ammo, int weapon3, int weapon3_ammo)
{
// Call native
_nClassCount++;
return Core.Natives.AddPlayerClass((int)skin, spawnPoint.X, spawnPoint.Y, spawnPoint.Z, angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
}
///
/// Adds a class to class selection, with a team parameter.
///
/// The team you want the player to spawn in.
/// The skin which the player will spawn with.
/// The spawnpoint of this class.
/// The direction in which the player should face after spawning.
/// The first spawn-weapon for the player.
/// The amount of ammunition for the primary spawnweapon.
/// The second spawn-weapon for the player.
/// The amount of ammunition for the secondary spawnweapon.
/// The third spawn-weapon for the player.
/// The amount of ammunition for the third spawnweapon.
/// Returns the ID of the class which was just added.
/// Classes are used so players may spawn with a skin of their choice and so on.
/// SAMP.API.GameMode.AddPlayerClass(15, SAMP.API.Skin.cj, new Vector3(1958.33f, 1343.12f, 15.36f), 269.15, 26, 36, 28, 150, 0, 0);
public int AddPlayerClass(int team, Skin skin, Vector3 spawnPoint, float angle, int weapon1, int weapon1_ammo, int weapon2, int weapon2_ammo, int weapon3, int weapon3_ammo)
{
// Call native
_nClassCount++;
return Core.Natives.AddPlayerClassEx(team, (int)skin, spawnPoint.X, spawnPoint.Y, spawnPoint.Z, angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
}
#endregion
#region Internal Methods
///
/// Invoke the OnExit event.
///
internal static void _OnExit()
{
try { OnExit(null, null); }
catch { }
_bGameModeInitialized = false;
}
///
/// Invoke the OnInit event.
///
internal static void _OnInit()
{
try { OnInit(null, null); }
catch { }
_bGameModeInitialized = true;
}
#endregion
};
};