commit 85bf078a27cd845759f5e7750cfd9998ee5def01 Author: Oliver Booth Date: Sat Aug 27 18:10:32 2022 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a437a65 --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +*.swp +*.*~ +project.lock.json +.DS_Store +*.pyc +nupkg/ + +# Visual Studio Code +.vscode + +# Rider +.idea + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +msbuild.log +msbuild.err +msbuild.wrn + +# Visual Studio 2015 +.vs/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..d4b1d50 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# SAMP.NET +C# / .NET bindings for SA:MP + +## About +This is an archive of a project I wrote back in my college days in 2012. It introduced .NET bindings for the SA:MP Pawn API. As such, the code is not up to standards that I feel are "good" these days, and much of this project was a learning experiment. + +I have zero intention to ever continue this project, but this repository shall be public, read-only, and archived, for the forseeable future. I am hoping someone may benefit from this. + +## How it works +SA:MP gamemodes are written in an extremely primitive language called Pawn. While Pawn is not very powerful, it does allow you to call into native code. The way this project works is Pawn will hook SA:MP events and functions, call into C++ code, which then itself uses Mono to invoke .NET methods - essentially giving you the ability to write gamemodes in C# / VB / any .NET language. diff --git a/sampdotnet/API/Enums/Alignment.cs b/sampdotnet/API/Enums/Alignment.cs new file mode 100644 index 0000000..1bda2ce --- /dev/null +++ b/sampdotnet/API/Enums/Alignment.cs @@ -0,0 +1,11 @@ + +namespace SAMP.API { + /// + /// Alignment. + /// + public enum Alignment : int { + Left = 1, + Centered = 2, + Right = 3 + }; +}; diff --git a/sampdotnet/API/Enums/CameraMode.cs b/sampdotnet/API/Enums/CameraMode.cs new file mode 100644 index 0000000..d3a9115 --- /dev/null +++ b/sampdotnet/API/Enums/CameraMode.cs @@ -0,0 +1,21 @@ + +namespace SAMP.API { + /// + /// Camera mode. + /// + public enum CameraMode : int { + TramTrain = 3, + OnFootChase = 4, + SniperAim = 7, + RPGAim = 8, + ChaseCinematicSprayGarage = 15, + FrontCloseupCar = 16, + NormalCarChase = 18, + BoatChase = 22, + Picture = 46, + HeatseekerAim = 51, + OverShoulderOnFootWeaponAim = 53, + PassengerWindow = 55, + NewsReporterChaseCinematic = 56 + }; +}; diff --git a/sampdotnet/API/Enums/ComponentSlot.cs b/sampdotnet/API/Enums/ComponentSlot.cs new file mode 100644 index 0000000..7151e04 --- /dev/null +++ b/sampdotnet/API/Enums/ComponentSlot.cs @@ -0,0 +1,22 @@ + +namespace SAMP.API { + /// + /// Component slot. + /// + public enum ComponentSlot : int { + Spoiler = 0, + Hood = 1, + Root = 2, + SideSkirt = 3, + Lamps = 4, + Nitro = 5, + Exhaust = 6, + Wheels = 7, + Stereo = 8, + Hydraulics = 9, + FrontBumper = 10, + RearBumper = 11, + VentRight = 12, + VentLeft = 13 + }; +}; diff --git a/sampdotnet/API/Enums/DialogStyle.cs b/sampdotnet/API/Enums/DialogStyle.cs new file mode 100644 index 0000000..cf05b2f --- /dev/null +++ b/sampdotnet/API/Enums/DialogStyle.cs @@ -0,0 +1,12 @@ + +namespace SAMP.API { + /// + /// Dialog style. + /// + public enum DialogStyle : int { + MessageBox = 0, + Input = 1, + List = 2, + Password = 3 + }; +}; diff --git a/sampdotnet/API/Enums/DisconnectReason.cs b/sampdotnet/API/Enums/DisconnectReason.cs new file mode 100644 index 0000000..40ec517 --- /dev/null +++ b/sampdotnet/API/Enums/DisconnectReason.cs @@ -0,0 +1,8 @@ + +namespace SAMP.API { + public enum DisconnectReason : int { + TimedOut = 0, + LeftNormally, + KickedOrBanned + }; +}; diff --git a/sampdotnet/API/Enums/Keys.cs b/sampdotnet/API/Enums/Keys.cs new file mode 100644 index 0000000..032f37d --- /dev/null +++ b/sampdotnet/API/Enums/Keys.cs @@ -0,0 +1,33 @@ + +namespace SAMP.API { + /// + /// Keys. + /// + public enum Keys : int { + Action = 1, + Crouch = 2, + Fire = 4, + Sprint = 8, + SecondaryAttack = 16, + Jump = 32, + LookRight = 64, + Handbreak = 128, + Aim = Handbreak, + LookLeft = 256, + Submission = 512, + LookBehind = 512, + Walk = 1024, + AnalogUp = 2048, + AnalogDown = 4096, + AnalogLeft = 8192, + AnalogRight = 16384, + Yes = 65536, + No = 131072, + CtrlBack = 262144, + + Up = -128, + Down = 128, + Left = -128, + Right = 128 + }; +}; diff --git a/sampdotnet/API/Enums/PlayerState.cs b/sampdotnet/API/Enums/PlayerState.cs new file mode 100644 index 0000000..b035756 --- /dev/null +++ b/sampdotnet/API/Enums/PlayerState.cs @@ -0,0 +1,18 @@ + +namespace SAMP.API { + /// + /// Player state. + /// + public enum PlayerState : int { + None = 0, + OnFoot = 1, + Driver = 2, + Passenger = 3, + ExitVehicle = 4, + EnterVehicleDriver = 5, + EnterVehiclePassenger = 6, + Wasted = 7, + Spawned = 8, + Spectating = 9, + }; +}; diff --git a/sampdotnet/API/Enums/Skin.cs b/sampdotnet/API/Enums/Skin.cs new file mode 100644 index 0000000..6bdbece --- /dev/null +++ b/sampdotnet/API/Enums/Skin.cs @@ -0,0 +1,307 @@ + +namespace SAMP.API { + /// + /// Skin. + /// + public enum Skin : int { + cj = 0, + truth = 1, + maccer = 2, + andre = 3, + bbthin = 4, + bb = 5, + emmet = 6, + male01 = 7, + janitor = 8, + bfori = 9, + bfost = 10, + vbfycrp = 11, + bfyri = 12, + bfyst = 13, + bmori = 14, + bmost = 15, + bmyap = 16, + bmybu = 17, + bmybe = 18, + bmydj = 19, + bmyri = 20, + bmycr = 21, + bmyst = 22, + wmybmx = 23, + wbdyg1 = 24, + wbdyg2 = 25, + wmybp = 26, + wmycon = 27, + bmydrug = 28, + wmydrug = 29, + hmydrug = 30, + dwfolc = 31, + dwmolc1 = 32, + dwmolc2 = 33, + dwmylc1 = 34, + hmogar = 35, + wmygol1 = 36, + wmygol2 = 37, + hfori = 38, + hfost = 39, + hfyri = 40, + hfyst = 41, + jethro = 42, + hmori = 43, + hmost = 44, + hmybe = 45, + hmyri = 46, + hmycr = 47, + hmyst = 48, + omokung = 49, + wmymech = 50, + bmymoun = 51, + wmymoun = 52, + unknown = 53, + ofost = 54, + ofyri = 55, + ofyst = 56, + omori = 57, + omost = 58, + omyri = 59, + omyst = 60, + wmyplt = 61, + wmopj = 62, + bfypro = 63, + hfypro = 64, + kendl = 65, + bmypol1 = 66, + bmypol2 = 67, + wmoprea = 68, + sbfyst = 69, + wmosci = 70, + wmysgrd = 71, + swmyhp1 = 72, + swmyhp2 = 73, + swfopro = 75, + wfystew = 76, + swmotr1 = 77, + wmotr1 = 78, + bmotr1 = 79, + vbmybox = 80, + vwmybox = 81, + vhmyelv = 82, + vbmyelv = 83, + vimyelv = 84, + vwfypro = 85, + ryder3 = 86, + vwfyst1 = 87, + wfori = 88, + wfost = 89, + wfyjg = 90, + wfyri = 91, + wfyro = 92, + wfyst = 93, + wmori = 94, + wmost = 95, + wmyjg = 96, + wmylg = 97, + wmyri = 98, + wmyro = 99, + wmycr = 100, + wmyst = 101, + ballas1 = 102, + ballas2 = 103, + ballas3 = 104, + fam1 = 105, + fam2 = 106, + fam3 = 107, + lsv1 = 108, + lsv2 = 109, + lsv3 = 110, + maffa = 111, + maffb = 112, + mafboss = 113, + vla1 = 114, + vla2 = 115, + vla3 = 116, + triada = 117, + triadb = 118, + sindaco = 119, + triboss = 120, + dnb1 = 121, + dnb2 = 122, + dnb3 = 123, + vmaff1 = 124, + vmaff2 = 125, + vmaff3 = 126, + vmaff4 = 127, + dnmylc = 128, + dnfolc1 = 129, + dnfolc2 = 130, + dnfylc = 131, + dnmolc1 = 132, + dnmolc2 = 133, + sbmotr2 = 134, + swmotr2 = 135, + sbmytr3 = 136, + swmotr3 = 137, + wfybe = 138, + bfybe = 139, + hfybe = 140, + sofybu = 141, + sbmyst = 142, + sbmycr = 143, + bmycg = 144, + wfycrk = 145, + hmycm = 146, + wmybu = 147, + bfybu = 148, + smokev = 149, + wfybu = 150, + dwfylc1 = 151, + wfypro = 152, + wmyconb = 153, + wmybe = 154, + wmypizz = 155, + bmobar = 156, + cwfyhb = 157, + cwmofr = 158, + cwmohb1 = 159, + cwmohb2 = 160, + cwmyfr = 161, + cwmyhb1 = 162, + bmyboun = 163, + wmyboun = 164, + wmomib = 165, + bmymib = 166, + wmybell = 167, + bmochil = 168, + sofyri = 169, + somyst = 170, + vwmybjd = 171, + vwfycrp = 172, + sfr1 = 173, + sfr2 = 174, + sfr3 = 175, + bmybar = 176, + wmybar = 177, + wfysex = 178, + wmyammo = 179, + bmytatt = 180, + vwmycr = 181, + vbmocd = 182, + vbmycr = 183, + vhmycr = 184, + sbmyri = 185, + somyri = 186, + somybu = 187, + swmyst = 188, + wmyva = 189, + copgrl3 = 190, + gungrl3 = 191, + mecgrl3 = 192, + nurgrl3 = 193, + crogrl3 = 194, + gangrl3 = 195, + cwfofr = 196, + cwfohb = 197, + cwfyfr1 = 198, + cwfyfr2 = 199, + cwmyhb2 = 200, + dwfylc2 = 201, + dwmylc2 = 202, + omykara = 203, + wmykara = 204, + wfyburg = 205, + vwmycd = 206, + vhfypro = 207, + suzie = 208, + omonood = 209, + omoboat = 210, + wfyclot = 211, + vwmotr1 = 212, + vwmotr2 = 213, + vwfywai = 214, + sbfori = 215, + swfyri = 216, + wmyclot = 217, + sbfost = 218, + sbfyri = 219, + sbmocd = 220, + sbmori = 221, + sbmost = 222, + shmycr = 223, + sofori = 224, + sofost = 225, + sofyst = 226, + somobu = 227, + somori = 228, + somost = 229, + swmotr5 = 230, + swfori = 231, + swfost = 232, + swfyst = 233, + swmocd = 234, + swmori = 235, + swmost = 236, + shfypro = 237, + sbfypro = 238, + swmotr4 = 239, + swmyri = 240, + smyst = 241, + smyst2 = 242, + sfypro = 243, + vbfyst2 = 244, + vbfypro = 245, + vhfyst3 = 246, + bikera = 247, + bikerb = 248, + bmypimp = 249, + swmycr = 250, + wfylg = 251, + wmyva2 = 252, + bmosec = 253, + bikdrug = 254, + wmych = 255, + sbfystr = 256, + swfystr = 257, + heck1 = 258, + heck2 = 259, + bmycon = 260, + wmycd1 = 261, + bmocd = 262, + vwfywa2 = 263, + wmoice = 264, + tenpen = 265, + pulaski = 266, + Hernandez = 267, + dwayne = 268, + smoke = 269, + sweet = 270, + ryder = 271, + mafiaboss = 272, + tbone = 273, + laemt1 = 274, + lvemt1 = 275, + sfemt1 = 276, + lafd1 = 277, + lvfd1 = 278, + sffd1 = 279, + lapd1 = 280, + sfpd1 = 281, + lvpd1 = 282, + csher = 283, + lapdm1 = 284, + swat = 285, + fbi = 286, + army = 287, + dsher = 288, + zero = 289, + rose = 290, + paul = 291, + cesar = 292, + ogloc = 293, + wuzimu = 294, + torino = 295, + jizzy = 296, + maddogg = 297, + cat = 298, + claude = 299 + }; +}; diff --git a/sampdotnet/API/Enums/SpecialAction.cs b/sampdotnet/API/Enums/SpecialAction.cs new file mode 100644 index 0000000..7e776b9 --- /dev/null +++ b/sampdotnet/API/Enums/SpecialAction.cs @@ -0,0 +1,29 @@ + +namespace SAMP.API { + /// + /// Special action. + /// + public enum SpecialAction : int { + None = 0, + UseJetpack = 2, + Dance1 = 5, + Dance2 = 6, + Dance3 = 7, + Dance4 = 8, + HandsUp = 10, + UseCellPhone = 11, + Sitting = 12, + StopUseCellPhone = 13, + + Duck = 1, // Can't be set + EnterVehicle = 3, // Can't be set + ExitVehicle = 4, // Can't be set + Beer = 20, + Ciggy = 21, + Wine = 22, + Sprunk = 23, + Pissing = 68, + + Cuffed = 24 + }; +}; diff --git a/sampdotnet/API/Enums/Weapon.cs b/sampdotnet/API/Enums/Weapon.cs new file mode 100644 index 0000000..a9b7b28 --- /dev/null +++ b/sampdotnet/API/Enums/Weapon.cs @@ -0,0 +1,51 @@ + +namespace SAMP.API { + /// + /// Weapon. + /// + public enum Weapon : int { + Fist = 0, + BrassKnucles, + GolfClub, + Nightstick, + Knife, + BaseballBat, + Shovel, + PoolCue, + Katana, + Chainsaw, + DoubleEndedDildo, + Dildo, + Vibrator, + SilverVibrator, + Flowers, + Cane, + Grenade, + TearGas, + MolotovCocktail, + NineMM, + SilencedNineMM, + DesertEagle, + Shotgun, + SawnoffShotgun, + CombatShotgun, + MicroSMG, + MP5, + AK47, + M4, + Tec9, + CountryRifle, + RPG, + HSRocket, + FlameThrower, + Minigun, + SatchelCharge, + Detonator, + Spraycan, + FireExtinguisher, + Camera, + NightVisionGoggles, + ThermalGoggles, + Parachute + }; +}; diff --git a/sampdotnet/API/Enums/WeaponState.cs b/sampdotnet/API/Enums/WeaponState.cs new file mode 100644 index 0000000..9cc6cb5 --- /dev/null +++ b/sampdotnet/API/Enums/WeaponState.cs @@ -0,0 +1,13 @@ + +namespace SAMP.API { + /// + /// Weapon state. + /// + public enum WeaponState : int { + Unknown = -1, + NoBullets = 0, + LastBullet = 1, + MoreBullets = 2, + Reloading = 3 + }; +}; diff --git a/sampdotnet/API/Enums/WeaponType.cs b/sampdotnet/API/Enums/WeaponType.cs new file mode 100644 index 0000000..1894759 --- /dev/null +++ b/sampdotnet/API/Enums/WeaponType.cs @@ -0,0 +1,19 @@ + +namespace SAMP.API { + /// + /// Weapon type. + /// + public enum WeaponType : int { + Pistol = 0, + PistolSilenced, + DesertEagle, + Shotgun, + SawnoffShotgun, + SPAS12Shotgun, + MicroUzi, + MP5, + AK47, + M4, + SniperRifle + }; +}; diff --git a/sampdotnet/API/EventData/DialogResponseEventArgs.cs b/sampdotnet/API/EventData/DialogResponseEventArgs.cs new file mode 100644 index 0000000..2052069 --- /dev/null +++ b/sampdotnet/API/EventData/DialogResponseEventArgs.cs @@ -0,0 +1,87 @@ +using System; + +namespace SAMP.API.EventData { + public class DialogResponseEventArgs : EventArgs { + #region Class Variables + + private int + m_iId, + m_iResponse, + m_iListItem; + private string + m_strInputText; + private bool + m_bPassOn; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The ID of the dialog the player responded to, assigned in Player.ShowDialog. + /// 1 for first button and 0 for second button. + /// The ID of the list item selected by the player. + /// The text entered into the input box by the player or the selected list item text. + public DialogResponseEventArgs(int dialogid, int response, int listitem, string inputtext) { + this.m_iId = dialogid; + this.m_iResponse = response; + this.m_iListItem = listitem; + this.m_strInputText = inputtext; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the ID of the dialog the player responded to, assigned in . + /// + public int DialogID { + get { + return this.m_iId; + } + } + + /// + /// Gets the response from the dialog. + /// + public int Response { + get { + return this.m_iResponse; + } + } + + /// + /// Gets the ID of the list item selected by the player. + /// + public int ListItem { + get { + return this.m_iListItem; + } + } + + /// + /// Gets the text entered into the input box by the player or the selected list item text. + /// + public string InputText { + get { + return this.m_strInputText; + } + } + + /// + /// Gets or sets whether or not this callback should be passed on to filterscripts. + /// + public bool ContinueToFilterscripts { + get { + return this.m_bPassOn; + } set { + this.m_bPassOn = value; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Player/PlayerClickMapEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerClickMapEventArgs.cs new file mode 100644 index 0000000..3c1ddcd --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerClickMapEventArgs.cs @@ -0,0 +1,37 @@ +using System; + +namespace SAMP.API.EventData { + public class PlayerClickMapEventArgs : EventArgs { + #region Class Variables + + private Vector3 + m_qPosition; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The coordinates of where the player clicked. + public PlayerClickMapEventArgs(Vector3 position) { + this.m_qPosition = position; + } + + #endregion + + #region Accessors & Mutators + + /// + /// The coordinates of where the player clicked + /// + public Vector3 Position { + get { + return this.m_qPosition; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Player/PlayerCommandTextEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerCommandTextEventArgs.cs new file mode 100644 index 0000000..b24a055 --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerCommandTextEventArgs.cs @@ -0,0 +1,51 @@ +using System; + +namespace SAMP.API.EventData { + public class PlayerCommandTextEventArgs : EventArgs { + #region Class Variables + + private string + m_strMessage; + private bool + m_bHandled; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The chat message. + public PlayerCommandTextEventArgs(string message) { + this.m_strMessage = message; + this.m_bHandled = false; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the chat message associated with this event. + /// + public string Message { + get { + return this.m_strMessage; } + } + + /// + /// Gets or sets whether the event was handled. Returning TRUE will prevent the 'SERVER: Unknown Command' message being shown. + /// + public bool Handled + { + get { + return this.m_bHandled; + } set { + this.m_bHandled = value; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Player/PlayerDeathEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerDeathEventArgs.cs new file mode 100644 index 0000000..b1d4789 --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerDeathEventArgs.cs @@ -0,0 +1,50 @@ +using System; + +namespace SAMP.API.EventData { + public class PlayerDeathEventArgs : EventArgs { + #region Class Variables + + private Player + m_qKiller; + private int + m_iReason; + + #endregion + + #region Constructor + + /// + /// Creates a new PlayerDeathEventArgs object. + /// + /// The player who killed the player who died. NULL if none. + /// The ID of the reason for the player's death. + public PlayerDeathEventArgs(Player killer, int reason) { + this.m_qKiller = killer; + this.m_iReason = reason; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the player who killed the player who died. NULL if none. + /// + public Player Killer { + get { + return this.m_qKiller; + } + } + + /// + /// Gets the ID of the reason for the player's death. + /// + public int Reason { + get { + return this.m_iReason; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Player/PlayerDisconnectEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerDisconnectEventArgs.cs new file mode 100644 index 0000000..670d974 --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerDisconnectEventArgs.cs @@ -0,0 +1,37 @@ +using System; + +namespace SAMP.API.EventData { + public class PlayerDisconnectEventArgs : EventArgs { + #region Class Variables + + private DisconnectReason + m_qReason; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The reason for the disconnect. + public PlayerDisconnectEventArgs(DisconnectReason reason) { + this.m_qReason = reason; + } + + #endregion + + #region Accessors & Mutators + + /// + /// The reason they left. + /// + public DisconnectReason Reason { + get { + return this.m_qReason; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Player/PlayerEnterExitModShopEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerEnterExitModShopEventArgs.cs new file mode 100644 index 0000000..2693f60 --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerEnterExitModShopEventArgs.cs @@ -0,0 +1,50 @@ +using System; + +namespace SAMP.API.EventData { + public class PlayerEnterExitModShopEventArgs : EventArgs { + #region Class Variables + + private bool + m_bEntering; + private int + m_iInterior; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// true if the player is entering, otherwise false. + /// The interior ID of the modshop that the player is entering (or 0 if exiting). + public PlayerEnterExitModShopEventArgs(bool entering, int interiodid) { + this.m_bEntering = entering; + this.m_iInterior = interiodid; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets whether or not the player is Entering a mod shop. + /// + public bool Entering { + get { + return this.m_bEntering; + } + } + + /// + /// Gets the interior ID of the modshop that the player is entering. This property will be 0 if the player is exiting. + /// + public int Interior { + get { + return this.m_iInterior; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Player/PlayerEnterVehicleEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerEnterVehicleEventArgs.cs new file mode 100644 index 0000000..1c406b2 --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerEnterVehicleEventArgs.cs @@ -0,0 +1,57 @@ +using System; + +namespace SAMP.API.EventData +{ + public class PlayerEnterVehicleEventArgs : EventArgs + { + #region Class Variables + + private Vehicle _qVehicle; + private bool _bIsPassenger; + + #endregion + + #region Constructor + + /// + /// Creates a new PlayerEnterVehicleEventArgs object. + /// + /// The vehicle the player is attempting to enter. + /// True = Driver, False = Passenger. + public PlayerEnterVehicleEventArgs(Vehicle vehicle, bool passenger) + { + _qVehicle = vehicle; + _bIsPassenger = passenger; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets whether or not the player was entering as a driver. + /// + public bool Driver + { + get { return !_bIsPassenger; } + } + + /// + /// Gets whether or not the player was entering as a passenger. + /// + public bool Passenger + { + get { return _bIsPassenger; } + } + + /// + /// Gets the vehicle the player is attempting to enter. + /// + public Vehicle Vehicle + { + get { return _qVehicle; } + } + + #endregion + }; +}; \ No newline at end of file diff --git a/sampdotnet/API/EventData/Player/PlayerExitVehicleEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerExitVehicleEventArgs.cs new file mode 100644 index 0000000..5d124c6 --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerExitVehicleEventArgs.cs @@ -0,0 +1,37 @@ +using System; + +namespace SAMP.API.EventData { + public class PlayerExitVehicleEventArgs : EventArgs { + #region Class Variables + + private Vehicle + m_qVehicle; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The vehicle the player is exiting. + public PlayerExitVehicleEventArgs(Vehicle vehicle) { + this.m_qVehicle = vehicle; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the vehicle the player is exiting. + /// + public Vehicle Vehicle { + get { + return this.m_qVehicle; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Player/PlayerPickUpPickupEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerPickUpPickupEventArgs.cs new file mode 100644 index 0000000..dcb129f --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerPickUpPickupEventArgs.cs @@ -0,0 +1,37 @@ +using System; + +namespace SAMP.API.EventData { + public class PlayerPickUpPickupEventArgs : EventArgs { + #region Class Variables + + private int + m_iId; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The ID of the pickup. + public PlayerPickUpPickupEventArgs(int pickupid) { + this.m_iId = pickupid; + } + + #endregion + + #region Accessors & Mutators + + /// + /// The ID of the pickup. + /// + public int PickUp { + get { + return this.m_iId; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Player/PlayerRequestClassEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerRequestClassEventArgs.cs new file mode 100644 index 0000000..71db4d5 --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerRequestClassEventArgs.cs @@ -0,0 +1,50 @@ +using System; + +namespace SAMP.API.EventData { + public class PlayerRequestClassEventArgs : EventArgs { + #region Class Variables + + private int + m_iClassId; + private bool + m_bCancel; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The reason for the disconnect. + public PlayerRequestClassEventArgs(int classid) { + m_iClassId = classid; + } + + #endregion + + #region Accessors & Mutators + + /// + /// The ID of the current class being viewed. + /// + public int Class { + get { + return this.m_iClassId; + } + } + + /// + /// Gets or sets whether the event should cancel (class denied.) + /// + public bool Cancel { + get { + return this.m_bCancel; + } set { + this.m_bCancel = value; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Player/PlayerSpawnEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerSpawnEventArgs.cs new file mode 100644 index 0000000..a6202cc --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerSpawnEventArgs.cs @@ -0,0 +1,28 @@ +using System; + +namespace SAMP.API.EventData { + public class PlayerSpawnEventArgs : EventArgs { + #region Class Variables + + private bool + m_bCancel; + + #endregion + + #region Accessors & Mutators + + /// + /// Gets or sets whether the event should be cancelled (send back to class selection). + /// + public bool Cancel + { + get { + return this.m_bCancel; + } set { + this.m_bCancel = value; + } + } + + #endregion + }; +}; \ No newline at end of file diff --git a/sampdotnet/API/EventData/Player/PlayerStateChangeEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerStateChangeEventArgs.cs new file mode 100644 index 0000000..715fb1b --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerStateChangeEventArgs.cs @@ -0,0 +1,47 @@ +using System; + +namespace SAMP.API.EventData { + public class PlayerStateChangeEventArgs : EventArgs { + #region Class Variables + + private PlayerState[] state = { PlayerState.None, PlayerState.None }; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The player's new state. + /// The player's old state. + public PlayerStateChangeEventArgs(PlayerState newState, PlayerState oldState) { + this.state[0] = newState; + this.state[1] = oldState; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the player's new state. + /// + public PlayerState NewState { + get { + return this.state[0]; + } + } + + /// + /// Gets the player's old state. + /// + public PlayerState OldState { + get { + return this.state[1]; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Player/PlayerStreamEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerStreamEventArgs.cs new file mode 100644 index 0000000..2ce019e --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerStreamEventArgs.cs @@ -0,0 +1,37 @@ +using System; + +namespace SAMP.API.EventData { + public class PlayerStreamEventArgs : EventArgs { + #region Class Variables + + private Player + m_qPlayer; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The player who the player streamed in or out for. + public PlayerStreamEventArgs(Player forplayer) { + this.m_qPlayer = forplayer; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the player who the player streamed in or out for. + /// + public Player ForPlayer { + get { + return this.m_qPlayer; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Player/PlayerTextEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerTextEventArgs.cs new file mode 100644 index 0000000..45b9b69 --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerTextEventArgs.cs @@ -0,0 +1,54 @@ +using System; + +namespace SAMP.API.EventData { + public class PlayerTextEventArgs : EventArgs { + #region Class Variables + + private string + m_strMessage; + private bool + m_bCancel; + internal bool + m_bSet = false; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The chat message associated with this PlayerTextEventArgs. + public PlayerTextEventArgs(string message) { + this.m_strMessage = message; + this.m_bCancel = false; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the chat message. + /// + public string Message { + get { + return this.m_strMessage; + } + } + + /// + /// Gets or sets whether the event should cancel (chat message displayed). + /// + public bool Cancel { + get { + return this.m_bCancel; + } set { + this.m_bCancel = value; + this.m_bSet = true; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Player/PlayerUpdateEventArgs.cs b/sampdotnet/API/EventData/Player/PlayerUpdateEventArgs.cs new file mode 100644 index 0000000..7a5e1ea --- /dev/null +++ b/sampdotnet/API/EventData/Player/PlayerUpdateEventArgs.cs @@ -0,0 +1,27 @@ +using System; + +namespace SAMP.API.EventData { + public class PlayerUpdateEventArgs : EventArgs { + #region Class Variables + + private bool + m_bCancel; + + #endregion + + #region Accessors & Mutators + + /// + /// Gets or sets whether the event should cancel. + /// + public bool Cancel { + get { + return this.m_bCancel; + } set { + this.m_bCancel = value; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/RconCommandEventArgs.cs b/sampdotnet/API/EventData/RconCommandEventArgs.cs new file mode 100644 index 0000000..3b70093 --- /dev/null +++ b/sampdotnet/API/EventData/RconCommandEventArgs.cs @@ -0,0 +1,50 @@ +using System; + +namespace SAMP.API.EventData { + public class RconCommandEventArgs : EventArgs { + #region Class Variables + + private string + m_strCommand; + private bool + m_bHandled; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The command entered. + public RconCommandEventArgs(string command) { + this.m_strCommand = command; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the chat message associated with this event. + /// + public string Command { + get { + return this.m_strCommand; + } + } + + /// + /// Gets or sets whether the event was handled. Returning TRUE will prevent the command being passed to other scripts. + /// + public bool Handled { + get { + return this.m_bHandled; + } set { + this.m_bHandled = value; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/RconLoginAttemptEventArgs.cs b/sampdotnet/API/EventData/RconLoginAttemptEventArgs.cs new file mode 100644 index 0000000..1598ef0 --- /dev/null +++ b/sampdotnet/API/EventData/RconLoginAttemptEventArgs.cs @@ -0,0 +1,62 @@ +using System; + +namespace SAMP.API.EventData { + public class RconLoginAttemptEventArgs : EventArgs { + #region Class Variables + + private string + m_strIp, + m_strPassword; + private bool + m_bSuccess; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The IP of the player that tried to login to RCON. + /// The password used to login with. + /// False if the password was incorrect or True if it was correct. + public RconLoginAttemptEventArgs(string ip, string password, bool success) { + this.m_strIp = ip; + this.m_strPassword = password; + this.m_bSuccess = success; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the IP of the player that tried to login to RCON. + /// + public string IP { + get { + return this.m_strIp; + } + } + + /// + /// Gets the password used to login with. + /// + public string Password { + get { + return this.m_strPassword; + } + } + + /// + /// Gets whether or not the password was correct. + /// + public bool Success { + get { + return this.m_bSuccess; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Vehicle/VehicleDeathEventArgs.cs b/sampdotnet/API/EventData/Vehicle/VehicleDeathEventArgs.cs new file mode 100644 index 0000000..d19db27 --- /dev/null +++ b/sampdotnet/API/EventData/Vehicle/VehicleDeathEventArgs.cs @@ -0,0 +1,37 @@ +using System; + +namespace SAMP.API.EventData { + public class VehicleDeathEventArgs : EventArgs { + #region Class Variables + + private Player + m_qKiller; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The player who destroyed the vehicle. + public VehicleDeathEventArgs(Player killer) { + this.m_qKiller = killer; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the player who destroyed the vehicle. + /// + public Player Killer { + get { + return this.m_qKiller; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/EventData/Vehicle/VehicleStreamEventArgs.cs b/sampdotnet/API/EventData/Vehicle/VehicleStreamEventArgs.cs new file mode 100644 index 0000000..5c77611 --- /dev/null +++ b/sampdotnet/API/EventData/Vehicle/VehicleStreamEventArgs.cs @@ -0,0 +1,37 @@ +using System; + +namespace SAMP.API.EventData { + public class VehicleStreamEventArgs : EventArgs { + #region Class Variables + + private Player + m_qPlayer; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// The player who the vehicle streamed in or out for. + public VehicleStreamEventArgs(Player forplayer) { + this.m_qPlayer = forplayer; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the player who the vehicle streamed in or out for. + /// + public Player ForPlayer { + get { + return this.m_qPlayer; + } + } + + #endregion + }; +}; diff --git a/sampdotnet/API/Util/Color.cs b/sampdotnet/API/Util/Color.cs new file mode 100644 index 0000000..1d70a7f --- /dev/null +++ b/sampdotnet/API/Util/Color.cs @@ -0,0 +1,795 @@ +using System; + +namespace SAMP.API { + public struct Color { + #region Struct Variables + + private uint + m_u32Color; + + #endregion + + #region Constructors + + internal Color(uint argb) { + // Store into a variable + this.m_u32Color = argb; + } + + #endregion + + #region Static Methods + + /// + /// Returns a new instance of the struct from a 32-bit ARGB value. + /// + /// A value specifying the 32-bit ARGB value. + /// The structure that this method creates. + public static Color FromArgb(uint argb) { + // Return the created colour + return new Color(argb); + } + + /// + /// Creates a structure from the specified 8-bit color values + /// (red, green, and blue). The alpha value is implicitly 255 (fully opaque). + /// Although this method allows a 32-bit value to be passed for each color component, + /// the value of each component is limited to 8 bits. + /// + /// The red component. Valid values are 0 through 255. + /// The green component. Valid values are 0 through 255. + /// The blue component. Valid values are 0 through 255. + /// The structure that this method creates. + public static Color FromArgb(int red, int green, int blue) { + // Return the created colour + return FromArgb(255, red, green, blue); + } + + /// + /// Creates a structure from the specified 8-bit color values + /// (red, green, and blue). The alpha value is implicitly 255 (fully opaque). + /// Although this method allows a 32-bit value to be passed for each color component, + /// the value of each component is limited to 8 bits. + /// + /// The alpha component. Valid values are 0 through 255. + /// The red component. Valid values are 0 through 255. + /// The green component. Valid values are 0 through 255. + /// The blue component. Valid values are 0 through 255. + /// The structure that this method creates. + public static Color FromArgb(int alpha, int red, int green, int blue) { + // Convert the passed parameters to a HTML colour + string html = ArgbToHex(red, green, blue, alpha); + + // Convert the HTML colour to ARGB decimal notation + uint argb = Convert.ToUInt32(html, 16); + + // Return the created colour + return new Color(argb); + } + + /// + /// Creates a structure from the specified Html color value (hexadecimal notation). + /// + /// A value specifying the Html color notation. + /// The structure that this method creates. + public static Color FromHtml(string htmlColor) { + // Truncate the HTML colour prefix ("0x" or "#") if necessary + if(htmlColor.StartsWith("0x")) + htmlColor = htmlColor.Substring(2); + else if(htmlColor.StartsWith("#")) + htmlColor = htmlColor.Substring(1); + + // Determine if the HTML has the correct length + if(htmlColor.Length.Equals(6)) + // Append an alpha value + htmlColor = string.Format("{0}FF", htmlColor.ToUpper()); + else if(htmlColor.Length.Equals(3)) { + // Elongate shorthand HTML + string + r = htmlColor.Substring(0, 1), + g = htmlColor.Substring(1, 1), + b = htmlColor.Substring(2, 1); + + htmlColor = string.Format("{0}{0}{1}{1}{2}{2}FF", r, g, b); + } + + // Convert the HTML colour to an ARGB decimal notation + uint argb = Convert.ToUInt32(htmlColor, 16); + + // Return the created colour + return new Color(argb); + } + + #endregion + + #region Internal Methods + + internal static string ArgbToHex(int r, int g, int b) { + return ArgbToHex(r, g, b, 255); + } + + internal static string ArgbToHex(int r, int g, int b, int a) { + string + hr = r.ToString("X"), + hg = g.ToString("X"), + hb = b.ToString("X"), + ha = a.ToString ("X"); + + if(hr.Length < 2) + hr = string.Format("0{0}", hr); + if(hg.Length < 2) + hg = string.Format("0{0}", hg); + if(hb.Length < 2) + hb = string.Format("0{0}", hb); + if(ha.Length < 2) + ha = string.Format("0{0}", ha); + + return string.Format("{0}{1}{2}{3}", hr, hg, hb, ha); + } + + #endregion + + #region Public Methods + + /// + /// Translates the specified instance to an HTML string color representation. + /// + /// Whether or not to include the alpha channel. + /// Returns the that represents the HTML color. + public string ToHtml(bool alpha) { + // Convert the Argb to a hexadecimal value + string html = m_u32Color.ToString("X"); + + // Truncate to 6 characters if we want to omit the alpha channel + if(!alpha) + html = html.Substring(0, 6); + + // Return the HTML color representatio. + return html; + } + + /// + /// Gets the 32-bit ARGB value of this instance. + /// + /// Returns the 32-bit ARGB value of this . + public uint ToArgb() { + // Return the Argb value + return m_u32Color; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the Red value of this Color. + /// + public byte R { + get { + string hex = m_u32Color.ToString("X"); + string val = hex.Substring(0, 2); + return Convert.ToByte(val, 16); + } + } + + /// + /// Gets the Green value of this Color. + /// + public byte G { + get { + string hex = m_u32Color.ToString("X"); + string val = hex.Substring(2, 2); + return Convert.ToByte(val, 16); + } + } + + /// + /// Gets the Blue value of this Color. + /// + public byte B { + get { + string hex = m_u32Color.ToString("X"); + string val = hex.Substring(4, 2); + return Convert.ToByte(val, 16); + } + } + + /// + /// Gets the Alpha value of this Color. + /// + public byte A { + get { + string hex = m_u32Color.ToString("X"); + string val = hex.Substring(6, 2); + return Convert.ToByte(val, 16); + } + } + + #endregion + + #region Defined Colour Values + + /// + /// Gets a system-defined color that has an ARGB value of #FFF0F8FF. + /// + public static Color AliceBlue { get { return FromHtml ("F0F8FF"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFAEBD7. + /// + public static Color AntiqueWhite { get { return FromHtml ("FAEBD7"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF00FFFF. + /// + public static Color Aqua { get { return FromHtml ("00FFFF"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF7FFFD4. + /// + public static Color Aquamarine { get { return FromHtml ("7FFFD4"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFF0FFFF. + /// + public static Color Azure { get { return FromHtml ("F0FFFF"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFF5F5DC. + /// + public static Color Beige { get { return FromHtml ("F5F5DC"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFE4C4. + /// + public static Color Bisque { get { return FromHtml ("FFE4C4"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF000000. + /// + public static Color Black { get { return FromHtml ("000000"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFEBCD. + /// + public static Color BlanchedAlmond { get { return FromHtml ("FFEBCD"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF0000FF. + /// + public static Color Blue { get { return FromHtml ("0000FF"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF8A2BE2. + /// + public static Color BlueViolet { get { return FromHtml ("8A2BE2"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFA52A2A. + /// + public static Color Brown { get { return FromHtml ("A52A2A"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFDEB887. + /// + public static Color BurlyWood { get { return FromHtml ("DEB887"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF5F9EA0. + /// + public static Color CadetBlue { get { return FromHtml ("5F9EA0"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF7FFF00. + /// + public static Color Chartreuse { get { return FromHtml ("7FFF00"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFD2691E. + /// + public static Color Chocolate { get { return FromHtml ("D2691E"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFF7F50. + /// + public static Color Coral { get { return FromHtml ("FF7F50"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF6495ED. + /// + public static Color CornflowerBlue { get { return FromHtml ("6495ED"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFF8DC. + /// + public static Color Cornsilk { get { return FromHtml ("FFF8DC"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFDC143C. + /// + public static Color Crimson { get { return FromHtml ("DC143C"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF00FFFF. + /// + public static Color Cyan { get { return FromHtml ("00FFFF"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF00008B. + /// + public static Color DarkBlue { get { return FromHtml ("00008B"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF008B8B. + /// + public static Color DarkCyan { get { return FromHtml ("008B8B"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFB8860B. + /// + public static Color DarkGoldenrod { get { return FromHtml ("B8860B"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFA9A9A9. + /// + public static Color DarkGray { get { return FromHtml ("A9A9A9"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF006400. + /// + public static Color DarkGreen { get { return FromHtml ("006400"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFBDB76B. + /// + public static Color DarkKhaki { get { return FromHtml ("BDB76B"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF8B008B. + /// + public static Color DarkMagenta { get { return FromHtml ("8B008B"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF556B2F. + /// + public static Color DarkOliveGreen { get { return FromHtml ("556B2F"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFF8C00. + /// + public static Color DarkOrange { get { return FromHtml ("FF8C00"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF9932CC. + /// + public static Color DarkOrchid { get { return FromHtml ("9932CC"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF8B0000. + /// + public static Color DarkRed { get { return FromHtml ("8B0000"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFE9967A. + /// + public static Color DarkSalmon { get { return FromHtml ("E9967A"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF8FBC8F. + /// + public static Color DarkSeaGreen { get { return FromHtml ("8FBC8F"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF483D8B. + /// + public static Color DarkSlateBlue { get { return FromHtml ("483D8B"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF2F4F4F. + /// + public static Color DarkSlateGray { get { return FromHtml ("2F4F4F"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF00CED1. + /// + public static Color DarkTurquoise { get { return FromHtml ("00CED1"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF9400D3. + /// + public static Color DarkViolet { get { return FromHtml ("9400D3"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFF1493. + /// + public static Color DeepPink { get { return FromHtml ("FF1493"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF00BFFF. + /// + public static Color DeepSkyBlue { get { return FromHtml ("00BFFF"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF696969. + /// + public static Color DimGray { get { return FromHtml ("696969"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF1E90FF. + /// + public static Color DodgerBlue { get { return FromHtml ("1E90FF"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFB22222. + /// + public static Color Firebrick { get { return FromHtml ("B22222"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFFAF0. + /// + public static Color FloralWhite { get { return FromHtml ("FFFAF0"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF228B22. + /// + public static Color ForestGreen { get { return FromHtml ("228B22"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFF00FF. + /// + public static Color Fuchsia { get { return FromHtml ("FF00FF"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFDCDCDC. + /// + public static Color Gainsboro { get { return FromHtml ("DCDCDC"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFF8F8FF. + /// + public static Color GhostWhite { get { return FromHtml ("F8F8FF"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFD700. + /// + public static Color Gold { get { return FromHtml ("FFD700"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFDAA520. + /// + public static Color Goldenrod { get { return FromHtml ("DAA520"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF808080. + /// + public static Color Gray { get { return FromHtml ("808080"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF008000. + /// + public static Color Green { get { return FromHtml ("008000"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFADFF2F. + /// + public static Color GreenYellow { get { return FromHtml ("ADFF2F"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFF0FFF0. + /// + public static Color Honeydew { get { return FromHtml ("F0FFF0"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFF69B4. + /// + public static Color HotPink { get { return FromHtml ("FF69B4"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFCD5C5C. + /// + public static Color IndianRed { get { return FromHtml ("CD5C5C"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF4B0082. + /// + public static Color Indigo { get { return FromHtml ("4B0082"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFFFF0. + /// + public static Color Ivory { get { return FromHtml ("FFFFF0"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFF0E68C. + /// + public static Color Khaki { get { return FromHtml ("F0E68C"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFE6E6FA. + /// + public static Color Lavender { get { return FromHtml ("E6E6FA"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFF0F5. + /// + public static Color LavenderBlush { get { return FromHtml ("FFF0F5"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF7CFC00. + /// + public static Color LawnGreen { get { return FromHtml ("7CFC00"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFFACD. + /// + public static Color LemonChiffon { get { return FromHtml ("FFFACD"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFADD8E6. + /// + public static Color LightBlue { get { return FromHtml ("ADD8E6"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFF08080. + /// + public static Color LightCoral { get { return FromHtml ("F08080"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFE0FFFF. + /// + public static Color LightCyan { get { return FromHtml ("E0FFFF"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFAFAD2. + /// + public static Color LightGoldenrodYellow { get { return FromHtml ("FAFAD2"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFD3D3D3. + /// + public static Color LightGray { get { return FromHtml ("D3D3D3"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF90EE90. + /// + public static Color LightGreen { get { return FromHtml ("90EE90"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFB6C1. + /// + public static Color LightPink { get { return FromHtml ("FFB6C1"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFA07A. + /// + public static Color LightSalmon { get { return FromHtml ("FFA07A"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF20B2AA. + /// + public static Color LightSeaGreen { get { return FromHtml ("20B2AA"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF87CEFA. + /// + public static Color LightSkyBlue { get { return FromHtml ("87CEFA"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF778899. + /// + public static Color LightSlateGray { get { return FromHtml ("778899"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFB0C4DE. + /// + public static Color LightSteelBlue { get { return FromHtml ("B0C4DE"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFFFE0. + /// + public static Color LightYellow { get { return FromHtml ("FFFFE0"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF00FF00. + /// + public static Color Lime { get { return FromHtml ("00FF00"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF32CD32. + /// + public static Color LimeGreen { get { return FromHtml ("32CD32"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFAF0E6. + /// + public static Color Linen { get { return FromHtml ("FAF0E6"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFF00FF. + /// + public static Color Magenta { get { return FromHtml ("FF00FF"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF800000. + /// + public static Color Maroon { get { return FromHtml ("800000"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF66CDAA. + /// + public static Color MediumAquamarine { get { return FromHtml ("66CDAA"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF0000CD. + /// + public static Color MediumBlue { get { return FromHtml ("0000CD"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFBA55D3. + /// + public static Color MediumOrchid { get { return FromHtml ("BA55D3"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF9370DB. + /// + public static Color MediumPurple { get { return FromHtml ("9370DB"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF3CB371. + /// + public static Color MediumSeaGreen { get { return FromHtml ("3CB371"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF7B68EE. + /// + public static Color MediumSlateBlue { get { return FromHtml ("7B68EE"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF00FA9A. + /// + public static Color MediumSpringGreen { get { return FromHtml ("00FA9A"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF48D1CC. + /// + public static Color MediumTurquoise { get { return FromHtml ("48D1CC"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFC71585. + /// + public static Color MediumVioletRed { get { return FromHtml ("C71585"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF191970. + /// + public static Color MidnightBlue { get { return FromHtml ("191970"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFF5FFFA. + /// + public static Color MintCream { get { return FromHtml ("F5FFFA"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFE4E1. + /// + public static Color MistyRose { get { return FromHtml ("FFE4E1"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFE4B5. + /// + public static Color Moccasin { get { return FromHtml ("FFE4B5"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFDEAD. + /// + public static Color NavajoWhite { get { return FromHtml ("FFDEAD"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF000080. + /// + public static Color Navy { get { return FromHtml ("000080"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFDF5E6. + /// + public static Color OldLace { get { return FromHtml ("FDF5E6"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF808000. + /// + public static Color Olive { get { return FromHtml ("808000"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF6B8E23. + /// + public static Color OliveDrab { get { return FromHtml ("6B8E23"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFA500. + /// + public static Color Orange { get { return FromHtml ("FFA500"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFF4500. + /// + public static Color OrangeRed { get { return FromHtml ("FF4500"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFDA70D6. + /// + public static Color Orchid { get { return FromHtml ("DA70D6"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFEEE8AA. + /// + public static Color PaleGoldenrod { get { return FromHtml ("EEE8AA"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF98FB98. + /// + public static Color PaleGreen { get { return FromHtml ("98FB98"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFAFEEEE. + /// + public static Color PaleTurquoise { get { return FromHtml ("AFEEEE"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFDB7093. + /// + public static Color PaleVioletRed { get { return FromHtml ("DB7093"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFEFD5. + /// + public static Color PapayaWhip { get { return FromHtml ("FFEFD5"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFDAB9. + /// + public static Color PeachPuff { get { return FromHtml ("FFDAB9"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFCD853F. + /// + public static Color Peru { get { return FromHtml ("CD853F"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFC0CB. + /// + public static Color Pink { get { return FromHtml ("FFC0CB"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFDDA0DD. + /// + public static Color Plum { get { return FromHtml ("DDA0DD"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFB0E0E6. + /// + public static Color PowderBlue { get { return FromHtml ("B0E0E6"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF800080. + /// + public static Color Purple { get { return FromHtml ("800080"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFF0000. + /// + public static Color Red { get { return FromHtml ("FF0000"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFBC8F8F. + /// + public static Color RosyBrown { get { return FromHtml ("BC8F8F"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF4169E1. + /// + public static Color RoyalBlue { get { return FromHtml ("4169E1"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF8B4513. + /// + public static Color SaddleBrown { get { return FromHtml ("8B4513"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFA8072. + /// + public static Color Salmon { get { return FromHtml ("FA8072"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFF4A460. + /// + public static Color SandyBrown { get { return FromHtml ("F4A460"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF2E8B57. + /// + public static Color SeaGreen { get { return FromHtml ("2E8B57"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFF5EE. + /// + public static Color SeaShell { get { return FromHtml ("FFF5EE"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFA0522D. + /// + public static Color Sienna { get { return FromHtml ("A0522D"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFC0C0C0. + /// + public static Color Silver { get { return FromHtml ("C0C0C0"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF87CEEB. + /// + public static Color SkyBlue { get { return FromHtml ("87CEEB"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF6A5ACD. + /// + public static Color SlateBlue { get { return FromHtml ("6A5ACD"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF708090. + /// + public static Color SlateGray { get { return FromHtml ("708090"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFFAFA. + /// + public static Color Snow { get { return FromHtml ("FFFAFA"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF00FF7F. + /// + public static Color SpringGreen { get { return FromHtml ("00FF7F"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF4682B4. + /// + public static Color SteelBlue { get { return FromHtml ("4682B4"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFD2B48C. + /// + public static Color Tan { get { return FromHtml ("D2B48C"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF008080. + /// + public static Color Teal { get { return FromHtml ("008080"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFD8BFD8. + /// + public static Color Thistle { get { return FromHtml ("D8BFD8"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFF6347. + /// + public static Color Tomato { get { return FromHtml ("FF6347"); } } + /// + /// Gets a system-defined color that has an ARGB value of #00000000. + /// + public static Color Transparent { get { return FromArgb (0, 0, 0, 0); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF40E0D0. + /// + public static Color Turquoise { get { return FromHtml ("40E0D0"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFEE82EE. + /// + public static Color Violet { get { return FromHtml ("EE82EE"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFF5DEB3. + /// + public static Color Wheat { get { return FromHtml ("F5DEB3"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFFFFF. + /// + public static Color White { get { return FromHtml ("FFFFFF"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFF5F5F5. + /// + public static Color WhiteSmoke { get { return FromHtml ("F5F5F5"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FFFFFF00. + /// + public static Color Yellow { get { return FromHtml ("FFFF00"); } } + /// + /// Gets a system-defined color that has an ARGB value of #FF9ACD32. + /// + public static Color YellowGreen { get { return FromHtml ("9ACD32"); } } + + #endregion + + #region Enums + + /// + /// Car colors. + /// + public enum CarColor : int + { + Salmon = 130, + Jade = 131, + PalePistachio = 132, + ElectricBlue = 142, + TurquoiseBlue = 144, + }; + + #endregion + }; +}; diff --git a/sampdotnet/API/Util/Server.cs b/sampdotnet/API/Util/Server.cs new file mode 100644 index 0000000..007da91 --- /dev/null +++ b/sampdotnet/API/Util/Server.cs @@ -0,0 +1,98 @@ +using System; +using System.Text; + +namespace SAMP.API { + public class Server { + #region Class Variables + + // Nothing to see here + + #endregion + + #region Events, Delegates and Method Calls + + #region OnRconCommand + public delegate void OnRconCommandHandler(object sender,EventData.RconCommandEventArgs e); + + /// + /// Occurs when an RCON command is received. + /// + public static event OnRconCommandHandler OnRconCommand; + + internal static int _OnRconCommand(string cmd) { + EventData.RconCommandEventArgs args = new EventData.RconCommandEventArgs(cmd); + if(OnRconCommand != null) + OnRconCommand(null, args); + return args.Handled ? 1 : 0; + } + #endregion + #region OnRconLoginAttempt + public delegate void OnRconLoginAttemptHandler(object sender,EventData.RconLoginAttemptEventArgs e); + + /// + /// Occurs when a play attempts to login to RCON. + /// + public static event OnRconLoginAttemptHandler OnRconLoginAttempt; + + internal static void _OnRconLoginAttempt(string ip, string password, int success) { + EventData.RconLoginAttemptEventArgs args = new EventData.RconLoginAttemptEventArgs(ip, password, success == 1); + if(OnRconLoginAttempt != null) + OnRconLoginAttempt(null, args); + args = null; + } + #endregion + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the number of currently connected players. + /// + public static int PlayerCount { + get { return Player.s_qStore.Count; } + } + + /// + /// Gets the maximum allowed players to connect. + /// + public static int MaxPlayers { + get { return Core.Natives.GetMaxPlayers(); } + } + + #endregion + + #region Public Methods + + /// + /// Sends an RCON command. + /// + /// The RCON command to be executed. + public static void Rcon(string command) { + Core.Natives.SendRconCommand(command); + } + + /// + /// Retrieve a server variable of the specified type. + /// + /// The name of the variable to retrieve. + /// The type of variable to search for and return. Valid types are , and . + /// Returns a variable of type T containing the value of the server variable with the name varname. + public static T Var(string varname) { + if (typeof(T).Equals(typeof(string))) { + StringBuilder sb = new StringBuilder (1024); + Core.Natives.GetServerVarAsString(varname, sb, sb.Capacity); + return (T)Convert.ChangeType (sb.ToString(), typeof(T)); + } else if (typeof(T).Equals(typeof(int))) { + int buffer = Core.Natives.GetServerVarAsInt(varname); + return (T)Convert.ChangeType (buffer, typeof(T)); + } else if (typeof(T).Equals(typeof(bool))) { + bool buffer = Core.Natives.GetServerVarAsInt(varname) == 1; + return (T)Convert.ChangeType(buffer, typeof(T)); + } else + return default(T); + } + + #endregion + }; +}; diff --git a/sampdotnet/API/Util/SpawnInfo.cs b/sampdotnet/API/Util/SpawnInfo.cs new file mode 100644 index 0000000..352260d --- /dev/null +++ b/sampdotnet/API/Util/SpawnInfo.cs @@ -0,0 +1,137 @@ + +namespace SAMP.API { + public class SpawnInfo { + #region Class Variables + + private Player + m_qPlayer; + private Skin + m_qSkin; + private Vector3 + m_qPos; + private int + m_iTeam, + m_iWeapon1, m_nWeapon1Ammo, + m_iWeapon2, m_nWeapon2Ammo, + m_iWeapon3, m_nWeapon3Ammo; + private float + m_fpAngle = 0.0f; + + #endregion + + #region Constructor + + internal SpawnInfo(Player sender) { + m_qPlayer = sender; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets or sets the spawn facing angle of the player. + /// + public float Angle { + get { + return this.m_fpAngle; + } set { + this.m_fpAngle = value; + } + } + + /// + /// Gets or sets the spawn position of the player. + /// + public Vector3 Position { + get { + return m_qPos; + } set { + m_qPos = value; + } + } + + /// + /// Gets or sets the skin of the player. + /// + public Skin Skin { + get { + return m_qSkin; + } set { + m_qSkin = value; + } + } + + /// + /// Gets or sets the team ID of the player. + /// + public int Team { + get { + return m_iTeam; + } set { + m_iTeam = value; + } + } + + /// + /// Gets or sets the primary spawn-weapon for the player. + /// + public int Weapon1 { + get { return m_iWeapon1; } + set { m_iWeapon1 = value; } + } + + /// + /// Gets or sets the amount of ammunition for the primary spawn-weapon. + /// + public int Weapon1Ammo { + get { return m_nWeapon1Ammo; } + set { m_nWeapon1Ammo = value; } + } + + /// + /// Gets or sets the secondary spawn-weapon for the player. + /// + public int Weapon2 { + get { return m_iWeapon2; } + set { m_iWeapon2 = value; } + } + + /// + /// Gets or sets the amount of ammunition for the secondary spawn-weapon. + /// + public int Weapon2Ammo { + get { return m_nWeapon2Ammo; } + set { m_nWeapon2Ammo = value; } + } + + /// + /// Gets or sets the third spawn-weapon for the player. + /// + public int Weapon3 { + get { return m_iWeapon3; } + set { m_iWeapon3 = value; } + } + + /// + /// Gets or sets the amount of ammunition for the third spawn-weapon. + /// + public int Weapon3Ammo { + get { return m_nWeapon3Ammo; } + set { m_nWeapon3Ammo = value; } + } + + #endregion + + #region Public Methods + + /// + /// Sends all buffered SpawnInfo to be updated. + /// + public void Flush() { + Core.Natives.SetSpawnInfo(m_qPlayer.ID, Team, (int)Skin, Position.X, Position.Y, Position.Z, Angle, Weapon1, Weapon1Ammo, Weapon2, Weapon2Ammo, Weapon3, Weapon3Ammo); + } + + #endregion + }; +}; diff --git a/sampdotnet/API/Util/Util.cs b/sampdotnet/API/Util/Util.cs new file mode 100644 index 0000000..98e543c --- /dev/null +++ b/sampdotnet/API/Util/Util.cs @@ -0,0 +1,62 @@ +using System; +using System.Text; + +namespace SAMP.API { + public class Util { + #region Accessors & Mutators + + /// + /// Gets a value indicating whether the current platform is Linux. + /// + public static bool IsLinux { + get { + int iPlatform = (int)Environment.OSVersion.Platform; + return (iPlatform == 4) || (iPlatform == 6) || (iPlatform == 128); + } + } + + /// + /// Gets a value indicating whether the current platform is Windows. + /// + public static bool IsWindows { + get { + return !IsLinux; + } + } + + /// + /// Gets the uptime of the actual server in milliseconds. (The machine, NOT the SA:MP server.) + /// + public static TimeSpan TickCount { + get { + return TimeSpan.FromMilliseconds(Core.Natives.GetTickCount()); + } + } + + #endregion + + #region Public Methods + + /// + /// Outputs a formatted string on the console (the server window, not the in-game chat). + /// + /// The format string. + /// Indefinite number of arguments of any tag. + public static void Log(string format, params object[] args) { + Core.Natives.logprintf(string.Format(format, args)); + } + + /// + /// Gets the name of a weapon. + /// + /// The Weapon ID you want to know the name of. + /// The weapon name. + public static string GetWeaponName(int weaponid) { + StringBuilder pstrWeaponName = new StringBuilder(50); + Core.Natives.GetWeaponName(weaponid, pstrWeaponName, pstrWeaponName.Capacity); + return pstrWeaponName.ToString(); + } + + #endregion + }; +}; diff --git a/sampdotnet/API/Util/Vector2.cs b/sampdotnet/API/Util/Vector2.cs new file mode 100644 index 0000000..8716700 --- /dev/null +++ b/sampdotnet/API/Util/Vector2.cs @@ -0,0 +1,186 @@ +using System; + +namespace SAMP.API { + public struct Vector2 { + #region Struct Variables + + private float + m_fpX, + m_fpY; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the struct. + /// + /// X position. + /// Y position. + public Vector2(float x, float y) { + this.m_fpX = x; + this.m_fpY = y; + } + + /// + /// Initializes a new instance of the struct. + /// + /// Uniform position. + public Vector2(float v) { + this.m_fpX = v; + this.m_fpY = v; + } + + /// + /// Initializes a new instance of the struct. + /// + /// The to copy. + public Vector2(Vector2 v) { + this.m_fpX = v.X; + this.m_fpY = v.Y; + } + + /// + /// Initializes a new instance of the struct. + /// + /// The to copy. + public Vector2(Vector3 v) { + this.m_fpX = v.X; + this.m_fpY = v.Y; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the zero-pointed . + /// + public static Vector2 Zero { + get { + return new Vector2(0.0f, 0.0f); + } + } + + /// + /// Gets or sets the X position of this . + /// + public float X { + get { + return this.m_fpX; + } set { + this.m_fpX = value; + } + } + + /// + /// Gets or sets the Y position of this . + /// + public float Y { + get { + return this.m_fpY; + } set { + this.m_fpY = value; + } + } + + #endregion + + #region Operator Overloads + + /// + /// Adds a to a , yielding a new . + /// + /// The first to add. + /// The second to add. + /// The that is the sum of the values of v1 and v2. + public static Vector2 operator +(Vector2 v1, Vector2 v2) { + return new Vector2(v1.X + v2.X, v1.Y + v2.Y); + } + + /// + /// Subtracts a from a , yielding a new . + /// + /// The to subtract from (the minuend). + /// The to subtract (the subtrahend). + /// The that is the v1 minus v2. + public static Vector2 operator -(Vector2 v1, Vector2 v2) { + return new Vector2(v1.X + v2.X, v1.Y + v2.Y); + } + + /// + /// Computes the product of v1 and v2, yielding a new . + /// + /// The to multiply. + /// The to multiply. + /// The that is the v1 * v2. + public static Vector2 operator *(Vector2 v1, Vector2 v2) { + return new Vector2(v1.X * v2.X, v1.Y * v2.Y); + } + + /// + /// Computes the division of v1 and v2, yielding a new . + /// + /// The to divide (the divident)./param> + /// The to divide (the divisor). + /// The that is the v1 / v2. + public static Vector2 operator /(Vector2 v1, Vector2 v2) { + return new Vector2(v1.X / v2.X, v1.Y / v2.Y); + } + + #endregion + + #region Method Overrides + + /// + /// Returns a that represents the current . + /// + /// A that represents the current . + public override string ToString() { + return string.Format("{{X: {0}, Y: {1}}}", this.X, this.Y); + } + + #endregion + + #region Static Methods + + /// + /// Calculates the distance between two objects. + /// + /// The base term. + /// The factor term. + /// Returns a representing the distance between v1 and v2. + public static double Distance(Vector2 v1, Vector2 v2) { + return Math.Sqrt( + Math.Pow((double)v1.X - (double)v2.X, 2) + + Math.Pow((double)v1.Y - (double)v2.Y, 2)); + } + + /// + /// Calculates the dot product of two vectors. + /// + /// The base term. + /// The factor term. + /// Returns a representing the dot product of v1 and v2. + public static Vector2 Dot(Vector2 v1, Vector2 v2) { + return new Vector2( + x: v1.X * v2.X, + y: v1.Y * v2.Y); + } + + #endregion + + #region Public Methods + + /// + /// Calculates the distance between the current and another. + /// + /// The term. + /// Returns a representing the distance between v and the current . + public double Distance(Vector2 v) { + return Vector2.Distance(this, v); + } + + #endregion + }; +}; diff --git a/sampdotnet/API/Util/Vector3.cs b/sampdotnet/API/Util/Vector3.cs new file mode 100644 index 0000000..2821642 --- /dev/null +++ b/sampdotnet/API/Util/Vector3.cs @@ -0,0 +1,205 @@ +using System; + +namespace SAMP.API { + public struct Vector3 { + #region Struct Variables + + private float + m_fpX, + m_fpY, + m_fpZ; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the struct. + /// + /// X position. + /// Y position. + /// Z position. + public Vector3(float x, float y, float z) { + this.m_fpX = x; + this.m_fpY = y; + this.m_fpZ = z; + } + + /// + /// Initializes a new instance of the struct. + /// + /// Uniform position. + public Vector3(float v) { + this.m_fpX = v; + this.m_fpY = v; + this.m_fpZ = v; + } + + /// + /// Initializes a new instance of the struct. + /// + /// The to copy. + public Vector3(Vector2 v) { + this.m_fpX = v.X; + this.m_fpY = v.Y; + this.m_fpZ = 0f; + } + + /// + /// Initializes a new instance of the struct. + /// + /// The to copy. + public Vector3(Vector3 v) { + this.m_fpX = v.X; + this.m_fpY = v.Y; + this.m_fpZ = v.Z; + } + + #endregion + + #region Accessors & Mutators + + /// + /// Gets the zero-pointed . + /// + public static Vector3 Zero { + get { + return new Vector3(0.0f, 0.0f, 0.0f); + } + } + + /// + /// Gets or sets the X position of this . + /// + public float X { + get { + return this.m_fpX; + } set { + this.m_fpX = value; + } + } + + /// + /// Gets or sets the Y position of this . + /// + public float Y { + get { + return this.m_fpY; + } set { + this.m_fpY = value; + } + } + + /// + /// Gets or sets the Z position of this . + /// + public float Z { + get { + return this.m_fpZ; + } set { + this.m_fpZ = value; + } + } + + #endregion + + #region Operator Overloads + + /// + /// Adds a to a , yielding a new . + /// + /// The first to add. + /// The second to add. + /// The that is the sum of the values of v1 and v2. + public static Vector3 operator +(Vector3 v1, Vector3 v2) { + return new Vector3(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z); + } + + /// + /// Subtracts a from a , yielding a new . + /// + /// The to subtract from (the minuend). + /// The to subtract (the subtrahend). + /// The that is the v1 minus v2. + public static Vector3 operator -(Vector3 v1, Vector3 v2) { + return new Vector3(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z); + } + + /// + /// Computes the product of v1 and v2, yielding a new . + /// + /// The to multiply. + /// The to multiply. + /// The that is the v1 * v2. + public static Vector3 operator *(Vector3 v1, Vector3 v2) { + return new Vector3(v1.X * v2.X, v1.Y * v2.Y, v1.Z * v2.Z); + } + + /// + /// Computes the division of v1 and v2, yielding a new . + /// + /// The to divide (the divident). + /// The to divide (the divisor). + /// The that is the v1 / v2. + public static Vector3 operator /(Vector3 v1, Vector3 v2) { + return new Vector3(v1.X / v2.X, v1.Y / v2.Y, v1.Z / v2.Z); + } + + #endregion + + #region Method Overrides + + /// + /// Returns a that represents the current . + /// + /// A that represents the current . + public override string ToString() { + return string.Format("({0}, {1}, {2})", this.X, this.Y, this.Z); + } + + #endregion + + #region Static Methods + + /// + /// Calculates the distance between two objects. + /// + /// The base term. + /// The factor term. + /// Returns a representing the distance between v1 and v2. + public static double Distance(Vector3 v1, Vector3 v2) { + return Math.Sqrt( + Math.Pow((double)v1.X - (double)v2.X, 2) + + Math.Pow((double)v1.Y - (double)v2.Y, 2) + + Math.Pow((double)v1.Z - (double)v2.Z, 2)); + } + + /// + /// Calculates the dot product of two objects. + /// + /// The base term. + /// he factor term./param> + /// Returns the dot product of v1 and v2. + public static Vector3 Dot(Vector3 v1, Vector3 v2) { + return new Vector3( + x: v1.X * v2.X, + y: v1.Y * v2.Y, + z: v1.Z * v2.Z); + } + + #endregion + + #region Public Methods + + /// + /// Calculates the distance between the current and another. + /// + /// The term. + /// Returns a representing the distance between v and the current . + public double Distance(Vector3 v) { + return Vector3.Distance(this, v); + } + + #endregion + }; +}; diff --git a/sampdotnet/Core/Exceptions.cs b/sampdotnet/Core/Exceptions.cs new file mode 100644 index 0000000..f8fac0c --- /dev/null +++ b/sampdotnet/Core/Exceptions.cs @@ -0,0 +1,8 @@ +using System; + +namespace SAMP.Core { + internal class Exceptions { + // API + public static Exception TextDrawDestroyed = new Exception("The TextDraw has been destroyed."); + }; +}; diff --git a/sampdotnet/Core/Interfaces/ICountable.cs b/sampdotnet/Core/Interfaces/ICountable.cs new file mode 100644 index 0000000..8045c6a --- /dev/null +++ b/sampdotnet/Core/Interfaces/ICountable.cs @@ -0,0 +1,6 @@ + +namespace SAMP.Core { + public interface ICountable { + int ID { get; } + }; +}; diff --git a/sampdotnet/Core/Interfaces/IScriptBase.cs b/sampdotnet/Core/Interfaces/IScriptBase.cs new file mode 100644 index 0000000..d1b5fa4 --- /dev/null +++ b/sampdotnet/Core/Interfaces/IScriptBase.cs @@ -0,0 +1,8 @@ + +namespace SAMP.Core { + public interface IScriptBase { + void Load(); + + void Unload(); + }; +}; diff --git a/sampdotnet/Core/Interfaces/IWorldEntity.cs b/sampdotnet/Core/Interfaces/IWorldEntity.cs new file mode 100644 index 0000000..6104be5 --- /dev/null +++ b/sampdotnet/Core/Interfaces/IWorldEntity.cs @@ -0,0 +1,6 @@ + +namespace SAMP.Core { + public interface IWorldEntity { + API.Vector3 Position { get; set; } + }; +}; diff --git a/sampdotnet/Core/Internal.cs b/sampdotnet/Core/Internal.cs new file mode 100644 index 0000000..0b56c31 --- /dev/null +++ b/sampdotnet/Core/Internal.cs @@ -0,0 +1,255 @@ +using System; +using System.Collections; +using System.Runtime.InteropServices; +using System.Text; +using SAMP.API; + +namespace SAMP.Core { + internal class Internal { + #region Class Variables + + public static int + s_nDialogCounter = 0; + public static Hashtable + s_qDialogResponses = new Hashtable(); + + #endregion + + #region C++ Callbacks + + public static void OnGameModeInit() { + GameMode._OnInit(); + } + + public static void OnGameModeExit() { + GameMode._OnExit(); + } + + public static void OnPlayerConnect(int playerid) { + // Instantiate the player + // This, in turn, adds itself to the collection + // Immediately call the OnConnect event. + new Player(playerid)._OnConnect(); + } + + public static void OnPlayerDisconnect(int playerid, int reason) { + Player.Get(playerid)._OnDisconnect(reason); + } + + public static int OnPlayerSpawn (int playerid) { + // Pre-define a variable for cancel + bool bCancel = false; + + // Call event + Player.Get(playerid)._OnSpawn(ref bCancel); + + // Return the cancel bool + return bCancel ? 0 : 1; + } + + public static void OnPlayerDeath(int playerid, int killerid, int reason) { + Player.Get(playerid)._OnDeath(Player.Get(killerid), reason); + } + + public static void OnVehicleSpawn(int vehicleid) { + Vehicle.Get(vehicleid)._OnSpawn(); + } + + public static void OnVehicleDeath(int vehicleid, int killerid) { + Vehicle.Get(vehicleid)._OnDeath(killerid); + } + + public static int OnPlayerText(int playerid, string text) { + return Player.Get(playerid)._OnText(text); + } + + public static int OnPlayerCommandText(int playerid, string cmdtext) { + // Pre-define a variable for cancel + bool bHandled = false; + + // Call event + Player.Get(playerid)._OnCommandText(cmdtext, ref bHandled); + + // Return the handled bool + return bHandled ? 1 : 0; + } + + public static int OnPlayerRequestClass(int playerid, int classid) { + // Pre-define a variable for cancel + bool cancel = false; + + // Call event + Player.Get(playerid)._OnRequestClass(classid, ref cancel); + + // Return the cancel bool + return cancel ? 0 : 1; + } + + public static void OnPlayerEnterVehicle(int playerid, int vehicleid, int ispassenger) { + Player.Get(playerid)._OnEnterVehicle(vehicleid, ispassenger == 1); + } + + public static void OnPlayerExitVehicle(int playerid, int vehicleid) { + Player.Get(playerid)._OnExitVehicle(vehicleid); + } + + public static void OnPlayerStateChange(int playerid, int newstate, int oldstate) { + Player.Get(playerid)._OnStateChange(newstate, oldstate); + } + + public static void OnPlayerEnterCheckpoint (int playerid) { + Player.Get(playerid)._OnEnterCheckpoint(); + } + + public static void OnPlayerLeaveCheckpoint(int playerid) { + Player.Get(playerid)._OnLeaveCheckpoint(); + } + + public static void OnPlayerEnterRaceCheckpoint(int playerid) { + Player.Get(playerid)._OnEnterRaceCheckpoint(); + } + + public static void OnPlayerLeaveRaceCheckpoint(int playerid) { + Player.Get(playerid)._OnLeaveRaceCheckpoint(); + } + + public static int OnRconCommand(string cmd) { + return Server._OnRconCommand(cmd); + } + + public static int OnPlayerRequestSpawn(int playerid) { + return Player.Get(playerid)._OnRequestSpawn(); + } + + public static void OnObjectMoved(int objectid) { + // TODO: Implement + } + public static void OnPlayerObjectMoved(int playerid, int objectid) { + // TODO: Implement + } + public static void OnPlayerPickUpPickup(int playerid, int pickupid) { + Player.Get(playerid)._OnPickUpPickup(pickupid); + } + + public static int OnVehicleMod(int playerid, int vehicleid, int componentid) { + // TODO: Implement + return 1; + } + public static void OnEnterExitModShop(int playerid, int enterexit, int interiorid) { + Player.Get(playerid)._OnEnterExitModShop(enterexit, interiorid); + } + + public static void OnVehiclePaintjob(int playerid, int vehicleid, int paintjobid) { + // TODO: Implement + } + + public static void OnVehicleRespray(int playerid, int vehicleid, int color1, int color2) { + // TODO: Implement + } + public static void OnVehicleDamageStatusUpdate(int vehicleid, int playerid) { + // TODO: Implement + } + + public static void OnUnoccupiedVehicleUpdate(int vehicleid, int playerid, int passenger_seat) { + // TODO: Implement + } + public static void OnPlayerSelectedMenuRow(int playerid, int row) { + // TODO: Implement + } + + public static void OnPlayerExitedMenu(int playerid) { + // TODO: Implement + } + + public static void OnPlayerInteriorChange(int playerid, int newinteriorid, int oldinteriorid) { + // TODO: Implement + } + + public static int OnPlayerKeyStateChange(int playerid, int newkeys, int oldkeys) { + // TODO: Implement + return 1; + } + + public static void OnRconLoginAttempt(string ip, string password, int success) { + Server._OnRconLoginAttempt(ip, password, success); + } + + public static int OnPlayerUpdate(int playerid) { + return Player.Get(playerid)._OnUpdate (); + } + + public static void OnPlayerStreamIn(int playerid, int forplayerid) { + Player.Get(playerid)._OnStreamIn(forplayerid); + } + + public static void OnPlayerStreamOut(int playerid, int forplayerid) { + Player.Get(playerid)._OnStreamOut(forplayerid); + } + + public static void OnVehicleStreamIn(int vehicleid, int forplayerid) { + Vehicle.Get(vehicleid)._OnStreamIn(forplayerid); + } + + public static void OnVehicleStreamOut(int vehicleid, int forplayerid) { + Vehicle.Get(vehicleid)._OnStreamOut(forplayerid); + } + + public static int OnDialogResponse(int playerid, int dialogid, int response, int listitem, string inputtext) { + // Pre-define a variable for pass-on + bool bPasson = false; + + // Call event + Player.Get(playerid)._OnDialogResponse(dialogid, response, listitem, inputtext, ref bPasson); + + // Return the pass-on int + return bPasson ? 0 : 1; + } + + public static void OnPlayerTakeDamage(int playerid, int issuerid, float amount, int weaponid) { + // TODO: Implement + } + + public static void OnPlayerGiveDamage(int playerid, int damagedid, float amount, int weaponid) { + // TODO: Implement + } + + public static void OnPlayerClickMap(int playerid, float fX, float fY, float fZ) { + Player.Get(playerid)._OnClickMap(fX, fY, fZ); + } + + public static int OnPlayerClickTextDraw (int playerid, int clickedid) { + // TODO: Implement + return 0; + } + + public static void OnPlayerClickPlayerTextDraw(int playerid, int playertextid) { + // TODO: Implement + } + + public static void OnPlayerClickPlayer(int playerid, int clickedplayerid, int source) { + // TODO: Implement + } + + public static void OnPlayerEditObject(int playerid, int playerobject, int objectid, int response, float fX, float fY, float fZ, float fRotX, float fRotY, float fRotZ) { + // TODO: Implement + } + + public static void OnPlayerEditAttachedObject(int playerid, int response, int index, int modelid, int boneid, float fOffsetX, float fOffsetY, float fOffsetZ, float fRotX, float fRotY, float fRotZ, float fScaleX, float fScaleY, float fScaleZ) { + // TODO: Implement + } + + public static void OnPlayerSelectObject(int playerid, int type, int objectid, int modelid, float fX, float fY, float fZ) { + // TODO: Implement + } + + #endregion + + public static string ByteArrayToString(byte[] arr) { + return Encoding.UTF8.GetString(arr); + } + + public static string IntPtrToString(IntPtr pointer) { + return Marshal.PtrToStringAuto(pointer); + } + }; +}; diff --git a/sampdotnet/Core/Natives.cs b/sampdotnet/Core/Natives.cs new file mode 100644 index 0000000..6c28b3e --- /dev/null +++ b/sampdotnet/Core/Natives.cs @@ -0,0 +1,689 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; + +namespace SAMP.Core { + internal class Natives { + [DllImport("__Internal", EntryPoint="_samp_logprintf")] + public static extern void logprintf(string message); + + // a_samp.inc + #region a_samp.inc + + // Util + [DllImport("__Internal", EntryPoint="_samp_SendClientMessage")] + public static extern void SendClientMessage(int playerid, uint color, string message); + [DllImport("__Internal", EntryPoint="_samp_SendClientMessageToAll")] + public static extern void SendClientMessageToAll(uint color, string message); + [DllImport("__Internal", EntryPoint="_samp_SendPlayerMessageToPlayer")] + public static extern void SendPlayerMessageToPlayer(int playerid, int senderid, string message); + [DllImport("__Internal", EntryPoint="_samp_SendPlayerMessageToAll")] + public static extern void SendPlayerMessageToAll(int senderid, string message); + [DllImport("__Internal", EntryPoint="_samp_SendDeathMessage")] + public static extern void SendDeathMessage(int killer, int killee, int weapon); + [DllImport("__Internal", EntryPoint="_samp_GameTextForAll")] + public static extern void GameTextForAll(string str, int time, int style); + [DllImport("__Internal", EntryPoint="_samp_GameTextForPlayer")] + public static extern void GameTextForPlayer(int playerid, string str, int time, int style); + [DllImport("__Internal", EntryPoint="_samp_GetTickCount")] + public static extern int GetTickCount(); + [DllImport("__Internal", EntryPoint="_samp_GetMaxPlayers")] + public static extern int GetMaxPlayers(); + + // Game + [DllImport("__Internal", EntryPoint="_samp_SetGameModeText")] + public static extern void SetGameModeText(string str); + [DllImport("__Internal", EntryPoint="_samp_SetTeamCount")] + public static extern void SetTeamCount(int count); // No effect + [DllImport("__Internal", EntryPoint="_samp_AddPlayerClass")] + public static extern int AddPlayerClass(int modelid, float spawn_x, float spawn_y, float spawn_z, float z_angle, int weapon1, int weapon1_ammo, int weapon2, int weapon2_ammo, int weapon3, int weapon3_ammo); + [DllImport("__Internal", EntryPoint="_samp_AddPlayerClassEx")] + public static extern int AddPlayerClassEx(int teamid, int modelid, float spawn_x, float spawn_y, float spawn_z, float z_angle, int weapon1, int weapon1_ammo, int weapon2, int weapon2_ammo, int weapon3, int weapon3_ammo); + [DllImport("__Internal", EntryPoint="_samp_AddStaticVehicle")] + public static extern int AddStaticVehicle(int modelid, float spawn_x, float spawn_y, float spawn_z, float z_angle, uint color1, uint color2); + [DllImport("__Internal", EntryPoint="_samp_AddStaticVehicleEx")] + public static extern int AddStaticVehicleEx(int modelid, float spawn_x, float spawn_y, float spawn_z, float z_angle, uint color1, uint color2, int respawn_delay); + [DllImport("__Internal", EntryPoint="_samp_AddStaticPickup")] + public static extern int AddStaticPickup(int model, int type, float x, float y, float z, int virtualworld=0); + [DllImport("__Internal", EntryPoint="_samp_CreatePickup")] + public static extern int CreatePickup(int model, int type, float x, float y, float z, int virtualworld=0); + [DllImport("__Internal", EntryPoint="_samp_DestroyPickup")] + public static extern void DestroyPickup(int pickup); + [DllImport("__Internal", EntryPoint="_samp_ShowNameTags")] + public static extern void ShowNameTags(int show); + [DllImport("__Internal", EntryPoint="_samp_ShowPlayerMarkers")] + public static extern void ShowPlayerMarkers(int mode); + [DllImport("__Internal", EntryPoint="_samp_GameModeExit")] + public static extern void GameModeExit(); + [DllImport("__Internal", EntryPoint="_samp_SetWorldTime")] + public static extern void SetWorldTime(int hour); + [DllImport("__Internal", EntryPoint="_samp_GetWeaponName")] + public static extern void GetWeaponName(int weaponid, StringBuilder weapon, int len); + [Obsolete("This function was removed in SA-MP 0.3. Tire popping is enabled by default.", false)] + [DllImport("__Internal", EntryPoint="_samp_EnableTirePopping")] + public static extern void EnableTirePopping(int enable); // Deprecated + [DllImport("__Internal", EntryPoint="_samp_AllowInteriorWeapons")] + public static extern void AllowInteriorWeapons(int allow); + [DllImport("__Internal", EntryPoint="_samp_SetWeather")] + public static extern void SetWeather(int weatherid); + [DllImport("__Internal", EntryPoint="_samp_SetGravity")] + public static extern void SetGravity(float gravity); + [Obsolete("This function is deprecated. Please see the SAMP.API.Player.OnClickMap event.", true)] + [DllImport("__Internal", EntryPoint="_samp_AllowAdminTeleport")] + public static extern void AllowAdminTeleport(int allow); // Deprecated + [Obsolete("This function is deprecated.", true)] + [DllImport("__Internal", EntryPoint="_samp_SetDeathDropAmount")] + public static extern void SetDeathDropAmount(int amount); // Deprecated + [DllImport("__Internal", EntryPoint="_samp_CreateExplosion")] + public static extern int CreateExplosion(float x, float y, float z, int type, float radius); + [DllImport("__Internal", EntryPoint="_samp_EnableZoneNames")] + public static extern void EnableZoneNames(int enable); + [DllImport("__Internal", EntryPoint="_samp_UsePlayerPedAnims")] + public static extern void UsePlayerPedAnims(); + [DllImport("__Internal", EntryPoint="_samp_DisableInteriorEnterExits")] + public static extern void DisableInteriorEnterExits(); + [DllImport("__Internal", EntryPoint="_samp_SetNameTagDrawDistance")] + public static extern void SetNameTagDrawDistance(float distance); + [DllImport("__Internal", EntryPoint="_samp_DisableNameTagLOS")] + public static extern void DisableNameTagLOS(); + [DllImport("__Internal", EntryPoint="_samp_LimitGlobalChatRadius")] + public static extern void LimitGlobalChatRadius(float chat_radius); + [DllImport("__Internal", EntryPoint="_samp_LimitPlayerMarkerRadius")] + public static extern void LimitPlayerMarkerRadius(float marker_radius); + + // Npc + // These functions are not yet implemented into the SAMP.NET library + [DllImport("__Internal", EntryPoint="_samp_ConnectNPC")] + public static extern void ConnectNPC(string name, string script); + [DllImport("__Internal", EntryPoint="_samp_IsPlayerNPC")] + public static extern int IsPlayerNPC(int playerid); + + // Admin + [DllImport("__Internal", EntryPoint="_samp_IsPlayerAdmin")] + public static extern int IsPlayerAdmin(int playerid); + [DllImport("__Internal", EntryPoint="_samp_Kick")] + public static extern void Kick(int playerid); + [DllImport("__Internal", EntryPoint="_samp_Ban")] + public static extern void Ban(int playerid); + [DllImport("__Internal", EntryPoint="_samp_BanEx")] + public static extern void BanEx(int playerid, string reason); + [DllImport("__Internal", EntryPoint="_samp_SendRconCommand")] + public static extern void SendRconCommand(string command); + [DllImport("__Internal", EntryPoint="_samp_GetServerVarAsString")] + public static extern void GetServerVarAsString(string varname, StringBuilder buffer, int len); + [DllImport("__Internal", EntryPoint="_samp_GetServerVarAsInt")] + public static extern int GetServerVarAsInt(string varname); + [DllImport("__Internal", EntryPoint="_samp_GetServerVarAsBool")] + public static extern int GetServerVarAsBool(string varname); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerNetworkStats")] + public static extern void GetPlayerNetworkStats(int playerid, StringBuilder retstr, int retstr_size); + [DllImport("__Internal", EntryPoint="_samp_GetNetworkStats")] + public static extern void GetNetworkStats(StringBuilder retstr, int retstr_size); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerVersion")] + public static extern int GetPlayerVersion(int playerid, StringBuilder version, int len); + + // Menu + [DllImport("__Internal", EntryPoint="_samp_CreateMenu")] + public static extern int CreateMenu(string title, int columns, float x, float y, float col1width, float col2width=0.0f); + [DllImport("__Internal", EntryPoint="_samp_DestroyMenu")] + public static extern int DestroyMenu(int menuid); + [DllImport("__Internal", EntryPoint="_samp_AddMenuItem")] + public static extern void AddMenuItem(int menuid, int column, string menutext); + [DllImport("__Internal", EntryPoint="_samp_SetMenuColumnHeader")] + public static extern void SetMenuColumnHeader(int menuid, int column, string columnheader); + [DllImport("__Internal", EntryPoint="_samp_ShowMenuForPlayer")] + public static extern void ShowMenuForPlayer(int menuid, int playerid); + [DllImport("__Internal", EntryPoint="_samp_HideMenuForPlayer")] + public static extern void HideMenuForPlayer(int menuid, int playerid); + [DllImport("__Internal", EntryPoint="_samp_IsValidMenu")] + public static extern int IsValidMenu(int menuid); + [DllImport("__Internal", EntryPoint="_samp_DisableMenu")] + public static extern void DisableMenu(int menuid); + [DllImport("__Internal", EntryPoint="_samp_DisableMenuRow")] + public static extern void DisableMenuRow(int menuid, int row); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerMenu")] + public static extern int GetPlayerMenu(int playerid); + + // Text Draw + [DllImport("__Internal", EntryPoint="_samp_TextDrawCreate")] + public static extern int TextDrawCreate(float x, float y, string text); + [DllImport("__Internal", EntryPoint="_samp_TextDrawDestroy")] + public static extern void TextDrawDestroy(int text); + [DllImport("__Internal", EntryPoint="_samp_TextDrawLetterSize")] + public static extern void TextDrawLetterSize(int text, float x, float y); + [DllImport("__Internal", EntryPoint="_samp_TextDrawTextSize")] + public static extern void TextDrawTextSize(int text, float x, float y); + [DllImport("__Internal", EntryPoint="_samp_TextDrawAlignment")] + public static extern void TextDrawAlignment(int text, int alignment); + [DllImport("__Internal", EntryPoint="_samp_TextDrawColor")] + public static extern void TextDrawColor(int text, uint color); + [DllImport("__Internal", EntryPoint="_samp_TextDrawUseBox")] + public static extern void TextDrawUseBox(int text, int use); + [DllImport("__Internal", EntryPoint="_samp_TextDrawBoxColor")] + public static extern void TextDrawBoxColor(int text, uint color); + [DllImport("__Internal", EntryPoint="_samp_TextDrawSetShadow")] + public static extern void TextDrawSetShadow(int text, int size); + [DllImport("__Internal", EntryPoint="_samp_TextDrawSetOutline")] + public static extern void TextDrawSetOutline(int text, int size); + [DllImport("__Internal", EntryPoint="_samp_TextDrawBackgroundColor")] + public static extern void TextDrawBackgroundColor(int text, uint color); + [DllImport("__Internal", EntryPoint="_samp_TextDrawFont")] + public static extern void TextDrawFont(int text, int font); + [DllImport("__Internal", EntryPoint="_samp_TextDrawSetProportional")] + public static extern void TextDrawSetProportional(int text, int set); + [DllImport("__Internal", EntryPoint="_samp_TextDrawSetSelectable")] + public static extern void TextDrawSetSelectable(int text, int set); + [DllImport("__Internal", EntryPoint="_samp_TextDrawShowForPlayer")] + public static extern void TextDrawShowForPlayer(int playerid, int text); + [DllImport("__Internal", EntryPoint="_samp_TextDrawHideForPlayer")] + public static extern void TextDrawHideForPlayer(int playerid, int text); + [DllImport("__Internal", EntryPoint="_samp_TextDrawShowForAll")] + public static extern void TextDrawShowForAll(int text); + [DllImport("__Internal", EntryPoint="_samp_TextDrawHideForAll")] + public static extern void TextDrawHideForAll(int text); + [DllImport("__Internal", EntryPoint="_samp_TextDrawSetString")] + public static extern void TextDrawSetString(int text, string str); + + // Gang Zones + [DllImport("__Internal", EntryPoint="_samp_GangZoneCreate")] + public static extern int GangZoneCreate(float minx, float miny, float maxx, float maxy); + [DllImport("__Internal", EntryPoint="_samp_GangZoneDestroy")] + public static extern void GangZoneDestroy(int zone); + [DllImport("__Internal", EntryPoint="_samp_GangZoneShowForPlayer")] + public static extern void GangZoneShowForPlayer(int playerid, int zone, uint color); + [DllImport("__Internal", EntryPoint="_samp_GangZoneShowForAll")] + public static extern int GangZoneShowForAll(int zone, uint color); + [DllImport("__Internal", EntryPoint="_samp_GangZoneHideForPlayer")] + public static extern void GangZoneHideForPlayer(int playerid, int zone); + [DllImport("__Internal", EntryPoint="_samp_GangZoneHideForAll")] + public static extern void GangZoneHideForAll(int zone); + [DllImport("__Internal", EntryPoint="_samp_GangZoneFlashForPlayer")] + public static extern void GangZoneFlashForPlayer(int playerid, int zone, uint flashcolor); + [DllImport("__Internal", EntryPoint="_samp_GangZoneFlashForAll")] + public static extern void GangZoneFlashForAll(int zone, uint flashcolor); + [DllImport("__Internal", EntryPoint="_samp_GangZoneStopFlashForPlayer")] + public static extern void GangZoneStopFlashForPlayer(int playerid, int zone); + [DllImport("__Internal", EntryPoint="_samp_GangZoneStopFlashForAll")] + public static extern void GangZoneStopFlashForAll(int zone); + + // Global 3D Text Labels + [DllImport("__Internal", EntryPoint="_samp_Create3DTextLabel")] + public static extern int Create3DTextLabel(string text, uint color, float x, float y, float z, float drawdistance, int virtualworld, int testlos=0); + [DllImport("__Internal", EntryPoint="_samp_Delete3DTextLabel")] + public static extern int Delete3DTextLabel(int id); + [DllImport("__Internal", EntryPoint="_samp_Attach3DTextLabelToPlayer")] + public static extern void Attach3DTextLabelToPlayer(int id, int playerid, float offsetx, float offsety, float offsetz); + [DllImport("__Internal", EntryPoint="_samp_Attach3DTextLabelToVehicle")] + public static extern void Attach3DTextLabelToVehicle(int id, int vehicleid, float offsetx, float offsety, float offsetz); + [DllImport("__Internal", EntryPoint="_samp_Update3DTextLabelText")] + public static extern void Update3DTextLabelText(int id, uint color, string text); + + // Per-player 3D Text Labels + [DllImport("__Internal", EntryPoint="_samp_CreatePlayer3DTextLabel")] + public static extern int CreatePlayer3DTextLabel(int playerid, string text, uint color, float x, float y, float z, float drawdistance, int attachedplayer=0xFFFF, int attachedvehicle=0xFFFF, int testlos=0); + [DllImport("__Internal", EntryPoint="_samp_DeletePlayer3DTextLabel")] + public static extern void DeletePlayer3DTextLabel(int playerid, int id); + [DllImport("__Internal", EntryPoint="_samp_UpdatePlayer3DTextLabelText")] + public static extern void UpdatePlayer3DTextLabelText(int playerid, int id, uint color, string text); + + // Player GUI Dialog + [DllImport("__Internal", EntryPoint="_samp_ShowPlayerDialog")] + public static extern void ShowPlayerDialog(int playerid, int dialogid, int style, string caption, string info, string button1, string button2); + #endregion + + // a_players.inc + #region a_players.inc + // Player + [DllImport("__Internal", EntryPoint="_samp_SetSpawnInfo")] + public static extern void SetSpawnInfo(int playerid, int team, int skin, float x, float y, float z, float rotation, int weapon1, int weapon1_ammo, int weapon2, int weapon2_ammo, int weapon3, int weapon3_ammo); + [DllImport("__Internal", EntryPoint="_samp_SpawnPlayer")] + public static extern void SpawnPlayer(int playerid); + + // Player info + [DllImport("__Internal", EntryPoint="_samp_SetPlayerPos")] + public static extern void SetPlayerPos(int playerid, float x, float y, float z); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerPosFindZ")] + public static extern void SetPlayerPosFindZ(int playerid, float x, float y, float z); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerPos")] + public static extern void GetPlayerPos(int playerid, ref float x, ref float y, ref float z); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerFacingAngle")] + public static extern void SetPlayerFacingAngle(int playerid, float ang); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerFacingAngle")] + public static extern void GetPlayerFacingAngle(int playerid, ref float ang); + //[DllImport("__Internal", EntryPoint="_samp_IsPlayerInRangeOfPoint")] + //public static extern void IsPlayerInRangeOfPoint(int playerid, float range, float x, float y, float z); + //[DllImport("__Internal", EntryPoint="_samp_GetPlayerDistanceFromPoint")] + //public static extern void GetPlayerDistanceFromPoint(int playerid, float x, float y, float z); + [DllImport("__Internal", EntryPoint="_samp_IsPlayerStreamedIn")] + public static extern int IsPlayerStreamedIn(int playerid, int forplayerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerInterior")] + public static extern void SetPlayerInterior(int playerid, int interiorid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerInterior")] + public static extern int GetPlayerInterior(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerHealth")] + public static extern void SetPlayerHealth(int playerid, float health); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerHealth")] + public static extern void GetPlayerHealth(int playerid, ref float health); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerArmour")] + public static extern void SetPlayerArmour(int playerid, float armour); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerArmour")] + public static extern void GetPlayerArmour(int playerid, ref float armour); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerAmmo")] + public static extern void SetPlayerAmmo(int playerid, int weaponslot, int ammo); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerAmmo")] + public static extern int GetPlayerAmmo(int playerid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerWeaponState")] + public static extern int GetPlayerWeaponState(int playerid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerTargetPlayer")] + public static extern int GetPlayerTargetPlayer(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerTeam")] + public static extern void SetPlayerTeam(int playerid, int teamid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerTeam")] + public static extern int GetPlayerTeam(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerScore")] + public static extern void SetPlayerScore(int playerid, int score); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerScore")] + public static extern int GetPlayerScore(int playerid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerDrunkLevel")] + public static extern int GetPlayerDrunkLevel(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerDrunkLevel")] + public static extern void SetPlayerDrunkLevel(int playerid, int level); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerColor")] + public static extern void SetPlayerColor(int playerid, uint color); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerColor")] + public static extern uint GetPlayerColor(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerSkin")] + public static extern void SetPlayerSkin(int playerid, int skinid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerSkin")] + public static extern int GetPlayerSkin(int playerid); + [DllImport("__Internal", EntryPoint="_samp_GivePlayerWeapon")] + public static extern void GivePlayerWeapon(int playerid, int weaponid, int ammo); + [DllImport("__Internal", EntryPoint="_samp_ResetPlayerWeapons")] + public static extern void ResetPlayerWeapons(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerArmedWeapon")] + public static extern void SetPlayerArmedWeapon(int playerid, int weaponid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerWeaponData")] + public static extern void GetPlayerWeaponData(int playerid, int slot, ref int weapons, ref int ammo); + [DllImport("__Internal", EntryPoint="_samp_GivePlayerMoney")] + public static extern void GivePlayerMoney(int playerid, int money); + [DllImport("__Internal", EntryPoint="_samp_ResetPlayerMoney")] + public static extern void ResetPlayerMoney(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerName")] + public static extern void SetPlayerName(int playerid, string name); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerMoney")] + public static extern int GetPlayerMoney(int playerid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerState")] + public static extern int GetPlayerState(int playerid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerIp")] + public static extern void GetPlayerIp(int playerid, StringBuilder name, int len); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerPing")] + public static extern int GetPlayerPing(int playerid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerWeapon")] + public static extern int GetPlayerWeapon(int playerid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerKeys")] + public static extern void GetPlayerKeys(int playerid, ref int keys, ref int updown, ref int leftright); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerName")] + public static extern void GetPlayerName(int playerid, StringBuilder name, int len); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerTime")] + public static extern void SetPlayerTime(int playerid, int hour, int minute); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerTime")] + public static extern void GetPlayerTime(int playerid, ref int hour, ref int minute); + [DllImport("__Internal", EntryPoint="_samp_TogglePlayerClock")] + public static extern void TogglePlayerClock(int playerid, int toggle); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerWeather")] + public static extern void SetPlayerWeather(int playerid, int weather); + [DllImport("__Internal", EntryPoint="_samp_ForceClassSelection")] + public static extern void ForceClassSelection(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerWantedLevel")] + public static extern void SetPlayerWantedLevel(int playerid, int level); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerWantedLevel")] + public static extern int GetPlayerWantedLevel(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerFightingStyle")] + public static extern void SetPlayerFightingStyle(int playerid, int style); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerFightingStyle")] + public static extern int GetPlayerFightingStyle(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerVelocity")] + public static extern void SetPlayerVelocity(int playerid, float x, float y, float z); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerVelocity")] + public static extern void GetPlayerVelocity(int playerid, ref float x, ref float y, ref float z); + [DllImport("__Internal", EntryPoint="_samp_PlayCrimeReportForPlayer")] + public static extern void PlayCrimeReportForPlayer(int playerid, int suspectid, int crime); + [DllImport("__Internal", EntryPoint="_samp_PlayAudioStreamForPlayer")] + public static extern void PlayAudioStreamForPlayer(int playerid, string url, float posx=0.0f, float posy=0.0f, float posz=0.0f, float distance=50.0f, int usepos=0); + [DllImport("__Internal", EntryPoint="_samp_StopAudioStreamForPlayer")] + public static extern void StopAudioStreamForPlayer(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerShopName")] + public static extern void SetPlayerShopName(int playerid, string shopname); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerSkillLevel")] + public static extern void SetPlayerSkillLevel(int playerid, int skill, int level); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerSurfingVehicleID")] + public static extern int GetPlayerSurfingVehicleID(int playerid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerSurfingObjectID")] + public static extern int GetPlayerSurfingObjectID(int playerid); + [DllImport("__Internal", EntryPoint="_samp_RemoveBuildingForPlayer")] + public static extern void RemoveBuildingForPlayer(int playerid, int modelid, float fx, float fy, float fz, float fradius); + + // Attached to bone objects + [DllImport("__Internal", EntryPoint="_samp_SetPlayerAttachedObject")] + public static extern void SetPlayerAttachedObject(int playerid, int index, int modelid, int bone, float foffsetx=0.0f, float foffsety=0.0f, float foffsetz=0.0f, float frotx=0.0f, float froty=0.0f, float frotz=0.0f, float fscalex=1.0f, float fscaley=1.0f, float fscalez=1.0f, int materialcolor1=0, int materialcolor2=0); + [DllImport("__Internal", EntryPoint="_samp_RemovePlayerAttachedObject")] + public static extern void RemovePlayerAttachedObject(int playerid, int index); + [DllImport("__Internal", EntryPoint="_samp_IsPlayerAttachedObjectSlotUsed")] + public static extern void IsPlayerAttachedObjectSlotUsed(int playerid, int index); + [DllImport("__Internal", EntryPoint="_samp_EditAttachedObject")] + public static extern void EditAttachedObject(int playerid, int index); + + // Per-player TextDraws + [DllImport("__Internal", EntryPoint="_samp_CreatePlayerTextDraw")] + public static extern int CreatePlayerTextDraw(int playerid, float x, float y, string text); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawDestroy")] + public static extern void PlayerTextDrawDestroy(int playerid, int text); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawLetterSize")] + public static extern void PlayerTextDrawLetterSize(int playerid, int text, float x, float y); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawTextSize")] + public static extern void PlayerTextDrawTextSize(int playerid, int text, float x, float y); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawAlignment")] + public static extern void PlayerTextDrawAlignment(int playerid, int text, int alignment); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawColor")] + public static extern void PlayerTextDrawColor(int playerid, int text, uint color); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawUseBox")] + public static extern void PlayerTextDrawUseBox(int playerid, int text, int use); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawBoxColor")] + public static extern void PlayerTextDrawBoxColor(int playerid, int text, uint color); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawSetShadow")] + public static extern void PlayerTextDrawSetShadow(int playerid, int text, int size); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawSetOutline")] + public static extern void PlayerTextDrawSetOutline(int playerid, int text, int size); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawBackgroundColor")] + public static extern void PlayerTextDrawBackgroundColor(int playerid, int text, uint color); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawFont")] + public static extern void PlayerTextDrawFont(int playerid, int text, int font); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawSetProportional")] + public static extern void PlayerTextDrawSetProportional(int playerid, int text, int set); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawSetSelectable")] + public static extern void PlayerTextDrawSetSelectable(int playerid, int text, int set); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawShow")] + public static extern void PlayerTextDrawShow(int playerid, int text); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawHide")] + public static extern void PlayerTextDrawHide(int playerid, int text); + [DllImport("__Internal", EntryPoint="_samp_PlayerTextDrawSetString")] + public static extern void PlayerTextDrawSetString(int playerid, int text, string str); + + // Per-player variable system(PVars) + [DllImport("__Internal", EntryPoint="_samp_SetPVarInt")] + public static extern void SetPVarInt(int playerid, string varname, int int_value); + [DllImport("__Internal", EntryPoint="_samp_GetPVarInt")] + public static extern int GetPVarInt(int playerid, string varname); + [DllImport("__Internal", EntryPoint="_samp_SetPVarString")] + public static extern void SetPVarString(int playerid, string varname, string string_value); + [DllImport("__Internal", EntryPoint="_samp_GetPVarString")] + public static extern void GetPVarString(int playerid, string varname, StringBuilder string_return, int len); + [DllImport("__Internal", EntryPoint="_samp_SetPVarFloat")] + public static extern void SetPVarFloat(int playerid, string varname, float float_value); + [DllImport("__Internal", EntryPoint="_samp_GetPVarFloat")] + public static extern float GetPVarFloat(int playerid, string varname); + [DllImport("__Internal", EntryPoint="_samp_DeletePVar")] + public static extern void DeletePVar(int playerid, string varname); + [DllImport("__Internal", EntryPoint="_samp_GetPVarsUpperIndex")] + public static extern int GetPVarsUpperIndex(int playerid); + [DllImport("__Internal", EntryPoint="_samp_GetPVarNameAtIndex")] + public static extern void GetPVarNameAtIndex(int playerid, int index, string ret_varname, int ret_len); + [DllImport("__Internal", EntryPoint="_samp_GetPVarType")] + public static extern void GetPVarType(int playerid, string varname); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerChatBubble")] + public static extern void SetPlayerChatBubble(int playerid, string text, uint color, float drawdistance, int expiretime); + [DllImport("__Internal", EntryPoint="_samp_PutPlayerInVehicle")] + public static extern void PutPlayerInVehicle(int playerid, int vehicleid, int seatid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerVehicleID")] + public static extern int GetPlayerVehicleID(int playerid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerVehicleSeat")] + public static extern int GetPlayerVehicleSeat(int playerid); + [DllImport("__Internal", EntryPoint="_samp_RemovePlayerFromVehicle")] + public static extern void RemovePlayerFromVehicle(int playerid); + [DllImport("__Internal", EntryPoint="_samp_TogglePlayerControllable")] + public static extern void TogglePlayerControllable(int playerid, int toggle); + [DllImport("__Internal", EntryPoint="_samp_PlayerPlaySound")] + public static extern void PlayerPlaySound(int playerid, int soundid, float x, float y, float z); + [DllImport("__Internal", EntryPoint="_samp_ApplyAnimation")] + public static extern void ApplyAnimation(int playerid, string animlib, string animname, float fdelta, int loop, int lockx, int locky, int freeze, int time, int forcesync=0); + [DllImport("__Internal", EntryPoint="_samp_ClearAnimations")] + public static extern void ClearAnimations(int playerid, int forcesync=0); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerAnimationIndex")] + public static extern int GetPlayerAnimationIndex(int playerid); + [DllImport("__Internal", EntryPoint="_samp_GetAnimationName")] + public static extern void GetAnimationName(int index, string animlib, int len1, string animname, int len2); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerSpecialAction")] + public static extern int GetPlayerSpecialAction(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerSpecialAction")] + public static extern void SetPlayerSpecialAction(int playerid, int actionid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerCheckpoint")] + public static extern void SetPlayerCheckpoint(int playerid, float x, float y, float z, float size); + [DllImport("__Internal", EntryPoint="_samp_DisablePlayerCheckpoint")] + public static extern void DisablePlayerCheckpoint(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerRaceCheckpoint")] + public static extern void SetPlayerRaceCheckpoint(int playerid, int type, float x, float y, float z, float nextx, float nexty, float nextz, float size); + [DllImport("__Internal", EntryPoint="_samp_DisablePlayerRaceCheckpoint")] + public static extern void DisablePlayerRaceCheckpoint(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerWorldBounds")] + public static extern void SetPlayerWorldBounds(int playerid, float x_max, float x_min, float y_max, float y_min); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerMarkerForPlayer")] + public static extern void SetPlayerMarkerForPlayer(int playerid, int showplayerid, uint color); + [DllImport("__Internal", EntryPoint="_samp_ShowPlayerNameTagForPlayer")] + public static extern void ShowPlayerNameTagForPlayer(int playerid, int showplayerid, int show); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerMapIcon")] + public static extern void SetPlayerMapIcon(int playerid, int iconid, float x, float y, float z, int markertype, uint color, int style=0); + [DllImport("__Internal", EntryPoint="_samp_RemovePlayerMapIcon")] + public static extern void RemovePlayerMapIcon(int playerid, int iconid); + [DllImport("__Internal", EntryPoint="_samp_AllowPlayerTeleport")] + public static extern void AllowPlayerTeleport(int playerid, int allow); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerCameraPos")] + public static extern void SetPlayerCameraPos(int playerid, float x, float y, float z); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerCameraLookAt")] + public static extern void SetPlayerCameraLookAt(int playerid, float x, float y, float z, int cut=2); + [DllImport("__Internal", EntryPoint="_samp_SetCameraBehindPlayer")] + public static extern void SetCameraBehindPlayer(int playerid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerCameraPos")] + public static extern void GetPlayerCameraPos(int playerid, ref float x, ref float y, ref float z); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerCameraFrontVector")] + public static extern void GetPlayerCameraFrontVector(int playerid, ref float x, ref float y, ref float z); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerCameraMode")] + public static extern int GetPlayerCameraMode(int playerid); + [DllImport("__Internal", EntryPoint="_samp_AttachCameraToObject")] + public static extern void AttachCameraToObject(int playerid, int objectid); + [DllImport("__Internal", EntryPoint="_samp_AttachCameraToPlayerObject")] + public static extern void AttachCameraToPlayerObject(int playerid, int playerobjectid); + [DllImport("__Internal", EntryPoint="_samp_InterpolateCameraPos")] + public static extern void InterpolateCameraPos(int playerid, float fromx, float fromy, float fromz, float tox, float toy, float toz, int time, int cut=2); + [DllImport("__Internal", EntryPoint="_samp_InterpolateCameraLookAt")] + public static extern void InterpolateCameraLookAt(int playerid, float fromx, float fromy, float fromz, float tox, float toy, float toz, int time, int cut=2); + [DllImport("__Internal", EntryPoint="_samp_IsPlayerConnected")] + public static extern int IsPlayerConnected(int playerid); + [DllImport("__Internal", EntryPoint="_samp_IsPlayerInVehicle")] + public static extern int IsPlayerInVehicle(int playerid, int vehicleid); + [DllImport("__Internal", EntryPoint="_samp_IsPlayerInAnyVehicle")] + public static extern int IsPlayerInAnyVehicle(int playerid); + [DllImport("__Internal", EntryPoint="_samp_IsPlayerInCheckpoint")] + public static extern int IsPlayerInCheckpoint(int playerid); + [DllImport("__Internal", EntryPoint="_samp_IsPlayerInRaceCheckpoint")] + public static extern int IsPlayerInRaceCheckpoint(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerVirtualWorld")] + public static extern void SetPlayerVirtualWorld(int playerid, int worldid); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerVirtualWorld")] + public static extern int GetPlayerVirtualWorld(int playerid); + [DllImport("__Internal", EntryPoint="_samp_EnableStuntBonusForPlayer")] + public static extern void EnableStuntBonusForPlayer(int playerid, int enable); + [DllImport("__Internal", EntryPoint="_samp_EnableStuntBonusForAll")] + public static extern void EnableStuntBonusForAll(int enable); + [DllImport("__Internal", EntryPoint="_samp_TogglePlayerSpectating")] + public static extern void TogglePlayerSpectating(int playerid, int toggle); + [DllImport("__Internal", EntryPoint="_samp_PlayerSpectatePlayer")] + public static extern void PlayerSpectatePlayer(int playerid, int targetplayerid, int mode=1); + [DllImport("__Internal", EntryPoint="_samp_PlayerSpectateVehicle")] + public static extern void PlayerSpectateVehicle(int playerid, int targetvehicleid, int mode=1); + [DllImport("__Internal", EntryPoint="_samp_StartRecordingPlayerData")] + public static extern void StartRecordingPlayerData(int playerid, int recordtype, string recordname); + [DllImport("__Internal", EntryPoint="_samp_StopRecordingPlayerData")] + public static extern void StopRecordingPlayerData(int playerid); + [DllImport("__Internal", EntryPoint="_samp_SelectTextDraw")] + public static extern void SelectTextDraw(int playerid, int hovercolor); + [DllImport("__Internal", EntryPoint="_samp_CancelSelectTextDraw")] + public static extern void CancelSelectTextDraw(int playerid); + #endregion + + // a_vehicles.inc + #region a_vehicles.inc + + // Vehicles + [DllImport("__Internal", EntryPoint="_samp_CreateVehicle")] + public static extern int CreateVehicle(int vehicletype, float x, float y, float z, float rotation, int color1, int color2, int respawn_delay); + [DllImport("__Internal", EntryPoint="_samp_DestroyVehicle")] + public static extern void DestroyVehicle(int vehicleid); + [DllImport("__Internal", EntryPoint="_samp_IsVehicleStreamedIn")] + public static extern void IsVehicleStreamedIn(int vehicleid, int forplayerid); + [DllImport("__Internal", EntryPoint="_samp_GetVehiclePos")] + public static extern void GetVehiclePos(int vehicleid, ref float x, ref float y, ref float z); + [DllImport("__Internal", EntryPoint="_samp_SetVehiclePos")] + public static extern void SetVehiclePos(int vehicleid, float x, float y, float z); + [DllImport("__Internal", EntryPoint="_samp_GetVehicleZAngle")] + public static extern void GetVehicleZAngle(int vehicleid, ref float z_angle); + [DllImport("__Internal", EntryPoint="_samp_GetVehicleRotationQuat")] + public static extern void GetVehicleRotationQuat(int vehicleid, ref float w, ref float x, ref float y, ref float z); + [DllImport("__Internal", EntryPoint="_samp_GetVehicleDistanceFromPoint")] + public static extern void GetVehicleDistanceFromPoint(int vehicleid, float x, float y, float z); + [DllImport("__Internal", EntryPoint="_samp_SetVehicleZAngle")] + public static extern void SetVehicleZAngle(int vehicleid, float z_angle); + [DllImport("__Internal", EntryPoint="_samp_SetVehicleParamsForPlayer")] + public static extern void SetVehicleParamsForPlayer(int vehicleid, int playerid, int objective, int doorslocked); + [DllImport("__Internal", EntryPoint="_samp_ManualVehicleEngineAndLights")] + public static extern void ManualVehicleEngineAndLights(); + [DllImport("__Internal", EntryPoint="_samp_SetVehicleParamsEx")] + public static extern void SetVehicleParamsEx(int vehicleid, int engine, int lights, int alarm, int doors, int bonnet, int boot, int objective); + [DllImport("__Internal", EntryPoint="_samp_GetVehicleParamsEx")] + public static extern void GetVehicleParamsEx(int vehicleid, ref int engine, ref int lights, ref int alarm, ref int doors, ref int bonnet, ref int boot, ref int objective); + [DllImport("__Internal", EntryPoint="_samp_SetVehicleToRespawn")] + public static extern void SetVehicleToRespawn(int vehicleid); + [DllImport("__Internal", EntryPoint="_samp_LinkVehicleToInterior")] + public static extern void LinkVehicleToInterior(int vehicleid, int interiorid); + [DllImport("__Internal", EntryPoint="_samp_AddVehicleComponent")] + public static extern void AddVehicleComponent(int vehicleid, int componentid); + [DllImport("__Internal", EntryPoint="_samp_RemoveVehicleComponent")] + public static extern void RemoveVehicleComponent(int vehicleid, int componentid); + [DllImport("__Internal", EntryPoint="_samp_ChangeVehicleColor")] + public static extern void ChangeVehicleColor(int vehicleid, int color1, int color2); + [DllImport("__Internal", EntryPoint="_samp_ChangeVehiclePaintjob")] + public static extern void ChangeVehiclePaintjob(int vehicleid, int paintjobid); + [DllImport("__Internal", EntryPoint="_samp_SetVehicleHealth")] + public static extern void SetVehicleHealth(int vehicleid, float health); + [DllImport("__Internal", EntryPoint="_samp_GetVehicleHealth")] + public static extern void GetVehicleHealth(int vehicleid, ref float health); + [DllImport("__Internal", EntryPoint="_samp_AttachTrailerToVehicle")] + public static extern void AttachTrailerToVehicle(int trailerid, int vehicleid); + [DllImport("__Internal", EntryPoint="_samp_DetachTrailerFromVehicle")] + public static extern void DetachTrailerFromVehicle(int vehicleid); + [DllImport("__Internal", EntryPoint="_samp_IsTrailerAttachedToVehicle")] + public static extern int IsTrailerAttachedToVehicle(int vehicleid); + [DllImport("__Internal", EntryPoint="_samp_GetVehicleTrailer")] + public static extern int GetVehicleTrailer(int vehicleid); + [DllImport("__Internal", EntryPoint="_samp_SetVehicleNumberPlate")] + public static extern void SetVehicleNumberPlate(int vehicleid, string numberplate); + [DllImport("__Internal", EntryPoint="_samp_GetVehicleModel")] + public static extern int GetVehicleModel(int vehicleid); + [DllImport("__Internal", EntryPoint="_samp_GetVehicleComponentInSlot")] + public static extern int GetVehicleComponentInSlot(int vehicleid, int slot); + [DllImport("__Internal", EntryPoint="_samp_GetVehicleComponentType")] + public static extern int GetVehicleComponentType(int component); + [DllImport("__Internal", EntryPoint="_samp_RepairVehicle")] + public static extern void RepairVehicle(int vehicleid); + [DllImport("__Internal", EntryPoint="_samp_GetVehicleVelocity")] + public static extern void GetVehicleVelocity(int vehicleid, ref float x, ref float y, ref float z); + [DllImport("__Internal", EntryPoint="_samp_SetVehicleVelocity")] + public static extern void SetVehicleVelocity(int vehicleid, float x, float y, float z); + [DllImport("__Internal", EntryPoint="_samp_SetVehicleAngularVelocity")] + public static extern void SetVehicleAngularVelocity(int vehicleid, float x, float y, float z); + [DllImport("__Internal", EntryPoint="_samp_GetVehicleDamageStatus")] + public static extern void GetVehicleDamageStatus(int vehicleid, ref int panels, ref int doors, ref int lights, ref int tires); + [DllImport("__Internal", EntryPoint="_samp_UpdateVehicleDamageStatus")] + public static extern void UpdateVehicleDamageStatus(int vehicleid, int panels, int doors, int lights, int tires); + [DllImport("__Internal", EntryPoint="_samp_GetVehicleModelInfo")] + public static extern void GetVehicleModelInfo(int vehiclemodel, int infotype, ref float x, ref float y, ref float z); + [DllImport("__Internal", EntryPoint="_samp_SetVehicleVirtualWorld")] + public static extern void SetVehicleVirtualWorld(int vehicleid, int worldid); + [DllImport("__Internal", EntryPoint="_samp_GetVehicleVirtualWorld")] + public static extern int GetVehicleVirtualWorld(int vehicleid); + + #endregion + + // a_objects.inc + #region a_objects.inc + + // Objects + [DllImport("__Internal", EntryPoint="_samp_CreateObject")] + public static extern int CreateObject(int modelid, float x, float y, float z, float rx, float ry, float rz, float drawdistance=0.0f); + [DllImport("__Internal", EntryPoint="_samp_AttachObjectToVehicle")] + public static extern void AttachObjectToVehicle(int objectid, int vehicleid, float offsetx, float offsety, float offsetz, float rotx, float roty, float rotz); + [DllImport("__Internal", EntryPoint="_samp_AttachObjectToObject")] + public static extern void AttachObjectToObject(int objectid, int attachtoid, float offsetx, float offsety, float offsetz, float rotx, float roty, float rotz, int syncrotation=1); + [DllImport("__Internal", EntryPoint="_samp_AttachObjectToPlayer")] + public static extern void AttachObjectToPlayer(int objectid, int playerid, float offsetx, float offsety, float offsetz, float rotx, float roty, float rotz); + [DllImport("__Internal", EntryPoint="_samp_SetObjectPos")] + public static extern void SetObjectPos(int objectid, float x, float y, float z); + [DllImport("__Internal", EntryPoint="_samp_GetObjectPos")] + public static extern void GetObjectPos(int objectid, ref float x, ref float y, ref float z); + [DllImport("__Internal", EntryPoint="_samp_SetObjectRot")] + public static extern void SetObjectRot(int objectid, float rotx, float roty, float rotz); + [DllImport("__Internal", EntryPoint="_samp_GetObjectRot")] + public static extern void GetObjectRot(int objectid, ref float rotx, ref float roty, ref float rotz); + [DllImport("__Internal", EntryPoint="_samp_IsValidObject")] + public static extern int IsValidObject(int objectid); + [DllImport("__Internal", EntryPoint="_samp_DestroyObject")] + public static extern void DestroyObject(int objectid); + [DllImport("__Internal", EntryPoint="_samp_MoveObject")] + public static extern void MoveObject(int objectid, float x, float y, float z, float speed, float rotx=-1000.0f, float roty=-1000.0f, float rotz=-1000.0f); + [DllImport("__Internal", EntryPoint="_samp_StopObject")] + public static extern void StopObject(int objectid); + [DllImport("__Internal", EntryPoint="_samp_IsObjectMoving")] + public static extern int IsObjectMoving(int objectid); + [DllImport("__Internal", EntryPoint="_samp_EditObject")] + public static extern void EditObject(int playerid, int objectid); + [DllImport("__Internal", EntryPoint="_samp_EditPlayerObject")] + public static extern void EditPlayerObject(int playerid, int objectid); + [DllImport("__Internal", EntryPoint="_samp_SelectObject")] + public static extern void SelectObject(int playerid); + [DllImport("__Internal", EntryPoint="_samp_CancelEdit")] + public static extern void CancelEdit(int playerid); + [DllImport("__Internal", EntryPoint="_samp_CreatePlayerObject")] + public static extern int CreatePlayerObject(int playerid, int modelid, float x, float y, float z, float rx, float ry, float rz, float drawdistance=0.0f); + [DllImport("__Internal", EntryPoint="_samp_AttachPlayerObjectToVehicle")] + public static extern void AttachPlayerObjectToVehicle(int playerid, int objectid, int vehicleid, float foffsetx, float foffsety, float foffsetz, float frotx, float froty, float rotz); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerObjectPos")] + public static extern void SetPlayerObjectPos(int playerid, int objectid, float x, float y, float z); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerObjectPos")] + public static extern void GetPlayerObjectPos(int playerid, int objectid, ref float x, ref float y, ref float z); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerObjectRot")] + public static extern void SetPlayerObjectRot(int playerid, int objectid, float rotx, float roty, float rotz); + [DllImport("__Internal", EntryPoint="_samp_GetPlayerObjectRot")] + public static extern void GetPlayerObjectRot(int playerid, int objectid, ref float rotx, ref float roty, ref float rotz); + [DllImport("__Internal", EntryPoint="_samp_IsValidPlayerObject")] + public static extern void IsValidPlayerObject(int playerid, int objectid); + [DllImport("__Internal", EntryPoint="_samp_DestroyPlayerObject")] + public static extern void DestroyPlayerObject(int playerid, int objectid); + [DllImport("__Internal", EntryPoint="_samp_MovePlayerObject")] + public static extern void MovePlayerObject(int playerid, int objectid, float x, float y, float z, float speed, float rotx=-1000.0f, float roty=-1000.0f, float rotz=-1000.0f); + [DllImport("__Internal", EntryPoint="_samp_StopPlayerObject")] + public static extern void StopPlayerObject(int playerid, int objectid); + [DllImport("__Internal", EntryPoint="_samp_IsPlayerObjectMoving")] + public static extern void IsPlayerObjectMoving(int playerid, int objectid); + [DllImport("__Internal", EntryPoint="_samp_AttachPlayerObjectToPlayer")] + public static extern void AttachPlayerObjectToPlayer(int objectplayer, int objectid, int attachplayer, float offsetx, float offsety, float offsetz, float rx, float ry, float rz); + [DllImport("__Internal", EntryPoint="_samp_SetObjectMaterial")] + public static extern void SetObjectMaterial(int objectid, int materialindex, int modelid, string txdname, string texturename, int materialcolor=0); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerObjectMaterial")] + public static extern void SetPlayerObjectMaterial(int playerid, int objectid, int materialindex, int modelid, string txdname, string texturename, int materialcolor=0); + [DllImport("__Internal", EntryPoint="_samp_SetObjectMaterialText")] + public static extern void SetObjectMaterialText(int objectid, string text, int materialindex=0, int materialsize=90, string fontface="arial", int fontsize=24, int bold=1, uint fontcolor=0xffffffff, int backcolor=0, int textalignment=0); + [DllImport("__Internal", EntryPoint="_samp_SetPlayerObjectMaterialText")] + public static extern void SetPlayerObjectMaterialText(int playerid, int objectid, string text, int materialindex=0, int materialsize=90, string fontface="arial", int fontsize=24, int bold=1, uint fontcolor=0xffffffff, int backcolor=0, int textalignment=0); + + #endregion + }; +}; diff --git a/sampdotnet/Properties/AssemblyInfo.cs b/sampdotnet/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..65c9164 --- /dev/null +++ b/sampdotnet/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SAMP.NET")] +[assembly: AssemblyDescription(".NET/Mono plugin for SA-MP")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Marshmallow Zombies")] +[assembly: AssemblyProduct("SAMP.NET")] +[assembly: AssemblyCopyright("Copyright © Oliver Davenport 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ef4e9941-fecb-4a69-9a95-61992c011286")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("0.6.0.0")] +[assembly: AssemblyFileVersion("0.6.0.0")] diff --git a/sampdotnet/sampdotnet.csproj b/sampdotnet/sampdotnet.csproj new file mode 100644 index 0000000..6d89a37 --- /dev/null +++ b/sampdotnet/sampdotnet.csproj @@ -0,0 +1,105 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {28F6A8E6-4A8A-4CDE-852C-FA578325B7DB} + Library + Properties + SAMP + sampdotnet + 512 + 0.6 BETA + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sampdotnethook/README b/sampdotnethook/README new file mode 100644 index 0000000..26ccaeb --- /dev/null +++ b/sampdotnethook/README @@ -0,0 +1,25 @@ +Important Note: +The Visual Studio project for the C++ hook was omitted since the introduction of the Linux-ready release. +In its place, a Code::Blocks project has been created. (Code::Blocks is a cross-platform open-source IDE) +The options have been pre-set for cross-compiling on both Windows and Linux, but there is some housekeeping you'll need to do if you want to build on either: + +== Building On Windows == +- Steps - +1) Load the project Build Options +2) Edit the Linker Settings +3) Remove the lib\limono-2.0.so library from the linker +4) Rebuild the project + +- Why? - +The .so library is a Linux "shared object", equivilent to a .dll on Windows. The linker has pre-set options to scan the lib/ directory for mono-2.0.dll, so we don't need to add that back in to the list. + +== Building on Linux == +- Steps +1) Load the project Build Options +2) Edit the Linker Settings +3) Under "Other linker options", omit the "def.def" flag from the list +4) Rebuild the project + +- Why? - +The definition module is a Windows-specific file for the linker to export the AMX functions to the DLL. Linux does a good job at not obfuscating function names upon compiling because it doesn't require the __stdcall convention to export said functions, so we don't need a definition module for this purpose. +It also throws errors because it's not a recognised file so just go with it. diff --git a/sampdotnethook/def.def b/sampdotnethook/def.def new file mode 100644 index 0000000..2ecf62b --- /dev/null +++ b/sampdotnethook/def.def @@ -0,0 +1,6 @@ +EXPORTS + Supports + Load + Unload + AmxLoad + AmxUnload diff --git a/sampdotnethook/include/mono/jit/jit.h b/sampdotnethook/include/mono/jit/jit.h new file mode 100644 index 0000000..1b31d11 --- /dev/null +++ b/sampdotnethook/include/mono/jit/jit.h @@ -0,0 +1,61 @@ +/* + * Author: + * Dietmar Maurer (dietmar@ximian.com) + * + * (C) 2001, 2002, 2003 Ximian, Inc. + */ + +#ifndef _MONO_JIT_JIT_H_ +#define _MONO_JIT_JIT_H_ + +#include "../metadata/appdomain.h" + +MONO_BEGIN_DECLS + +MonoDomain * +mono_jit_init (const char *file); + +MonoDomain * +mono_jit_init_version (const char *root_domain_name, const char *runtime_version); + +int +mono_jit_exec (MonoDomain *domain, MonoAssembly *assembly, + int argc, char *argv[]); +void +mono_jit_cleanup (MonoDomain *domain); + +mono_bool +mono_jit_set_trace_options (const char* options); + +void +mono_set_signal_chaining (mono_bool chain_signals); + +void +mono_jit_set_aot_only (mono_bool aot_only); + +/* Allow embedders to decide wherther to actually obey breakpoint instructions + * in specific methods (works for both break IL instructions and Debugger.Break () + * method calls). + */ +typedef enum { + /* the default is to always obey the breakpoint */ + MONO_BREAK_POLICY_ALWAYS, + /* a nop is inserted instead of a breakpoint */ + MONO_BREAK_POLICY_NEVER, + /* the breakpoint is executed only if the program has ben started under + * the debugger (that is if a debugger was attached at the time the method + * was compiled). + */ + MONO_BREAK_POLICY_ON_DBG +} MonoBreakPolicy; + +typedef MonoBreakPolicy (*MonoBreakPolicyFunc) (MonoMethod *method); +void mono_set_break_policy (MonoBreakPolicyFunc policy_callback); + +void +mono_jit_parse_options (int argc, char * argv[]); + +MONO_END_DECLS + +#endif + diff --git a/sampdotnethook/include/mono/metadata/appdomain.h b/sampdotnethook/include/mono/metadata/appdomain.h new file mode 100644 index 0000000..240d625 --- /dev/null +++ b/sampdotnethook/include/mono/metadata/appdomain.h @@ -0,0 +1,218 @@ +/* + * appdomain.h: AppDomain functions + * + * Author: + * Dietmar Maurer (dietmar@ximian.com) + * + * (C) 2001 Ximian, Inc. + */ + +#ifndef _MONO_METADATA_APPDOMAIN_H_ +#define _MONO_METADATA_APPDOMAIN_H_ + +#include "../utils/mono-publib.h" + +#include "object.h" +#include "reflection.h" + +MONO_BEGIN_DECLS + +typedef void (*MonoThreadStartCB) (intptr_t tid, void* stack_start, + void* func); +typedef void (*MonoThreadAttachCB) (intptr_t tid, void* stack_start); + +typedef struct _MonoAppDomain MonoAppDomain; +typedef struct _MonoJitInfo MonoJitInfo; + +typedef void (*MonoDomainFunc) (MonoDomain *domain, void* user_data); + +MonoDomain* +mono_init (const char *filename); + +MonoDomain * +mono_init_from_assembly (const char *domain_name, const char *filename); + +MonoDomain * +mono_init_version (const char *domain_name, const char *version); + +MonoDomain* +mono_get_root_domain (void); + +void +mono_runtime_init (MonoDomain *domain, MonoThreadStartCB start_cb, + MonoThreadAttachCB attach_cb); + +void +mono_runtime_cleanup (MonoDomain *domain); + +void +mono_install_runtime_cleanup (MonoDomainFunc func); + +void +mono_runtime_quit (void); + +void +mono_runtime_set_shutting_down (void); + +mono_bool +mono_runtime_is_shutting_down (void); + +const char* +mono_check_corlib_version (void); + +MonoDomain * +mono_domain_create (void); + +MonoDomain * +mono_domain_create_appdomain (char *friendly_name, char *configuration_file); + +MonoDomain * +mono_domain_get (void); + +MonoDomain * +mono_domain_get_by_id (int32_t domainid); + +int32_t +mono_domain_get_id (MonoDomain *domain); + +mono_bool +mono_domain_set (MonoDomain *domain, mono_bool force); + +void +mono_domain_set_internal (MonoDomain *domain); + +void +mono_domain_unload (MonoDomain *domain); + +void +mono_domain_try_unload (MonoDomain *domain, MonoObject **exc); + +mono_bool +mono_domain_is_unloading (MonoDomain *domain); + +MonoDomain * +mono_domain_from_appdomain (MonoAppDomain *appdomain); + +void +mono_domain_foreach (MonoDomainFunc func, void* user_data); + +MonoAssembly * +mono_domain_assembly_open (MonoDomain *domain, const char *name); + +mono_bool +mono_domain_finalize (MonoDomain *domain, uint32_t timeout); + +void +mono_domain_free (MonoDomain *domain, mono_bool force); + +mono_bool +mono_domain_has_type_resolve (MonoDomain *domain); + +MonoReflectionAssembly * +mono_domain_try_type_resolve (MonoDomain *domain, char *name, MonoObject *tb); + +mono_bool +mono_domain_owns_vtable_slot (MonoDomain *domain, void* vtable_slot); + +void +mono_context_init (MonoDomain *domain); + +void +mono_context_set (MonoAppContext *new_context); + +MonoAppContext * +mono_context_get (void); + +MonoJitInfo * +mono_jit_info_table_find (MonoDomain *domain, char *addr); + +/* MonoJitInfo accessors */ + +void* +mono_jit_info_get_code_start (MonoJitInfo* ji); + +int +mono_jit_info_get_code_size (MonoJitInfo* ji); + +MonoMethod* +mono_jit_info_get_method (MonoJitInfo* ji); + + +MonoImage* +mono_get_corlib (void); + +MonoClass* +mono_get_object_class (void); + +MonoClass* +mono_get_byte_class (void); + +MonoClass* +mono_get_void_class (void); + +MonoClass* +mono_get_boolean_class (void); + +MonoClass* +mono_get_sbyte_class (void); + +MonoClass* +mono_get_int16_class (void); + +MonoClass* +mono_get_uint16_class (void); + +MonoClass* +mono_get_int32_class (void); + +MonoClass* +mono_get_uint32_class (void); + +MonoClass* +mono_get_intptr_class (void); + +MonoClass* +mono_get_uintptr_class (void); + +MonoClass* +mono_get_int64_class (void); + +MonoClass* +mono_get_uint64_class (void); + +MonoClass* +mono_get_single_class (void); + +MonoClass* +mono_get_double_class (void); + +MonoClass* +mono_get_char_class (void); + +MonoClass* +mono_get_string_class (void); + +MonoClass* +mono_get_enum_class (void); + +MonoClass* +mono_get_array_class (void); + +MonoClass* +mono_get_thread_class (void); + +MonoClass* +mono_get_exception_class (void); + +void +mono_security_enable_core_clr (void); + +typedef mono_bool (*MonoCoreClrPlatformCB) (const char *image_name); + +void +mono_security_set_core_clr_platform_callback (MonoCoreClrPlatformCB callback); + +MONO_END_DECLS + +#endif /* _MONO_METADATA_APPDOMAIN_H_ */ + diff --git a/sampdotnethook/include/mono/metadata/assembly.h b/sampdotnethook/include/mono/metadata/assembly.h new file mode 100644 index 0000000..229f389 --- /dev/null +++ b/sampdotnethook/include/mono/metadata/assembly.h @@ -0,0 +1,111 @@ +#ifndef _MONONET_METADATA_ASSEMBLY_H_ +#define _MONONET_METADATA_ASSEMBLY_H_ + +#include "image.h" + +MONO_BEGIN_DECLS + +void mono_assemblies_init (void); +void mono_assemblies_cleanup (void); +MonoAssembly *mono_assembly_open (const char *filename, + MonoImageOpenStatus *status); +MonoAssembly *mono_assembly_open_full (const char *filename, + MonoImageOpenStatus *status, + mono_bool refonly); +MonoAssembly* mono_assembly_load (MonoAssemblyName *aname, + const char *basedir, + MonoImageOpenStatus *status); +MonoAssembly* mono_assembly_load_full (MonoAssemblyName *aname, + const char *basedir, + MonoImageOpenStatus *status, + mono_bool refonly); +MonoAssembly* mono_assembly_load_from (MonoImage *image, const char *fname, + MonoImageOpenStatus *status); +MonoAssembly* mono_assembly_load_from_full (MonoImage *image, const char *fname, + MonoImageOpenStatus *status, + mono_bool refonly); + +MonoAssembly* mono_assembly_load_with_partial_name (const char *name, MonoImageOpenStatus *status); + +MonoAssembly* mono_assembly_loaded (MonoAssemblyName *aname); +MonoAssembly* mono_assembly_loaded_full (MonoAssemblyName *aname, mono_bool refonly); +void mono_assembly_get_assemblyref (MonoImage *image, int index, MonoAssemblyName *aname); +void mono_assembly_load_reference (MonoImage *image, int index); +void mono_assembly_load_references (MonoImage *image, MonoImageOpenStatus *status); +MonoImage* mono_assembly_load_module (MonoAssembly *assembly, uint32_t idx); +void mono_assembly_close (MonoAssembly *assembly); +void mono_assembly_setrootdir (const char *root_dir); +MONO_CONST_RETURN char *mono_assembly_getrootdir (void); +void mono_assembly_foreach (MonoFunc func, void* user_data); +void mono_assembly_set_main (MonoAssembly *assembly); +MonoAssembly *mono_assembly_get_main (void); +MonoImage *mono_assembly_get_image (MonoAssembly *assembly); +mono_bool mono_assembly_fill_assembly_name (MonoImage *image, MonoAssemblyName *aname); +mono_bool mono_assembly_names_equal (MonoAssemblyName *l, MonoAssemblyName *r); +char* mono_stringify_assembly_name (MonoAssemblyName *aname); + +/* Installs a function which is called each time a new assembly is loaded. */ +typedef void (*MonoAssemblyLoadFunc) (MonoAssembly *assembly, void* user_data); +void mono_install_assembly_load_hook (MonoAssemblyLoadFunc func, void* user_data); + +/* + * Installs a new function which is used to search the list of loaded + * assemblies for a given assembly name. + */ +typedef MonoAssembly *(*MonoAssemblySearchFunc) (MonoAssemblyName *aname, void* user_data); +void mono_install_assembly_search_hook (MonoAssemblySearchFunc func, void* user_data); +void mono_install_assembly_refonly_search_hook (MonoAssemblySearchFunc func, void* user_data); + +MonoAssembly* mono_assembly_invoke_search_hook (MonoAssemblyName *aname); + +/* + * Installs a new search function which is used as a last resort when loading + * an assembly fails. This could invoke AssemblyResolve events. + */ +void +mono_install_assembly_postload_search_hook (MonoAssemblySearchFunc func, void* user_data); + +void +mono_install_assembly_postload_refonly_search_hook (MonoAssemblySearchFunc func, void* user_data); + + +/* Installs a function which is called before a new assembly is loaded + * The hook are invoked from last hooked to first. If any of them returns + * a non-null value, that will be the value returned in mono_assembly_load */ +typedef MonoAssembly * (*MonoAssemblyPreLoadFunc) (MonoAssemblyName *aname, + char **assemblies_path, + void* user_data); + +void mono_install_assembly_preload_hook (MonoAssemblyPreLoadFunc func, + void* user_data); +void mono_install_assembly_refonly_preload_hook (MonoAssemblyPreLoadFunc func, + void* user_data); + +void mono_assembly_invoke_load_hook (MonoAssembly *ass); + +MonoAssemblyName* mono_assembly_name_new (const char *name); +const char* mono_assembly_name_get_name (MonoAssemblyName *aname); +const char* mono_assembly_name_get_culture (MonoAssemblyName *aname); +uint16_t mono_assembly_name_get_version (MonoAssemblyName *aname, + uint16_t *minor, uint16_t *build, uint16_t *revision); +mono_byte* mono_assembly_name_get_pubkeytoken (MonoAssemblyName *aname); +void mono_assembly_name_free (MonoAssemblyName *aname); + +typedef struct { + const char *name; + const unsigned char *data; + const unsigned int size; +} MonoBundledAssembly; + +void mono_register_bundled_assemblies (const MonoBundledAssembly **assemblies); +void mono_register_config_for_assembly (const char* assembly_name, const char* config_xml); +void mono_register_symfile_for_assembly (const char* assembly_name, const mono_byte *raw_contents, int size); +void mono_register_machine_config (const char *config_xml); + +void mono_set_rootdir (void); +void mono_set_dirs (const char *assembly_dir, const char *config_dir); +void mono_set_assemblies_path (const char* path); +MONO_END_DECLS + +#endif + diff --git a/sampdotnethook/include/mono/metadata/attrdefs.h b/sampdotnethook/include/mono/metadata/attrdefs.h new file mode 100644 index 0000000..8ba0cba --- /dev/null +++ b/sampdotnethook/include/mono/metadata/attrdefs.h @@ -0,0 +1,273 @@ +/* + * attredefs.h: This file contains the various definitions for constants + * found on the metadata tables + * + * Author: + * Miguel de Icaza (miguel@ximian.com) + * Paolo Molaro (lupus@ximian.com) + * + * (C) 2001 Ximian, Inc. + * (C) 2006 Novell, Inc. + * + * From the ECMA documentation + */ + +#ifndef _MONO_METADATA_ATTRDEFS_H_ +#define _MONO_METADATA_ATTRDEFS_H_ + +/* + * 23.1.1 Values for AssemblyHashAlgorithm + */ +enum { + MONO_ASSEMBLY_HASH_NONE, + MONO_ASSEMBLY_HASH_MD5 = 0x8003, + MONO_ASSEMBLY_HASH_SHA1 = 0x8004 +}; + +/* + * 23.1.2 AssemblyRefs + */ +enum { + MONO_ASSEMBLYREF_FULL_PUBLIC_KEY = 0x0001, + MONO_ASSEMBLYREF_RETARGETABLE = 0x0100, + MONO_ASSEMBLYREF_JIT_TRACKING = 0x8000, + MONO_ASSEMBLYREF_NO_JIT_OPT = 0x4000 +}; + +/* + * 23.1.4 Flags for Event.EventAttributes + */ +enum { + MONO_EVENT_SPECIALNAME = 0x0200, + MONO_EVENT_RTSPECIALNAME = 0x0400 +}; + +/* + * Field Attributes (23.1.5). + */ +enum { + MONO_FIELD_ATTR_FIELD_ACCESS_MASK = 0x0007, + MONO_FIELD_ATTR_COMPILER_CONTROLLED = 0x0000, + MONO_FIELD_ATTR_PRIVATE = 0x0001, + MONO_FIELD_ATTR_FAM_AND_ASSEM = 0x0002, + MONO_FIELD_ATTR_ASSEMBLY = 0x0003, + MONO_FIELD_ATTR_FAMILY = 0x0004, + MONO_FIELD_ATTR_FAM_OR_ASSEM = 0x0005, + MONO_FIELD_ATTR_PUBLIC = 0x0006, + + MONO_FIELD_ATTR_STATIC = 0x0010, + MONO_FIELD_ATTR_INIT_ONLY = 0x0020, + MONO_FIELD_ATTR_LITERAL = 0x0040, + MONO_FIELD_ATTR_NOT_SERIALIZED = 0x0080, + MONO_FIELD_ATTR_SPECIAL_NAME = 0x0200, + MONO_FIELD_ATTR_PINVOKE_IMPL = 0x2000, + +/* For runtime use only */ + MONO_FIELD_ATTR_RESERVED_MASK = 0x9500, + MONO_FIELD_ATTR_RT_SPECIAL_NAME = 0x0400, + MONO_FIELD_ATTR_HAS_MARSHAL = 0x1000, + MONO_FIELD_ATTR_HAS_DEFAULT = 0x8000, + MONO_FIELD_ATTR_HAS_RVA = 0x0100 +}; + +/* + * 23.1.6 Flags for FileAttributes + */ +enum { + MONO_FILE_HAS_METADATA = 0, + MONO_FILE_HAS_NO_METADATA = 1 +}; + +/* + * 23.1.7 Flags for generic parameters + */ +enum { + MONO_GEN_PARAM_VARIANCE_MASK = 0x0003, + MONO_GEN_PARAM_NON_VARIANT = 0x0000, + MONO_GEN_PARAM_VARIANT = 0x0001, + MONO_GEN_PARAM_COVARIANT = 0x0002, + MONO_GEN_PARAM_CONSTRAINT_MASK = 0x001c, + MONO_GEN_PARAM_CONSTRAINT_CLASS = 0x0004, + MONO_GEN_PARAM_CONSTRAINT_VTYPE = 0x0008, + MONO_GEN_PARAM_CONSTRAINT_DCTOR = 0x0010 +}; + +/* + * 23.1.8 Flags for ImplMap [PInvokeAttributes] + */ +enum { + MONO_PINVOKE_NO_MANGLE = 0x0001, + MONO_PINVOKE_CHAR_SET_MASK = 0x0006, + MONO_PINVOKE_CHAR_SET_NOT_SPEC = 0x0000, + MONO_PINVOKE_CHAR_SET_ANSI = 0x0002, + MONO_PINVOKE_CHAR_SET_UNICODE = 0x0004, + MONO_PINVOKE_CHAR_SET_AUTO = 0x0006, + MONO_PINVOKE_BEST_FIT_ENABLED = 0x0010, + MONO_PINVOKE_BEST_FIT_DISABLED = 0x0020, + MONO_PINVOKE_BEST_FIT_MASK = 0x0030, + MONO_PINVOKE_SUPPORTS_LAST_ERROR = 0x0040, + MONO_PINVOKE_CALL_CONV_MASK = 0x0700, + MONO_PINVOKE_CALL_CONV_WINAPI = 0x0100, + MONO_PINVOKE_CALL_CONV_CDECL = 0x0200, + MONO_PINVOKE_CALL_CONV_STDCALL = 0x0300, + MONO_PINVOKE_CALL_CONV_THISCALL = 0x0400, + MONO_PINVOKE_CALL_CONV_FASTCALL = 0x0500, + MONO_PINVOKE_THROW_ON_UNMAPPABLE_ENABLED = 0x1000, + MONO_PINVOKE_THROW_ON_UNMAPPABLE_DISABLED = 0x2000, + MONO_PINVOKE_THROW_ON_UNMAPPABLE_MASK = 0x3000, + MONO_PINVOKE_CALL_CONV_GENERIC = 0x0010, + MONO_PINVOKE_CALL_CONV_GENERICINST = 0x000a +}; + +/* + * 23.1.9 Flags for ManifestResource + */ +enum { + MONO_MANIFEST_RESOURCE_VISIBILITY_MASK = 0x00000007, + MONO_MANIFEST_RESOURCE_PUBLIC = 0x00000001, + MONO_MANIFEST_RESOURCE_PRIVATE = 0x00000002 +}; + +/* + * Method Attributes (23.1.10) + */ +enum { + MONO_METHOD_ATTR_ACCESS_MASK = 0x0007, + MONO_METHOD_ATTR_COMPILER_CONTROLLED = 0x0000, + MONO_METHOD_ATTR_PRIVATE = 0x0001, + MONO_METHOD_ATTR_FAM_AND_ASSEM = 0x0002, + MONO_METHOD_ATTR_ASSEM = 0x0003, + MONO_METHOD_ATTR_FAMILY = 0x0004, + MONO_METHOD_ATTR_FAM_OR_ASSEM = 0x0005, + MONO_METHOD_ATTR_PUBLIC = 0x0006, + + MONO_METHOD_ATTR_STATIC = 0x0010, + MONO_METHOD_ATTR_FINAL = 0x0020, + MONO_METHOD_ATTR_VIRTUAL = 0x0040, + MONO_METHOD_ATTR_HIDE_BY_SIG = 0x0080, + + MONO_METHOD_ATTR_VTABLE_LAYOUT_MASK = 0x0100, + MONO_METHOD_ATTR_REUSE_SLOT = 0x0000, + MONO_METHOD_ATTR_NEW_SLOT = 0x0100, + MONO_METHOD_ATTR_STRICT = 0x0200, + MONO_METHOD_ATTR_ABSTRACT = 0x0400, + + MONO_METHOD_ATTR_SPECIAL_NAME = 0x0800, + + MONO_METHOD_ATTR_PINVOKE_IMPL = 0x2000, + MONO_METHOD_ATTR_UNMANAGED_EXPORT = 0x0008, + +/* + * For runtime use only + */ + MONO_METHOD_ATTR_RESERVED_MASK = 0xd000, + MONO_METHOD_ATTR_RT_SPECIAL_NAME = 0x1000, + MONO_METHOD_ATTR_HAS_SECURITY = 0x4000, + MONO_METHOD_ATTR_REQUIRE_SEC_OBJECT = 0x8000 +}; + +/* + * Method Impl Attributes (23.1.11) + */ +enum { + MONO_METHOD_IMPL_ATTR_CODE_TYPE_MASK = 0x0003, + MONO_METHOD_IMPL_ATTR_IL = 0x0000, + MONO_METHOD_IMPL_ATTR_NATIVE = 0x0001, + MONO_METHOD_IMPL_ATTR_OPTIL = 0x0002, + MONO_METHOD_IMPL_ATTR_RUNTIME = 0x0003, + + MONO_METHOD_IMPL_ATTR_MANAGED_MASK = 0x0004, + MONO_METHOD_IMPL_ATTR_UNMANAGED = 0x0004, + MONO_METHOD_IMPL_ATTR_MANAGED = 0x0000, + + MONO_METHOD_IMPL_ATTR_FORWARD_REF = 0x0010, + MONO_METHOD_IMPL_ATTR_PRESERVE_SIG = 0x0080, + MONO_METHOD_IMPL_ATTR_INTERNAL_CALL = 0x1000, + MONO_METHOD_IMPL_ATTR_SYNCHRONIZED = 0x0020, + MONO_METHOD_IMPL_ATTR_NOINLINING = 0x0008, + MONO_METHOD_IMPL_ATTR_NOOPTIMIZATION = 0x0040, + MONO_METHOD_IMPL_ATTR_MAX_METHOD_IMPL_VAL = 0xffff +}; + +/* + * Method Semantics ([MethodSemanticAttributes]) 23.1.12, + */ +enum { + MONO_METHOD_SEMANTIC_SETTER = 0x0001, + MONO_METHOD_SEMANTIC_GETTER = 0x0002, + MONO_METHOD_SEMANTIC_OTHER = 0x0004, + MONO_METHOD_SEMANTIC_ADD_ON = 0x0008, + MONO_METHOD_SEMANTIC_REMOVE_ON = 0x0010, + MONO_METHOD_SEMANTIC_FIRE = 0x0020 +}; + +/* + * Flags for Params (23.1.13) + */ +enum { + MONO_PARAM_ATTR_IN = 0x0001, + MONO_PARAM_ATTR_OUT = 0x0002, + MONO_PARAM_ATTR_OPTIONAL = 0x0010, + MONO_PARAM_ATTR_RESERVED_MASK = 0xf000, + MONO_PARAM_ATTR_HAS_DEFAULT = 0x1000, + MONO_PARAM_ATTR_HAS_MARSHAL = 0x2000, + MONO_PARAM_ATTR_UNUSED = 0xcfe0 +}; + +/* + * 23.1.14 PropertyAttributes + */ +enum { + MONO_PROPERTY_ATTR_SPECIAL_NAME = 0x0200, + MONO_PROPERTY_ATTR_RESERVED_MASK = 0xf400, + MONO_PROPERTY_ATTR_RT_SPECIAL_NAME = 0x0400, + MONO_PROPERTY_ATTR_HAS_DEFAULT = 0x1000, + MONO_PROPERTY_ATTR_UNUSED = 0xe9ff +}; + +/* + * Type Attributes (23.1.15). + */ +enum { + MONO_TYPE_ATTR_VISIBILITY_MASK = 0x00000007, + MONO_TYPE_ATTR_NOT_PUBLIC = 0x00000000, + MONO_TYPE_ATTR_PUBLIC = 0x00000001, + MONO_TYPE_ATTR_NESTED_PUBLIC = 0x00000002, + MONO_TYPE_ATTR_NESTED_PRIVATE = 0x00000003, + MONO_TYPE_ATTR_NESTED_FAMILY = 0x00000004, + MONO_TYPE_ATTR_NESTED_ASSEMBLY = 0x00000005, + MONO_TYPE_ATTR_NESTED_FAM_AND_ASSEM = 0x00000006, + MONO_TYPE_ATTR_NESTED_FAM_OR_ASSEM = 0x00000007, + + MONO_TYPE_ATTR_LAYOUT_MASK = 0x00000018, + MONO_TYPE_ATTR_AUTO_LAYOUT = 0x00000000, + MONO_TYPE_ATTR_SEQUENTIAL_LAYOUT = 0x00000008, + MONO_TYPE_ATTR_EXPLICIT_LAYOUT = 0x00000010, + + MONO_TYPE_ATTR_CLASS_SEMANTIC_MASK = 0x00000020, + MONO_TYPE_ATTR_CLASS = 0x00000000, + MONO_TYPE_ATTR_INTERFACE = 0x00000020, + + MONO_TYPE_ATTR_ABSTRACT = 0x00000080, + MONO_TYPE_ATTR_SEALED = 0x00000100, + MONO_TYPE_ATTR_SPECIAL_NAME = 0x00000400, + + MONO_TYPE_ATTR_IMPORT = 0x00001000, + MONO_TYPE_ATTR_SERIALIZABLE = 0x00002000, + + MONO_TYPE_ATTR_STRING_FORMAT_MASK = 0x00030000, + MONO_TYPE_ATTR_ANSI_CLASS = 0x00000000, + MONO_TYPE_ATTR_UNICODE_CLASS = 0x00010000, + MONO_TYPE_ATTR_AUTO_CLASS = 0x00020000, + MONO_TYPE_ATTR_CUSTOM_CLASS = 0x00030000, + MONO_TYPE_ATTR_CUSTOM_MASK = 0x00c00000, + + MONO_TYPE_ATTR_BEFORE_FIELD_INIT = 0x00100000, + MONO_TYPE_ATTR_FORWARDER = 0x00200000, + + MONO_TYPE_ATTR_RESERVED_MASK = 0x00040800, + MONO_TYPE_ATTR_RT_SPECIAL_NAME = 0x00000800, + MONO_TYPE_ATTR_HAS_SECURITY = 0x00040000 +}; + +#endif diff --git a/sampdotnethook/include/mono/metadata/blob.h b/sampdotnethook/include/mono/metadata/blob.h new file mode 100644 index 0000000..3d0e3ab --- /dev/null +++ b/sampdotnethook/include/mono/metadata/blob.h @@ -0,0 +1,105 @@ +/* + * blob.h: Definitions used to pull information out of the Blob + * + */ +#ifndef _MONO_METADATA_BLOB_H_ +#define _MONO_METADATA_BLOB_H_ + +/* + * Encoding for type signatures used in the Metadata + */ +typedef enum { + MONO_TYPE_END = 0x00, /* End of List */ + MONO_TYPE_VOID = 0x01, + MONO_TYPE_BOOLEAN = 0x02, + MONO_TYPE_CHAR = 0x03, + MONO_TYPE_I1 = 0x04, + MONO_TYPE_U1 = 0x05, + MONO_TYPE_I2 = 0x06, + MONO_TYPE_U2 = 0x07, + MONO_TYPE_I4 = 0x08, + MONO_TYPE_U4 = 0x09, + MONO_TYPE_I8 = 0x0a, + MONO_TYPE_U8 = 0x0b, + MONO_TYPE_R4 = 0x0c, + MONO_TYPE_R8 = 0x0d, + MONO_TYPE_STRING = 0x0e, + MONO_TYPE_PTR = 0x0f, /* arg: token */ + MONO_TYPE_BYREF = 0x10, /* arg: token */ + MONO_TYPE_VALUETYPE = 0x11, /* arg: token */ + MONO_TYPE_CLASS = 0x12, /* arg: token */ + MONO_TYPE_VAR = 0x13, /* number */ + MONO_TYPE_ARRAY = 0x14, /* type, rank, boundsCount, bound1, loCount, lo1 */ + MONO_TYPE_GENERICINST= 0x15, /* \x{2026} */ + MONO_TYPE_TYPEDBYREF = 0x16, + MONO_TYPE_I = 0x18, + MONO_TYPE_U = 0x19, + MONO_TYPE_FNPTR = 0x1b, /* arg: full method signature */ + MONO_TYPE_OBJECT = 0x1c, + MONO_TYPE_SZARRAY = 0x1d, /* 0-based one-dim-array */ + MONO_TYPE_MVAR = 0x1e, /* number */ + MONO_TYPE_CMOD_REQD = 0x1f, /* arg: typedef or typeref token */ + MONO_TYPE_CMOD_OPT = 0x20, /* optional arg: typedef or typref token */ + MONO_TYPE_INTERNAL = 0x21, /* CLR internal type */ + + MONO_TYPE_MODIFIER = 0x40, /* Or with the following types */ + MONO_TYPE_SENTINEL = 0x41, /* Sentinel for varargs method signature */ + MONO_TYPE_PINNED = 0x45, /* Local var that points to pinned object */ + + MONO_TYPE_ENUM = 0x55 /* an enumeration */ +} MonoTypeEnum; + +typedef enum { + MONO_TABLE_MODULE, + MONO_TABLE_TYPEREF, + MONO_TABLE_TYPEDEF, + MONO_TABLE_FIELD_POINTER, + MONO_TABLE_FIELD, + MONO_TABLE_METHOD_POINTER, + MONO_TABLE_METHOD, + MONO_TABLE_PARAM_POINTER, + MONO_TABLE_PARAM, + MONO_TABLE_INTERFACEIMPL, + MONO_TABLE_MEMBERREF, /* 0xa */ + MONO_TABLE_CONSTANT, + MONO_TABLE_CUSTOMATTRIBUTE, + MONO_TABLE_FIELDMARSHAL, + MONO_TABLE_DECLSECURITY, + MONO_TABLE_CLASSLAYOUT, + MONO_TABLE_FIELDLAYOUT, /* 0x10 */ + MONO_TABLE_STANDALONESIG, + MONO_TABLE_EVENTMAP, + MONO_TABLE_EVENT_POINTER, + MONO_TABLE_EVENT, + MONO_TABLE_PROPERTYMAP, + MONO_TABLE_PROPERTY_POINTER, + MONO_TABLE_PROPERTY, + MONO_TABLE_METHODSEMANTICS, + MONO_TABLE_METHODIMPL, + MONO_TABLE_MODULEREF, /* 0x1a */ + MONO_TABLE_TYPESPEC, + MONO_TABLE_IMPLMAP, + MONO_TABLE_FIELDRVA, + MONO_TABLE_UNUSED6, + MONO_TABLE_UNUSED7, + MONO_TABLE_ASSEMBLY, /* 0x20 */ + MONO_TABLE_ASSEMBLYPROCESSOR, + MONO_TABLE_ASSEMBLYOS, + MONO_TABLE_ASSEMBLYREF, + MONO_TABLE_ASSEMBLYREFPROCESSOR, + MONO_TABLE_ASSEMBLYREFOS, + MONO_TABLE_FILE, + MONO_TABLE_EXPORTEDTYPE, + MONO_TABLE_MANIFESTRESOURCE, + MONO_TABLE_NESTEDCLASS, + MONO_TABLE_GENERICPARAM, /* 0x2a */ + MONO_TABLE_METHODSPEC, + MONO_TABLE_GENERICPARAMCONSTRAINT + +#define MONO_TABLE_LAST MONO_TABLE_GENERICPARAMCONSTRAINT +#define MONO_TABLE_NUM (MONO_TABLE_LAST + 1) + +} MonoMetaTableEnum; + +#endif + diff --git a/sampdotnethook/include/mono/metadata/class.h b/sampdotnethook/include/mono/metadata/class.h new file mode 100644 index 0000000..4a259c6 --- /dev/null +++ b/sampdotnethook/include/mono/metadata/class.h @@ -0,0 +1,263 @@ +#ifndef _MONO_CLI_CLASS_H_ +#define _MONO_CLI_CLASS_H_ + +#include "metadata.h" +#include "image.h" +#include "loader.h" + +MONO_BEGIN_DECLS + +typedef struct MonoVTable MonoVTable; + +typedef struct _MonoClassField MonoClassField; +typedef struct _MonoProperty MonoProperty; +typedef struct _MonoEvent MonoEvent; + +MonoClass * +mono_class_get (MonoImage *image, uint32_t type_token); + +MonoClass * +mono_class_get_full (MonoImage *image, uint32_t type_token, MonoGenericContext *context); + +mono_bool +mono_class_init (MonoClass *klass); + +MonoVTable * +mono_class_vtable (MonoDomain *domain, MonoClass *klass); + +MonoClass * +mono_class_from_name (MonoImage *image, const char* name_space, const char *name); + +MonoClass * +mono_class_from_name_case (MonoImage *image, const char* name_space, const char *name); + +MonoMethod * +mono_class_get_method_from_name_flags (MonoClass *klass, const char *name, int param_count, int flags); + +MonoClass * +mono_class_from_typeref (MonoImage *image, uint32_t type_token); + +MonoClass * +mono_class_from_generic_parameter (MonoGenericParam *param, MonoImage *image, mono_bool is_mvar); + +MonoType* +mono_class_inflate_generic_type (MonoType *type, MonoGenericContext *context) /* MONO_DEPRECATED */; + +MonoMethod* +mono_class_inflate_generic_method (MonoMethod *method, MonoGenericContext *context); + +MonoMethod * +mono_get_inflated_method (MonoMethod *method); + +MonoClassField* +mono_field_from_token (MonoImage *image, uint32_t token, MonoClass **retklass, MonoGenericContext *context); + +MonoClass * +mono_bounded_array_class_get (MonoClass *element_class, uint32_t rank, mono_bool bounded); + +MonoClass * +mono_array_class_get (MonoClass *element_class, uint32_t rank); + +MonoClass * +mono_ptr_class_get (MonoType *type); + +MonoClassField * +mono_class_get_field (MonoClass *klass, uint32_t field_token); + +MonoClassField * +mono_class_get_field_from_name (MonoClass *klass, const char *name); + +uint32_t +mono_class_get_field_token (MonoClassField *field); + +uint32_t +mono_class_get_event_token (MonoEvent *event); + +MonoProperty* +mono_class_get_property_from_name (MonoClass *klass, const char *name); + +uint32_t +mono_class_get_property_token (MonoProperty *prop); + +int32_t +mono_array_element_size (MonoClass *ac); + +int32_t +mono_class_instance_size (MonoClass *klass); + +int32_t +mono_class_array_element_size (MonoClass *klass); + +int32_t +mono_class_data_size (MonoClass *klass); + +int32_t +mono_class_value_size (MonoClass *klass, uint32_t *align); + +int32_t +mono_class_min_align (MonoClass *klass); + +MonoClass * +mono_class_from_mono_type (MonoType *type); + +mono_bool +mono_class_is_subclass_of (MonoClass *klass, MonoClass *klassc, + mono_bool check_interfaces); + +mono_bool +mono_class_is_assignable_from (MonoClass *klass, MonoClass *oklass); + +void* +mono_ldtoken (MonoImage *image, uint32_t token, MonoClass **retclass, MonoGenericContext *context); + +char* +mono_type_get_name (MonoType *type); + +MonoType* +mono_type_get_underlying_type (MonoType *type); + +/* MonoClass accessors */ +MonoImage* +mono_class_get_image (MonoClass *klass); + +MonoClass* +mono_class_get_element_class (MonoClass *klass); + +mono_bool +mono_class_is_valuetype (MonoClass *klass); + +mono_bool +mono_class_is_enum (MonoClass *klass); + +MonoType* +mono_class_enum_basetype (MonoClass *klass); + +MonoClass* +mono_class_get_parent (MonoClass *klass); + +MonoClass* +mono_class_get_nesting_type (MonoClass *klass); + +int +mono_class_get_rank (MonoClass *klass); + +uint32_t +mono_class_get_flags (MonoClass *klass); + +const char* +mono_class_get_name (MonoClass *klass); + +const char* +mono_class_get_namespace (MonoClass *klass); + +MonoType* +mono_class_get_type (MonoClass *klass); + +uint32_t +mono_class_get_type_token (MonoClass *klass); + +MonoType* +mono_class_get_byref_type (MonoClass *klass); + +int +mono_class_num_fields (MonoClass *klass); + +int +mono_class_num_methods (MonoClass *klass); + +int +mono_class_num_properties (MonoClass *klass); + +int +mono_class_num_events (MonoClass *klass); + +MonoClassField* +mono_class_get_fields (MonoClass* klass, void **iter); + +MonoMethod* +mono_class_get_methods (MonoClass* klass, void **iter); + +MonoProperty* +mono_class_get_properties (MonoClass* klass, void **iter); + +MonoEvent* +mono_class_get_events (MonoClass* klass, void **iter); + +MonoClass* +mono_class_get_interfaces (MonoClass* klass, void **iter); + +MonoClass* +mono_class_get_nested_types (MonoClass* klass, void **iter); + +/* MonoClassField accessors */ +const char* +mono_field_get_name (MonoClassField *field); + +MonoType* +mono_field_get_type (MonoClassField *field); + +MonoClass* +mono_field_get_parent (MonoClassField *field); + +uint32_t +mono_field_get_flags (MonoClassField *field); + +uint32_t +mono_field_get_offset (MonoClassField *field); + +const char * +mono_field_get_data (MonoClassField *field); + +/* MonoProperty acessors */ +const char* +mono_property_get_name (MonoProperty *prop); + +MonoMethod* +mono_property_get_set_method (MonoProperty *prop); + +MonoMethod* +mono_property_get_get_method (MonoProperty *prop); + +MonoClass* +mono_property_get_parent (MonoProperty *prop); + +uint32_t +mono_property_get_flags (MonoProperty *prop); + +/* MonoEvent accessors */ +const char* +mono_event_get_name (MonoEvent *event); + +MonoMethod* +mono_event_get_add_method (MonoEvent *event); + +MonoMethod* +mono_event_get_remove_method (MonoEvent *event); + +MonoMethod* +mono_event_get_remove_method (MonoEvent *event); + +MonoMethod* +mono_event_get_raise_method (MonoEvent *event); + +MonoClass* +mono_event_get_parent (MonoEvent *event); + +uint32_t +mono_event_get_flags (MonoEvent *event); + +MonoMethod * +mono_class_get_method_from_name (MonoClass *klass, const char *name, int param_count); + +char * +mono_class_name_from_token (MonoImage *image, uint32_t type_token); + +mono_bool +mono_method_can_access_field (MonoMethod *method, MonoClassField *field); + +mono_bool +mono_method_can_access_method (MonoMethod *method, MonoMethod *called); + +MONO_END_DECLS + +#endif /* _MONO_CLI_CLASS_H_ */ diff --git a/sampdotnethook/include/mono/metadata/debug-helpers.h b/sampdotnethook/include/mono/metadata/debug-helpers.h new file mode 100644 index 0000000..2d1dbad --- /dev/null +++ b/sampdotnethook/include/mono/metadata/debug-helpers.h @@ -0,0 +1,48 @@ +#ifndef __MONO_DEBUG_HELPERS_H__ +#define __MONO_DEBUG_HELPERS_H__ + +#include "class.h" + +MONO_BEGIN_DECLS + +typedef struct MonoDisHelper MonoDisHelper; + +typedef char* (*MonoDisIndenter) (MonoDisHelper *dh, MonoMethod *method, uint32_t ip_offset); +typedef char* (*MonoDisTokener) (MonoDisHelper *dh, MonoMethod *method, uint32_t token); + +struct MonoDisHelper { + const char *newline; + const char *label_format; + const char *label_target; + MonoDisIndenter indenter; + MonoDisTokener tokener; + void* user_data; +}; + +char* mono_disasm_code_one (MonoDisHelper *dh, MonoMethod *method, const mono_byte *ip, const mono_byte** endp); +char* mono_disasm_code (MonoDisHelper *dh, MonoMethod *method, const mono_byte *ip, const mono_byte* end); + +typedef struct MonoMethodDesc MonoMethodDesc; + +char* mono_type_full_name (MonoType *type); + +char* mono_signature_get_desc (MonoMethodSignature *sig, mono_bool include_namespace); + +char* mono_context_get_desc (MonoGenericContext *context); + +MonoMethodDesc* mono_method_desc_new (const char *name, mono_bool include_namespace); +MonoMethodDesc* mono_method_desc_from_method (MonoMethod *method); +void mono_method_desc_free (MonoMethodDesc *desc); +mono_bool mono_method_desc_match (MonoMethodDesc *desc, MonoMethod *method); +mono_bool mono_method_desc_full_match (MonoMethodDesc *desc, MonoMethod *method); +MonoMethod* mono_method_desc_search_in_class (MonoMethodDesc *desc, MonoClass *klass); +MonoMethod* mono_method_desc_search_in_image (MonoMethodDesc *desc, MonoImage *image); + +char* mono_method_full_name (MonoMethod *method, mono_bool signature); + +char* mono_field_full_name (MonoClassField *field); + +MONO_END_DECLS + +#endif /* __MONO_DEBUG_HELPERS_H__ */ + diff --git a/sampdotnethook/include/mono/metadata/debug-mono-symfile.h b/sampdotnethook/include/mono/metadata/debug-mono-symfile.h new file mode 100644 index 0000000..e36753b --- /dev/null +++ b/sampdotnethook/include/mono/metadata/debug-mono-symfile.h @@ -0,0 +1,153 @@ +/* + * This header is only installed for use by the debugger: + * the structures and the API declared here are not supported. + */ + +#ifndef __MONO_DEBUG_MONO_SYMFILE_H__ +#define __MONO_DEBUG_MONO_SYMFILE_H__ + +#include +#include +#include + +typedef struct MonoSymbolFileOffsetTable MonoSymbolFileOffsetTable; +typedef struct MonoSymbolFileLineNumberEntry MonoSymbolFileLineNumberEntry; +typedef struct MonoSymbolFileMethodAddress MonoSymbolFileMethodAddress; +typedef struct MonoSymbolFileDynamicTable MonoSymbolFileDynamicTable; +typedef struct MonoSymbolFileSourceEntry MonoSymbolFileSourceEntry; +typedef struct MonoSymbolFileMethodEntry MonoSymbolFileMethodEntry; + +/* Keep in sync with OffsetTable in mcs/class/Mono.CSharp.Debugger/MonoSymbolTable.cs */ +struct MonoSymbolFileOffsetTable { + uint32_t _total_file_size; + uint32_t _data_section_offset; + uint32_t _data_section_size; + uint32_t _compile_unit_count; + uint32_t _compile_unit_table_offset; + uint32_t _compile_unit_table_size; + uint32_t _source_count; + uint32_t _source_table_offset; + uint32_t _source_table_size; + uint32_t _method_count; + uint32_t _method_table_offset; + uint32_t _method_table_size; + uint32_t _type_count; + uint32_t _anonymous_scope_count; + uint32_t _anonymous_scope_table_offset; + uint32_t _anonymous_scope_table_size; + uint32_t _line_number_table_line_base; + uint32_t _line_number_table_line_range; + uint32_t _line_number_table_opcode_base; + uint32_t _is_aspx_source; +}; + +struct MonoSymbolFileSourceEntry { + uint32_t _index; + uint32_t _data_offset; +}; + +struct MonoSymbolFileMethodEntry { + uint32_t _token; + uint32_t _data_offset; + uint32_t _line_number_table; +}; + +struct MonoSymbolFileMethodAddress { + uint32_t size; + const uint8_t *start_address; + const uint8_t *end_address; + const uint8_t *method_start_address; + const uint8_t *method_end_address; + const uint8_t *wrapper_address; + uint32_t has_this; + uint32_t num_params; + uint32_t variable_table_offset; + uint32_t type_table_offset; + uint32_t num_line_numbers; + uint32_t line_number_offset; + uint8_t data [MONO_ZERO_LEN_ARRAY]; +}; + +struct _MonoDebugMethodInfo { + MonoMethod *method; + MonoDebugHandle *handle; + uint32_t index; + uint32_t data_offset; + uint32_t lnt_offset; +}; + +typedef struct { + int parent; + int type; + /* IL offsets */ + int start_offset, end_offset; +} MonoDebugCodeBlock; + +typedef struct { + char *name; + int index; + /* Might be null for the main scope */ + MonoDebugCodeBlock *block; +} MonoDebugLocalVar; + +/* + * Information about local variables retrieved from a symbol file. + */ +struct _MonoDebugLocalsInfo { + int num_locals; + MonoDebugLocalVar *locals; + int num_blocks; + MonoDebugCodeBlock *code_blocks; +}; + +struct _MonoDebugLineNumberEntry { + uint32_t il_offset; + uint32_t native_offset; +}; + +#define MONO_SYMBOL_FILE_MAJOR_VERSION 50 +#define MONO_SYMBOL_FILE_MINOR_VERSION 0 +#define MONO_SYMBOL_FILE_MAGIC 0x45e82623fd7fa614ULL + +MONO_BEGIN_DECLS + +MonoSymbolFile * +mono_debug_open_mono_symbols (MonoDebugHandle *handle, + const uint8_t *raw_contents, + int size, + mono_bool in_the_debugger); + +void +mono_debug_close_mono_symbol_file (MonoSymbolFile *symfile); + +mono_bool +mono_debug_symfile_is_loaded (MonoSymbolFile *symfile); + +MonoDebugSourceLocation * +mono_debug_symfile_lookup_location (MonoDebugMethodInfo *minfo, + uint32_t offset); + +void +mono_debug_symfile_free_location (MonoDebugSourceLocation *location); + +int32_t +_mono_debug_address_from_il_offset (MonoDebugMethodJitInfo *jit, + uint32_t il_offset); + +MonoDebugMethodInfo * +mono_debug_symfile_lookup_method (MonoDebugHandle *handle, + MonoMethod *method); + +MonoDebugLocalsInfo* +mono_debug_symfile_lookup_locals (MonoDebugMethodInfo *minfo); + +void +mono_debug_symfile_free_locals (MonoDebugLocalsInfo *info); + +void +mono_debug_symfile_get_line_numbers (MonoDebugMethodInfo *minfo, char **source_file, int *n_il_offsets, int **il_offsets, int **line_numbers); + +MONO_END_DECLS + +#endif /* __MONO_SYMFILE_H__ */ + diff --git a/sampdotnethook/include/mono/metadata/environment.h b/sampdotnethook/include/mono/metadata/environment.h new file mode 100644 index 0000000..619249a --- /dev/null +++ b/sampdotnethook/include/mono/metadata/environment.h @@ -0,0 +1,22 @@ +/* + * environment.h: System.Environment support internal calls + * + * Author: + * Dick Porter (dick@ximian.com) + * + * (C) 2002 Ximian, Inc + */ + +#ifndef _MONO_METADATA_ENVIRONMENT_H_ +#define _MONO_METADATA_ENVIRONMENT_H_ + +#include + +MONO_BEGIN_DECLS + +extern int32_t mono_environment_exitcode_get (void); +extern void mono_environment_exitcode_set (int32_t value); + +MONO_END_DECLS + +#endif /* _MONO_METADATA_ENVIRONMENT_H_ */ diff --git a/sampdotnethook/include/mono/metadata/exception.h b/sampdotnethook/include/mono/metadata/exception.h new file mode 100644 index 0000000..fa17fa2 --- /dev/null +++ b/sampdotnethook/include/mono/metadata/exception.h @@ -0,0 +1,150 @@ +#ifndef _MONO_METADATA_EXCEPTION_H_ +#define _MONO_METADATA_EXCEPTION_H_ + +/* here for compat: should not be used anymore */ +#define MONO_ARCH_SAVE_REGS + +#include +#include + +MONO_BEGIN_DECLS + +extern MonoException * +mono_exception_from_name (MonoImage *image, + const char* name_space, + const char *name); + +MonoException * +mono_exception_from_token (MonoImage *image, uint32_t token); + +MonoException * +mono_exception_from_name_two_strings (MonoImage *image, const char *name_space, + const char *name, MonoString *a1, MonoString *a2); + +MonoException * +mono_exception_from_name_msg (MonoImage *image, const char *name_space, + const char *name, const char *msg); + +MonoException * +mono_exception_from_token_two_strings (MonoImage *image, uint32_t token, + MonoString *a1, MonoString *a2); + +extern MonoException * +mono_exception_from_name_domain (MonoDomain *domain, MonoImage *image, + const char* name_space, + const char *name); + +MonoException * +mono_get_exception_divide_by_zero (void); + +MonoException * +mono_get_exception_security (void); + +MonoException * +mono_get_exception_arithmetic (void); + +MonoException * +mono_get_exception_overflow (void); + +MonoException * +mono_get_exception_null_reference (void); + +MonoException * +mono_get_exception_execution_engine (const char *msg); + +MonoException * +mono_get_exception_thread_abort (void); + +MonoException * +mono_get_exception_thread_state (const char *msg); + +MonoException * +mono_get_exception_thread_interrupted (void); + +MonoException * +mono_get_exception_serialization (const char *msg); + +MonoException * +mono_get_exception_invalid_cast (void); + +MonoException * +mono_get_exception_invalid_operation (const char *msg); + +MonoException * +mono_get_exception_index_out_of_range (void); + +MonoException * +mono_get_exception_array_type_mismatch (void); + +MonoException * +mono_get_exception_type_load (MonoString *class_name, char *assembly_name); + +MonoException * +mono_get_exception_missing_method (const char *class_name, const char *member_name); + +MonoException * +mono_get_exception_missing_field (const char *class_name, const char *member_name); + +MonoException * +mono_get_exception_not_implemented (const char *msg); + +MonoException * +mono_get_exception_not_supported (const char *msg); + +MonoException* +mono_get_exception_argument_null (const char *arg); + +MonoException * +mono_get_exception_argument (const char *arg, const char *msg); + +MonoException * +mono_get_exception_argument_out_of_range (const char *arg); + +MonoException * +mono_get_exception_io (const char *msg); + +MonoException * +mono_get_exception_file_not_found (MonoString *fname); + +MonoException * +mono_get_exception_file_not_found2 (const char *msg, MonoString *fname); + +MonoException * +mono_get_exception_type_initialization (const char *type_name, MonoException *inner); + +MonoException * +mono_get_exception_synchronization_lock (const char *msg); + +MonoException * +mono_get_exception_cannot_unload_appdomain (const char *msg); + +MonoException * +mono_get_exception_appdomain_unloaded (void); + +MonoException * +mono_get_exception_bad_image_format (const char *msg); + +MonoException * +mono_get_exception_bad_image_format2 (const char *msg, MonoString *fname); + +MonoException * +mono_get_exception_stack_overflow (void); + +MonoException * +mono_get_exception_out_of_memory (void); + +MonoException * +mono_get_exception_field_access (void); + +MonoException * +mono_get_exception_method_access (void); + +MonoException * +mono_get_exception_reflection_type_load (MonoArray *types, MonoArray *exceptions); + +MonoException * +mono_get_exception_runtime_wrapped (MonoObject *wrapped_exception); + +MONO_END_DECLS + +#endif /* _MONO_METADATA_EXCEPTION_H_ */ diff --git a/sampdotnethook/include/mono/metadata/image.h b/sampdotnethook/include/mono/metadata/image.h new file mode 100644 index 0000000..66d1dda --- /dev/null +++ b/sampdotnethook/include/mono/metadata/image.h @@ -0,0 +1,83 @@ +#ifndef _MONONET_METADATA_IMAGE_H_ +#define _MONONET_METADATA_IMAGE_H_ + +#include +#include "../utils/mono-publib.h" + +MONO_BEGIN_DECLS + +typedef struct _MonoImage MonoImage; +typedef struct _MonoAssembly MonoAssembly; +typedef struct _MonoAssemblyName MonoAssemblyName; +typedef struct _MonoTableInfo MonoTableInfo; + +typedef enum { + MONO_IMAGE_OK, + MONO_IMAGE_ERROR_ERRNO, + MONO_IMAGE_MISSING_ASSEMBLYREF, + MONO_IMAGE_IMAGE_INVALID +} MonoImageOpenStatus; + +void mono_images_init (void); +void mono_images_cleanup (void); + +MonoImage *mono_image_open (const char *fname, + MonoImageOpenStatus *status); +MonoImage *mono_image_open_full (const char *fname, + MonoImageOpenStatus *status, mono_bool refonly); +MonoImage *mono_pe_file_open (const char *fname, + MonoImageOpenStatus *status); +MonoImage *mono_image_open_from_data (char *data, uint32_t data_len, mono_bool need_copy, + MonoImageOpenStatus *status); +MonoImage *mono_image_open_from_data_full (char *data, uint32_t data_len, mono_bool need_copy, + MonoImageOpenStatus *status, mono_bool refonly); +MonoImage *mono_image_open_from_data_with_name (char *data, uint32_t data_len, mono_bool need_copy, + MonoImageOpenStatus *status, mono_bool refonly, const char *name); +void mono_image_fixup_vtable (MonoImage *image); +MonoImage *mono_image_loaded (const char *name); +MonoImage *mono_image_loaded_full (const char *name, mono_bool refonly); +MonoImage *mono_image_loaded_by_guid (const char *guid); +MonoImage *mono_image_loaded_by_guid_full (const char *guid, mono_bool refonly); +void mono_image_init (MonoImage *image); +void mono_image_close (MonoImage *image); +void mono_image_addref (MonoImage *image); +const char *mono_image_strerror (MonoImageOpenStatus status); + +int mono_image_ensure_section (MonoImage *image, + const char *section); +int mono_image_ensure_section_idx (MonoImage *image, + int section); + +uint32_t mono_image_get_entry_point (MonoImage *image); +const char *mono_image_get_resource (MonoImage *image, uint32_t offset, uint32_t *size); +MonoImage* mono_image_load_file_for_image (MonoImage *image, int fileidx); + +MonoImage* mono_image_load_module (MonoImage *image, int idx); + +const char* mono_image_get_name (MonoImage *image); +const char* mono_image_get_filename (MonoImage *image); +const char * mono_image_get_guid (MonoImage *image); +MonoAssembly* mono_image_get_assembly (MonoImage *image); +mono_bool mono_image_is_dynamic (MonoImage *image); +char* mono_image_rva_map (MonoImage *image, uint32_t rva); + +const MonoTableInfo *mono_image_get_table_info (MonoImage *image, int table_id); +int mono_image_get_table_rows (MonoImage *image, int table_id); +int mono_table_info_get_rows (const MonoTableInfo *table); + +/* This actually returns a MonoPEResourceDataEntry *, but declaring it + * causes an include file loop. + */ +void* mono_image_lookup_resource (MonoImage *image, uint32_t res_id, + uint32_t lang_id, mono_unichar2 *name); + +const char* mono_image_get_public_key (MonoImage *image, uint32_t *size); +const char* mono_image_get_strong_name (MonoImage *image, uint32_t *size); +uint32_t mono_image_strong_name_position (MonoImage *image, uint32_t *size); +void mono_image_add_to_name_cache (MonoImage *image, + const char *nspace, const char *name, uint32_t idx); +mono_bool mono_image_has_authenticode_entry (MonoImage *image); + +MONO_END_DECLS + +#endif diff --git a/sampdotnethook/include/mono/metadata/loader.h b/sampdotnethook/include/mono/metadata/loader.h new file mode 100644 index 0000000..d33f7a4 --- /dev/null +++ b/sampdotnethook/include/mono/metadata/loader.h @@ -0,0 +1,93 @@ +#ifndef _MONO_METADATA_LOADER_H_ +#define _MONO_METADATA_LOADER_H_ 1 + +#include "metadata.h" +#include "image.h" + +MONO_BEGIN_DECLS + +typedef mono_bool (*MonoStackWalk) (MonoMethod *method, int32_t native_offset, int32_t il_offset, mono_bool managed, void* data); + +MonoMethod * +mono_get_method (MonoImage *image, uint32_t token, MonoClass *klass); + +MonoMethod * +mono_get_method_full (MonoImage *image, uint32_t token, MonoClass *klass, + MonoGenericContext *context); + +MonoMethod * +mono_get_method_constrained (MonoImage *image, uint32_t token, MonoClass *constrained_class, + MonoGenericContext *context, MonoMethod **cil_method); + +void +mono_free_method (MonoMethod *method); + +MonoMethodSignature* +mono_method_get_signature_full (MonoMethod *method, MonoImage *image, uint32_t token, + MonoGenericContext *context); + +MonoMethodSignature* +mono_method_get_signature (MonoMethod *method, MonoImage *image, uint32_t token); + +MonoMethodSignature* +mono_method_signature (MonoMethod *method); + +MonoMethodHeader* +mono_method_get_header (MonoMethod *method); + +const char* +mono_method_get_name (MonoMethod *method); + +MonoClass* +mono_method_get_class (MonoMethod *method); + +uint32_t +mono_method_get_token (MonoMethod *method); + +uint32_t +mono_method_get_flags (MonoMethod *method, uint32_t *iflags); + +uint32_t +mono_method_get_index (MonoMethod *method); + +MonoImage * +mono_load_image (const char *fname, MonoImageOpenStatus *status); + +void +mono_add_internal_call (const char *name, const void* method); + +void* +mono_lookup_internal_call (MonoMethod *method); + +void +mono_dllmap_insert (MonoImage *assembly, const char *dll, const char *func, const char *tdll, const char *tfunc); + +void* +mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char **exc_arg); + +void +mono_method_get_param_names (MonoMethod *method, const char **names); + +uint32_t +mono_method_get_param_token (MonoMethod *method, int idx); + +void +mono_method_get_marshal_info (MonoMethod *method, MonoMarshalSpec **mspecs); + +mono_bool +mono_method_has_marshal_info (MonoMethod *method); + +MonoMethod* +mono_method_get_last_managed (void); + +void +mono_stack_walk (MonoStackWalk func, void* user_data); + +/* Use this if the IL offset is not needed: it's faster */ +void +mono_stack_walk_no_il (MonoStackWalk func, void* user_data); + +MONO_END_DECLS + +#endif + diff --git a/sampdotnethook/include/mono/metadata/metadata.h b/sampdotnethook/include/mono/metadata/metadata.h new file mode 100644 index 0000000..31f194d --- /dev/null +++ b/sampdotnethook/include/mono/metadata/metadata.h @@ -0,0 +1,499 @@ + +#ifndef __MONO_METADATA_H__ +#define __MONO_METADATA_H__ + +#include "../utils/mono-publib.h" + +#include "blob.h" +#include "row-indexes.h" +#include "image.h" + +MONO_BEGIN_DECLS + +/* + * When embedding, you have to define MONO_ZERO_LEN_ARRAY before including any + * other Mono header file if you use a different compiler from the one used to + * build Mono. + */ +#ifndef MONO_ZERO_LEN_ARRAY +#ifdef __GNUC__ +#define MONO_ZERO_LEN_ARRAY 0 +#else +#define MONO_ZERO_LEN_ARRAY 1 +#endif +#endif + +#define MONO_TYPE_ISSTRUCT(t) mono_type_is_struct (t) +#define MONO_TYPE_IS_VOID(t) mono_type_is_void (t) +#define MONO_TYPE_IS_POINTER(t) mono_type_is_pointer (t) +#define MONO_TYPE_IS_REFERENCE(t) mono_type_is_reference (t) + +#define MONO_CLASS_IS_INTERFACE(c) ((c->flags & TYPE_ATTRIBUTE_INTERFACE) || (c->byval_arg.type == MONO_TYPE_VAR) || (c->byval_arg.type == MONO_TYPE_MVAR)) + +#define MONO_CLASS_IS_IMPORT(c) ((c->flags & TYPE_ATTRIBUTE_IMPORT)) + +typedef struct _MonoClass MonoClass; +typedef struct _MonoDomain MonoDomain; +typedef struct _MonoMethod MonoMethod; + +typedef enum { + MONO_EXCEPTION_CLAUSE_NONE, + MONO_EXCEPTION_CLAUSE_FILTER, + MONO_EXCEPTION_CLAUSE_FINALLY, + MONO_EXCEPTION_CLAUSE_FAULT = 4 +} MonoExceptionEnum; + +typedef enum { + MONO_CALL_DEFAULT, + MONO_CALL_C, + MONO_CALL_STDCALL, + MONO_CALL_THISCALL, + MONO_CALL_FASTCALL, + MONO_CALL_VARARG +} MonoCallConvention; + +/* ECMA lamespec: the old spec had more info... */ +typedef enum { + MONO_NATIVE_BOOLEAN = 0x02, /* 4 bytes, 0 is false, != 0 is true */ + MONO_NATIVE_I1 = 0x03, + MONO_NATIVE_U1 = 0x04, + MONO_NATIVE_I2 = 0x05, + MONO_NATIVE_U2 = 0x06, + MONO_NATIVE_I4 = 0x07, + MONO_NATIVE_U4 = 0x08, + MONO_NATIVE_I8 = 0x09, + MONO_NATIVE_U8 = 0x0a, + MONO_NATIVE_R4 = 0x0b, + MONO_NATIVE_R8 = 0x0c, + MONO_NATIVE_CURRENCY = 0x0f, + MONO_NATIVE_BSTR = 0x13, /* prefixed length, Unicode */ + MONO_NATIVE_LPSTR = 0x14, /* ANSI, null terminated */ + MONO_NATIVE_LPWSTR = 0x15, /* UNICODE, null terminated */ + MONO_NATIVE_LPTSTR = 0x16, /* plattform dep., null terminated */ + MONO_NATIVE_BYVALTSTR = 0x17, + MONO_NATIVE_IUNKNOWN = 0x19, + MONO_NATIVE_IDISPATCH = 0x1a, + MONO_NATIVE_STRUCT = 0x1b, + MONO_NATIVE_INTERFACE = 0x1c, + MONO_NATIVE_SAFEARRAY = 0x1d, + MONO_NATIVE_BYVALARRAY = 0x1e, + MONO_NATIVE_INT = 0x1f, + MONO_NATIVE_UINT = 0x20, + MONO_NATIVE_VBBYREFSTR = 0x22, + MONO_NATIVE_ANSIBSTR = 0x23, /* prefixed length, ANSI */ + MONO_NATIVE_TBSTR = 0x24, /* prefixed length, plattform dep. */ + MONO_NATIVE_VARIANTBOOL = 0x25, + MONO_NATIVE_FUNC = 0x26, + MONO_NATIVE_ASANY = 0x28, + MONO_NATIVE_LPARRAY = 0x2a, + MONO_NATIVE_LPSTRUCT = 0x2b, + MONO_NATIVE_CUSTOM = 0x2c, + MONO_NATIVE_ERROR = 0x2d, + MONO_NATIVE_MAX = 0x50 /* no info */ +} MonoMarshalNative; + +/* Used only in context of SafeArray */ +typedef enum { + MONO_VARIANT_EMPTY = 0x00, + MONO_VARIANT_NULL = 0x01, + MONO_VARIANT_I2 = 0x02, + MONO_VARIANT_I4 = 0x03, + MONO_VARIANT_R4 = 0x04, + MONO_VARIANT_R8 = 0x05, + MONO_VARIANT_CY = 0x06, + MONO_VARIANT_DATE = 0x07, + MONO_VARIANT_BSTR = 0x08, + MONO_VARIANT_DISPATCH = 0x09, + MONO_VARIANT_ERROR = 0x0a, + MONO_VARIANT_BOOL = 0x0b, + MONO_VARIANT_VARIANT = 0x0c, + MONO_VARIANT_UNKNOWN = 0x0d, + MONO_VARIANT_DECIMAL = 0x0e, + MONO_VARIANT_I1 = 0x10, + MONO_VARIANT_UI1 = 0x11, + MONO_VARIANT_UI2 = 0x12, + MONO_VARIANT_UI4 = 0x13, + MONO_VARIANT_I8 = 0x14, + MONO_VARIANT_UI8 = 0x15, + MONO_VARIANT_INT = 0x16, + MONO_VARIANT_UINT = 0x17, + MONO_VARIANT_VOID = 0x18, + MONO_VARIANT_HRESULT = 0x19, + MONO_VARIANT_PTR = 0x1a, + MONO_VARIANT_SAFEARRAY = 0x1b, + MONO_VARIANT_CARRAY = 0x1c, + MONO_VARIANT_USERDEFINED = 0x1d, + MONO_VARIANT_LPSTR = 0x1e, + MONO_VARIANT_LPWSTR = 0x1f, + MONO_VARIANT_RECORD = 0x24, + MONO_VARIANT_FILETIME = 0x40, + MONO_VARIANT_BLOB = 0x41, + MONO_VARIANT_STREAM = 0x42, + MONO_VARIANT_STORAGE = 0x43, + MONO_VARIANT_STREAMED_OBJECT = 0x44, + MONO_VARIANT_STORED_OBJECT = 0x45, + MONO_VARIANT_BLOB_OBJECT = 0x46, + MONO_VARIANT_CF = 0x47, + MONO_VARIANT_CLSID = 0x48, + MONO_VARIANT_VECTOR = 0x1000, + MONO_VARIANT_ARRAY = 0x2000, + MONO_VARIANT_BYREF = 0x4000 +} MonoMarshalVariant; + +typedef enum { + MONO_MARSHAL_CONV_NONE, + MONO_MARSHAL_CONV_BOOL_VARIANTBOOL, + MONO_MARSHAL_CONV_BOOL_I4, + MONO_MARSHAL_CONV_STR_BSTR, + MONO_MARSHAL_CONV_STR_LPSTR, + MONO_MARSHAL_CONV_LPSTR_STR, + MONO_MARSHAL_CONV_LPTSTR_STR, + MONO_MARSHAL_CONV_STR_LPWSTR, + MONO_MARSHAL_CONV_LPWSTR_STR, + MONO_MARSHAL_CONV_STR_LPTSTR, + MONO_MARSHAL_CONV_STR_ANSIBSTR, + MONO_MARSHAL_CONV_STR_TBSTR, + MONO_MARSHAL_CONV_STR_BYVALSTR, + MONO_MARSHAL_CONV_STR_BYVALWSTR, + MONO_MARSHAL_CONV_SB_LPSTR, + MONO_MARSHAL_CONV_SB_LPTSTR, + MONO_MARSHAL_CONV_SB_LPWSTR, + MONO_MARSHAL_CONV_LPSTR_SB, + MONO_MARSHAL_CONV_LPTSTR_SB, + MONO_MARSHAL_CONV_LPWSTR_SB, + MONO_MARSHAL_CONV_ARRAY_BYVALARRAY, + MONO_MARSHAL_CONV_ARRAY_BYVALCHARARRAY, + MONO_MARSHAL_CONV_ARRAY_SAVEARRAY, + MONO_MARSHAL_CONV_ARRAY_LPARRAY, + MONO_MARSHAL_FREE_LPARRAY, + MONO_MARSHAL_CONV_OBJECT_INTERFACE, + MONO_MARSHAL_CONV_OBJECT_IDISPATCH, + MONO_MARSHAL_CONV_OBJECT_IUNKNOWN, + MONO_MARSHAL_CONV_OBJECT_STRUCT, + MONO_MARSHAL_CONV_DEL_FTN, + MONO_MARSHAL_CONV_FTN_DEL, + MONO_MARSHAL_FREE_ARRAY, + MONO_MARSHAL_CONV_BSTR_STR, + MONO_MARSHAL_CONV_SAFEHANDLE, + MONO_MARSHAL_CONV_HANDLEREF +} MonoMarshalConv; + +typedef struct { + MonoMarshalNative native; + union { + struct { + MonoMarshalNative elem_type; + int32_t num_elem; /* -1 if not set */ + int16_t param_num; /* -1 if not set */ + int16_t elem_mult; /* -1 if not set */ + } array_data; + struct { + char *custom_name; + char *cookie; + } custom_data; + struct { + MonoMarshalVariant elem_type; + int32_t num_elem; + } safearray_data; + } data; +} MonoMarshalSpec; + +void mono_metadata_init (void); + +void mono_metadata_decode_row (const MonoTableInfo *t, + int idx, + uint32_t *res, + int res_size); + +uint32_t mono_metadata_decode_row_col (const MonoTableInfo *t, + int idx, + unsigned int col); + +/* + * This macro is used to extract the size of the table encoded in + * the size_bitfield of MonoTableInfo. + */ +#define mono_metadata_table_size(bitfield,table) ((((bitfield) >> ((table)*2)) & 0x3) + 1) +#define mono_metadata_table_count(bitfield) ((bitfield) >> 24) + +int mono_metadata_compute_size (MonoImage *meta, + int tableindex, + uint32_t *result_bitfield); + +/* + * + */ +const char *mono_metadata_locate (MonoImage *meta, int table, int idx); +const char *mono_metadata_locate_token (MonoImage *meta, uint32_t token); + +const char *mono_metadata_string_heap (MonoImage *meta, uint32_t table_index); +const char *mono_metadata_blob_heap (MonoImage *meta, uint32_t table_index); +const char *mono_metadata_user_string (MonoImage *meta, uint32_t table_index); +const char *mono_metadata_guid_heap (MonoImage *meta, uint32_t table_index); + +uint32_t mono_metadata_typedef_from_field (MonoImage *meta, uint32_t table_index); +uint32_t mono_metadata_typedef_from_method (MonoImage *meta, uint32_t table_index); +uint32_t mono_metadata_nested_in_typedef (MonoImage *meta, uint32_t table_index); +uint32_t mono_metadata_nesting_typedef (MonoImage *meta, uint32_t table_index, uint32_t start_index); + +MonoClass** mono_metadata_interfaces_from_typedef (MonoImage *meta, uint32_t table_index, unsigned int *count); + +uint32_t mono_metadata_events_from_typedef (MonoImage *meta, uint32_t table_index, unsigned int *end_idx); +uint32_t mono_metadata_methods_from_event (MonoImage *meta, uint32_t table_index, unsigned int *end); +uint32_t mono_metadata_properties_from_typedef (MonoImage *meta, uint32_t table_index, unsigned int *end); +uint32_t mono_metadata_methods_from_property (MonoImage *meta, uint32_t table_index, unsigned int *end); +uint32_t mono_metadata_packing_from_typedef (MonoImage *meta, uint32_t table_index, uint32_t *packing, uint32_t *size); +const char* mono_metadata_get_marshal_info (MonoImage *meta, uint32_t idx, mono_bool is_field); +uint32_t mono_metadata_custom_attrs_from_index (MonoImage *meta, uint32_t cattr_index); + +MonoMarshalSpec *mono_metadata_parse_marshal_spec (MonoImage *image, const char *ptr); + +void mono_metadata_free_marshal_spec (MonoMarshalSpec *spec); + +uint32_t mono_metadata_implmap_from_method (MonoImage *meta, uint32_t method_idx); + +void mono_metadata_field_info (MonoImage *meta, + uint32_t table_index, + uint32_t *offset, + uint32_t *rva, + MonoMarshalSpec **marshal_spec); + +uint32_t mono_metadata_get_constant_index (MonoImage *meta, uint32_t token, uint32_t hint); + +/* + * Functions to extract information from the Blobs + */ +uint32_t mono_metadata_decode_value (const char *ptr, + const char **rptr); +int32_t mono_metadata_decode_signed_value (const char *ptr, const char **rptr); + +uint32_t mono_metadata_decode_blob_size (const char *ptr, + const char **rptr); + +void mono_metadata_encode_value (uint32_t value, char *bug, char **endbuf); + +#define MONO_OFFSET_IN_CLAUSE(clause,offset) \ + ((clause)->try_offset <= (offset) && (offset) < ((clause)->try_offset + (clause)->try_len)) +#define MONO_OFFSET_IN_HANDLER(clause,offset) \ + ((clause)->handler_offset <= (offset) && (offset) < ((clause)->handler_offset + (clause)->handler_len)) +#define MONO_OFFSET_IN_FILTER(clause,offset) \ + ((clause)->flags == MONO_EXCEPTION_CLAUSE_FILTER && (clause)->data.filter_offset <= (offset) && (offset) < ((clause)->handler_offset)) + +typedef struct { + uint32_t flags; + uint32_t try_offset; + uint32_t try_len; + uint32_t handler_offset; + uint32_t handler_len; + union { + uint32_t filter_offset; + MonoClass *catch_class; + } data; +} MonoExceptionClause; + +typedef struct _MonoType MonoType; +typedef struct _MonoGenericInst MonoGenericInst; +typedef struct _MonoGenericClass MonoGenericClass; +typedef struct _MonoDynamicGenericClass MonoDynamicGenericClass; +typedef struct _MonoGenericContext MonoGenericContext; +typedef struct _MonoGenericContainer MonoGenericContainer; +typedef struct _MonoGenericParam MonoGenericParam; +typedef struct _MonoArrayType MonoArrayType; +typedef struct _MonoMethodSignature MonoMethodSignature; + +/* FIXME: Keeping this name alive for now, since it is part of the exposed API, even though no entrypoint uses it. */ +typedef struct invalid_name MonoGenericMethod; + +typedef struct { + unsigned int required : 1; + unsigned int token : 31; +} MonoCustomMod; + +struct _MonoArrayType { + MonoClass *eklass; + uint8_t rank; + uint8_t numsizes; + uint8_t numlobounds; + int *sizes; + int *lobounds; +}; + +typedef struct _MonoMethodHeader MonoMethodHeader; + +typedef enum { + MONO_PARSE_TYPE, + MONO_PARSE_MOD_TYPE, + MONO_PARSE_LOCAL, + MONO_PARSE_PARAM, + MONO_PARSE_RET, + MONO_PARSE_FIELD +} MonoParseTypeMode; + +mono_bool +mono_type_is_byref (MonoType *type); + +int +mono_type_get_type (MonoType *type); + +/* For MONO_TYPE_FNPTR */ +MonoMethodSignature* +mono_type_get_signature (MonoType *type); + +/* For MONO_TYPE_CLASS, VALUETYPE */ +MonoClass* +mono_type_get_class (MonoType *type); + +MonoArrayType* +mono_type_get_array_type (MonoType *type); + +/* For MONO_TYPE_PTR */ +MonoType* +mono_type_get_ptr_type (MonoType *type); + +MonoClass* +mono_type_get_modifiers (MonoType *type, mono_bool *is_required, void **iter); + +mono_bool mono_type_is_struct (MonoType *type); +mono_bool mono_type_is_void (MonoType *type); +mono_bool mono_type_is_pointer (MonoType *type); +mono_bool mono_type_is_reference (MonoType *type); + +MonoType* +mono_signature_get_return_type (MonoMethodSignature *sig); + +MonoType* +mono_signature_get_params (MonoMethodSignature *sig, void **iter); + +uint32_t +mono_signature_get_param_count (MonoMethodSignature *sig); + +uint32_t +mono_signature_get_call_conv (MonoMethodSignature *sig); + +int +mono_signature_vararg_start (MonoMethodSignature *sig); + +mono_bool +mono_signature_is_instance (MonoMethodSignature *sig); + +mono_bool +mono_signature_explicit_this (MonoMethodSignature *sig); + +uint32_t mono_metadata_parse_typedef_or_ref (MonoImage *m, + const char *ptr, + const char **rptr); +int mono_metadata_parse_custom_mod (MonoImage *m, + MonoCustomMod *dest, + const char *ptr, + const char **rptr); +MonoArrayType *mono_metadata_parse_array (MonoImage *m, + const char *ptr, + const char **rptr); +void mono_metadata_free_array (MonoArrayType *array); +MonoType *mono_metadata_parse_type (MonoImage *m, + MonoParseTypeMode mode, + short opt_attrs, + const char *ptr, + const char **rptr); +MonoType *mono_metadata_parse_param (MonoImage *m, + const char *ptr, + const char **rptr); +MonoType *mono_metadata_parse_ret_type (MonoImage *m, + const char *ptr, + const char **rptr); +MonoType *mono_metadata_parse_field_type (MonoImage *m, + short field_flags, + const char *ptr, + const char **rptr); +MonoType *mono_type_create_from_typespec (MonoImage *image, + uint32_t type_spec); +void mono_metadata_free_type (MonoType *type); +int mono_type_size (MonoType *type, + int *alignment); +int mono_type_stack_size (MonoType *type, + int *alignment); + +mono_bool mono_type_generic_inst_is_valuetype (MonoType *type); +mono_bool mono_metadata_generic_class_is_valuetype (MonoGenericClass *gclass); +unsigned int mono_metadata_generic_class_hash (MonoGenericClass *gclass); +mono_bool mono_metadata_generic_class_equal (MonoGenericClass *g1, MonoGenericClass *g2); + +unsigned int mono_metadata_type_hash (MonoType *t1); +mono_bool mono_metadata_type_equal (MonoType *t1, MonoType *t2); + +MonoMethodSignature *mono_metadata_signature_alloc (MonoImage *image, uint32_t nparams); + +MonoMethodSignature *mono_metadata_signature_dup (MonoMethodSignature *sig); + +MonoMethodSignature *mono_metadata_parse_signature (MonoImage *image, + uint32_t token); + +MonoMethodSignature *mono_metadata_parse_method_signature (MonoImage *m, + int def, + const char *ptr, + const char **rptr); +void mono_metadata_free_method_signature (MonoMethodSignature *method); + +mono_bool mono_metadata_signature_equal (MonoMethodSignature *sig1, + MonoMethodSignature *sig2); + +unsigned int mono_signature_hash (MonoMethodSignature *sig); + +MonoMethodHeader *mono_metadata_parse_mh (MonoImage *m, const char *ptr); +void mono_metadata_free_mh (MonoMethodHeader *mh); + +/* MonoMethodHeader acccessors */ +const unsigned char* +mono_method_header_get_code (MonoMethodHeader *header, uint32_t* code_size, uint32_t* max_stack); + +MonoType** +mono_method_header_get_locals (MonoMethodHeader *header, uint32_t* num_locals, mono_bool *init_locals); + +int +mono_method_header_get_num_clauses (MonoMethodHeader *header); + +int +mono_method_header_get_clauses (MonoMethodHeader *header, MonoMethod *method, void **iter, MonoExceptionClause *clause); + +uint32_t +mono_type_to_unmanaged (MonoType *type, MonoMarshalSpec *mspec, + mono_bool as_field, mono_bool unicode, MonoMarshalConv *conv); + +/* + * Makes a token based on a table and an index + */ +#define mono_metadata_make_token(table,idx) (((table) << 24)| (idx)) + +/* + * Returns the table index that this token encodes. + */ +#define mono_metadata_token_table(token) ((token) >> 24) + + /* + * Returns the index that a token refers to + */ +#define mono_metadata_token_index(token) ((token & 0xffffff)) + + +#define mono_metadata_token_code(token) ((token & 0xff000000)) + +uint32_t mono_metadata_token_from_dor (uint32_t dor_index); + +char *mono_guid_to_string (const uint8_t *guid); + +uint32_t mono_metadata_declsec_from_index (MonoImage *meta, uint32_t idx); + +uint32_t mono_metadata_translate_token_index (MonoImage *image, int table, uint32_t idx); + +void mono_metadata_decode_table_row (MonoImage *image, int table, + int idx, + uint32_t *res, + int res_size); + +uint32_t mono_metadata_decode_table_row_col (MonoImage *image, int table, + int idx, + unsigned int col); + +MONO_END_DECLS + +#endif /* __MONO_METADATA_H__ */ diff --git a/sampdotnethook/include/mono/metadata/mono-config.h b/sampdotnethook/include/mono/metadata/mono-config.h new file mode 100644 index 0000000..0b46425 --- /dev/null +++ b/sampdotnethook/include/mono/metadata/mono-config.h @@ -0,0 +1,31 @@ +/* + * mono-config.h + * + * Author: Paolo Molaro (lupus@ximian.com) + * + * (C) 2002 Ximian, Inc. + */ +#ifndef __MONO_METADATA_CONFIG_H__ +#define __MONO_METADATA_CONFIG_H__ + +#include +#include + +MONO_BEGIN_DECLS + +const char* mono_get_config_dir (void); +void mono_set_config_dir (const char *dir); + +const char* mono_get_machine_config (void); + +void mono_config_cleanup (void); +void mono_config_parse (const char *filename); +void mono_config_for_assembly (MonoImage *assembly); +void mono_config_parse_memory (const char *buffer); + +const char* mono_config_string_for_assembly_file (const char *filename); + +MONO_END_DECLS + +#endif /* __MONO_METADATA_CONFIG_H__ */ + diff --git a/sampdotnethook/include/mono/metadata/mono-debug.h b/sampdotnethook/include/mono/metadata/mono-debug.h new file mode 100644 index 0000000..9494a79 --- /dev/null +++ b/sampdotnethook/include/mono/metadata/mono-debug.h @@ -0,0 +1,212 @@ +/* + * This header is only installed for use by the debugger: + * the structures and the API declared here are not supported. + */ + +#ifndef __MONO_DEBUG_H__ +#define __MONO_DEBUG_H__ + +#include +#include +#include + +MONO_BEGIN_DECLS + +typedef struct _MonoSymbolTable MonoSymbolTable; +typedef struct _MonoDebugDataTable MonoDebugDataTable; + +typedef struct _MonoSymbolFile MonoSymbolFile; + +typedef struct _MonoDebugHandle MonoDebugHandle; + +typedef struct _MonoDebugLineNumberEntry MonoDebugLineNumberEntry; + +typedef struct _MonoDebugVarInfo MonoDebugVarInfo; +typedef struct _MonoDebugMethodJitInfo MonoDebugMethodJitInfo; +typedef struct _MonoDebugMethodAddress MonoDebugMethodAddress; +typedef struct _MonoDebugMethodAddressList MonoDebugMethodAddressList; +typedef struct _MonoDebugClassEntry MonoDebugClassEntry; + +typedef struct _MonoDebugMethodInfo MonoDebugMethodInfo; +typedef struct _MonoDebugLocalsInfo MonoDebugLocalsInfo; +typedef struct _MonoDebugSourceLocation MonoDebugSourceLocation; + +typedef struct _MonoDebugList MonoDebugList; + +typedef enum { + MONO_DEBUG_FORMAT_NONE, + MONO_DEBUG_FORMAT_MONO, + MONO_DEBUG_FORMAT_DEBUGGER +} MonoDebugFormat; + +/* + * NOTE: + * We intentionally do not use GList here since the debugger needs to know about + * the layout of the fields. +*/ +struct _MonoDebugList { + MonoDebugList *next; + const void* data; +}; + +struct _MonoSymbolTable { + uint64_t magic; + uint32_t version; + uint32_t total_size; + + /* + * Corlib and metadata info. + */ + MonoDebugHandle *corlib; + MonoDebugDataTable *global_data_table; + MonoDebugList *data_tables; + + /* + * The symbol files. + */ + MonoDebugList *symbol_files; +}; + +struct _MonoDebugHandle { + uint32_t index; + char *image_file; + MonoImage *image; + MonoDebugDataTable *type_table; + MonoSymbolFile *symfile; +}; + +struct _MonoDebugMethodJitInfo { + const mono_byte *code_start; + uint32_t code_size; + uint32_t prologue_end; + uint32_t epilogue_begin; + const mono_byte *wrapper_addr; + uint32_t num_line_numbers; + MonoDebugLineNumberEntry *line_numbers; + uint32_t num_params; + MonoDebugVarInfo *this_var; + MonoDebugVarInfo *params; + uint32_t num_locals; + MonoDebugVarInfo *locals; +}; + +struct _MonoDebugMethodAddressList { + uint32_t size; + uint32_t count; + mono_byte data [MONO_ZERO_LEN_ARRAY]; +}; + +struct _MonoDebugSourceLocation { + char *source_file; + uint32_t row, column; + uint32_t il_offset; +}; + +/* + * These bits of the MonoDebugLocalInfo's "index" field are flags specifying + * where the variable is actually stored. + * + * See relocate_variable() in debug-symfile.c for more info. + */ +#define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS 0xf0000000 + +/* The variable is in register "index". */ +#define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER 0 + +/* The variable is at offset "offset" from register "index". */ +#define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET 0x10000000 + +/* The variable is in the two registers "offset" and "index". */ +#define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS 0x20000000 + +/* The variable is dead. */ +#define MONO_DEBUG_VAR_ADDRESS_MODE_DEAD 0x30000000 + +struct _MonoDebugVarInfo { + uint32_t index; + uint32_t offset; + uint32_t size; + uint32_t begin_scope; + uint32_t end_scope; + MonoType *type; +}; + +#define MONO_DEBUGGER_MAJOR_VERSION 81 +#define MONO_DEBUGGER_MINOR_VERSION 6 +#define MONO_DEBUGGER_MAGIC 0x7aff65af4253d427ULL + +extern MonoSymbolTable *mono_symbol_table; +extern MonoDebugFormat mono_debug_format; +extern int32_t mono_debug_debugger_version; +extern int32_t _mono_debug_using_mono_debugger; + +void mono_debug_list_add (MonoDebugList **list, const void* data); +void mono_debug_list_remove (MonoDebugList **list, const void* data); + +void mono_debug_init (MonoDebugFormat format); +void mono_debug_open_image_from_memory (MonoImage *image, const mono_byte *raw_contents, int size); +void mono_debug_cleanup (void); + +void mono_debug_close_image (MonoImage *image); + +void mono_debug_domain_unload (MonoDomain *domain); +void mono_debug_domain_create (MonoDomain *domain); + +mono_bool mono_debug_using_mono_debugger (void); + +MonoDebugMethodAddress * +mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDomain *domain); + +void +mono_debug_remove_method (MonoMethod *method, MonoDomain *domain); + +MonoDebugMethodInfo * +mono_debug_lookup_method (MonoMethod *method); + +MonoDebugMethodAddressList * +mono_debug_lookup_method_addresses (MonoMethod *method); + +MonoDebugMethodJitInfo* +mono_debug_find_method (MonoMethod *method, MonoDomain *domain); + +void +mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit); + + +void +mono_debug_add_delegate_trampoline (void* code, int size); + +MonoDebugLocalsInfo* +mono_debug_lookup_locals (MonoMethod *method); + +/* + * Line number support. + */ + +MonoDebugSourceLocation * +mono_debug_lookup_source_location (MonoMethod *method, uint32_t address, MonoDomain *domain); + +int32_t +mono_debug_il_offset_from_address (MonoMethod *method, MonoDomain *domain, uint32_t native_offset); + +void +mono_debug_free_source_location (MonoDebugSourceLocation *location); + +char * +mono_debug_print_stack_frame (MonoMethod *method, uint32_t native_offset, MonoDomain *domain); + +/* + * Mono Debugger support functions + * + * These methods are used by the JIT while running inside the Mono Debugger. + */ + +int mono_debugger_method_has_breakpoint (MonoMethod *method); +int mono_debugger_insert_breakpoint (const char *method_name, mono_bool include_namespace); + +void mono_set_is_debugger_attached (mono_bool attached); +mono_bool mono_is_debugger_attached (void); + +MONO_END_DECLS + +#endif /* __MONO_DEBUG_H__ */ diff --git a/sampdotnethook/include/mono/metadata/mono-gc.h b/sampdotnethook/include/mono/metadata/mono-gc.h new file mode 100644 index 0000000..f2ff92b --- /dev/null +++ b/sampdotnethook/include/mono/metadata/mono-gc.h @@ -0,0 +1,27 @@ +/* + * mono-gc.h: GC related public interface + * + */ +#ifndef __METADATA_MONO_GC_H__ +#define __METADATA_MONO_GC_H__ + +#include + +MONO_BEGIN_DECLS + +typedef int (*MonoGCReferences) (MonoObject *obj, MonoClass *klass, uintptr_t size, uintptr_t num, MonoObject **refs, uintptr_t *offsets, void *data); + +void mono_gc_collect (int generation); +int mono_gc_max_generation (void); +int mono_gc_get_generation (MonoObject *object); +int mono_gc_collection_count (int generation); +int64_t mono_gc_get_used_size (void); +int64_t mono_gc_get_heap_size (void); +int mono_gc_invoke_finalizers (void); +/* heap walking is only valid in the pre-stop-world event callback */ +int mono_gc_walk_heap (int flags, MonoGCReferences callback, void *data); + +MONO_END_DECLS + +#endif /* __METADATA_MONO_GC_H__ */ + diff --git a/sampdotnethook/include/mono/metadata/opcodes.h b/sampdotnethook/include/mono/metadata/opcodes.h new file mode 100644 index 0000000..1c553f1 --- /dev/null +++ b/sampdotnethook/include/mono/metadata/opcodes.h @@ -0,0 +1,76 @@ +#ifndef __MONO_METADATA_OPCODES_H__ +#define __MONO_METADATA_OPCODES_H__ + +/* + * opcodes.h: CIL instruction information + * + * Author: + * Paolo Molaro (lupus@ximian.com) + * + * (C) 2002 Ximian, Inc. + */ + +#include + +MONO_BEGIN_DECLS + +#define MONO_CUSTOM_PREFIX 0xf0 + +#define OPDEF(a,b,c,d,e,f,g,h,i,j) \ + MONO_ ## a, + +typedef enum { +#include "mono/cil/opcode.def" + MONO_CEE_LAST +} MonoOpcodeEnum; + +#undef OPDEF + +enum { + MONO_FLOW_NEXT, + MONO_FLOW_BRANCH, + MONO_FLOW_COND_BRANCH, + MONO_FLOW_ERROR, + MONO_FLOW_CALL, + MONO_FLOW_RETURN, + MONO_FLOW_META +}; + +enum { + MonoInlineNone, + MonoInlineType, + MonoInlineField, + MonoInlineMethod, + MonoInlineTok, + MonoInlineString, + MonoInlineSig, + MonoInlineVar, + MonoShortInlineVar, + MonoInlineBrTarget, + MonoShortInlineBrTarget, + MonoInlineSwitch, + MonoInlineR, + MonoShortInlineR, + MonoInlineI, + MonoShortInlineI, + MonoInlineI8 +}; + +typedef struct { + unsigned char argument; + unsigned char flow_type; + unsigned short opval; +} MonoOpcode; + +extern const MonoOpcode mono_opcodes []; + +const char* +mono_opcode_name (int opcode); + +MonoOpcodeEnum +mono_opcode_value (const mono_byte **ip, const mono_byte *end); + +MONO_END_DECLS + +#endif /* __MONO_METADATA_OPCODES_H__ */ + diff --git a/sampdotnethook/include/mono/metadata/profiler.h b/sampdotnethook/include/mono/metadata/profiler.h new file mode 100644 index 0000000..09299a7 --- /dev/null +++ b/sampdotnethook/include/mono/metadata/profiler.h @@ -0,0 +1,199 @@ +#ifndef __MONO_PROFILER_H__ +#define __MONO_PROFILER_H__ + +#include +#include + +MONO_BEGIN_DECLS + +#define MONO_PROFILER_MAX_STAT_CALL_CHAIN_DEPTH 128 + +typedef enum { + MONO_PROFILE_NONE = 0, + MONO_PROFILE_APPDOMAIN_EVENTS = 1 << 0, + MONO_PROFILE_ASSEMBLY_EVENTS = 1 << 1, + MONO_PROFILE_MODULE_EVENTS = 1 << 2, + MONO_PROFILE_CLASS_EVENTS = 1 << 3, + MONO_PROFILE_JIT_COMPILATION = 1 << 4, + MONO_PROFILE_INLINING = 1 << 5, + MONO_PROFILE_EXCEPTIONS = 1 << 6, + MONO_PROFILE_ALLOCATIONS = 1 << 7, + MONO_PROFILE_GC = 1 << 8, + MONO_PROFILE_THREADS = 1 << 9, + MONO_PROFILE_REMOTING = 1 << 10, + MONO_PROFILE_TRANSITIONS = 1 << 11, + MONO_PROFILE_ENTER_LEAVE = 1 << 12, + MONO_PROFILE_COVERAGE = 1 << 13, + MONO_PROFILE_INS_COVERAGE = 1 << 14, + MONO_PROFILE_STATISTICAL = 1 << 15, + MONO_PROFILE_METHOD_EVENTS = 1 << 16, + MONO_PROFILE_MONITOR_EVENTS = 1 << 17, + MONO_PROFILE_IOMAP_EVENTS = 1 << 18, /* this should likely be removed, too */ + MONO_PROFILE_GC_MOVES = 1 << 19, + MONO_PROFILE_GC_ROOTS = 1 << 20 +} MonoProfileFlags; + +typedef enum { + MONO_PROFILE_OK, + MONO_PROFILE_FAILED +} MonoProfileResult; + +typedef enum { + MONO_GC_EVENT_START, + MONO_GC_EVENT_MARK_START, + MONO_GC_EVENT_MARK_END, + MONO_GC_EVENT_RECLAIM_START, + MONO_GC_EVENT_RECLAIM_END, + MONO_GC_EVENT_END, + MONO_GC_EVENT_PRE_STOP_WORLD, + MONO_GC_EVENT_POST_STOP_WORLD, + MONO_GC_EVENT_PRE_START_WORLD, + MONO_GC_EVENT_POST_START_WORLD +} MonoGCEvent; + +/* coverage info */ +typedef struct { + MonoMethod *method; + int iloffset; + int counter; + const char *filename; + int line; + int col; +} MonoProfileCoverageEntry; + +/* executable code buffer info */ +typedef enum { + MONO_PROFILER_CODE_BUFFER_UNKNOWN, + MONO_PROFILER_CODE_BUFFER_METHOD, + MONO_PROFILER_CODE_BUFFER_LAST +} MonoProfilerCodeBufferType; + +typedef struct _MonoProfiler MonoProfiler; + +typedef enum { + MONO_PROFILER_MONITOR_CONTENTION = 1, + MONO_PROFILER_MONITOR_DONE = 2, + MONO_PROFILER_MONITOR_FAIL = 3 +} MonoProfilerMonitorEvent; + +typedef enum { + MONO_PROFILER_CALL_CHAIN_NONE = 0, + MONO_PROFILER_CALL_CHAIN_NATIVE = 1, + MONO_PROFILER_CALL_CHAIN_GLIBC = 2, + MONO_PROFILER_CALL_CHAIN_MANAGED = 3, + MONO_PROFILER_CALL_CHAIN_INVALID = 4 +} MonoProfilerCallChainStrategy; + +typedef enum { + MONO_PROFILER_GC_HANDLE_CREATED, + MONO_PROFILER_GC_HANDLE_DESTROYED +} MonoProfileGCHandleEvent; + +typedef enum { + MONO_PROFILE_GC_ROOT_PINNING = 1 << 8, + MONO_PROFILE_GC_ROOT_WEAKREF = 2 << 8, + MONO_PROFILE_GC_ROOT_INTERIOR = 4 << 8, + /* the above are flags, the type is in the low 2 bytes */ + MONO_PROFILE_GC_ROOT_STACK = 0, + MONO_PROFILE_GC_ROOT_FINALIZER = 1, + MONO_PROFILE_GC_ROOT_HANDLE = 2, + MONO_PROFILE_GC_ROOT_OTHER = 3, + MONO_PROFILE_GC_ROOT_MISC = 4, /* could be stack, handle, etc. */ + MONO_PROFILE_GC_ROOT_TYPEMASK = 0xff +} MonoProfileGCRootType; + +/* + * Functions that the runtime will call on the profiler. + */ + +typedef void (*MonoProfileFunc) (MonoProfiler *prof); + +typedef void (*MonoProfileAppDomainFunc) (MonoProfiler *prof, MonoDomain *domain); +typedef void (*MonoProfileMethodFunc) (MonoProfiler *prof, MonoMethod *method); +typedef void (*MonoProfileClassFunc) (MonoProfiler *prof, MonoClass *klass); +typedef void (*MonoProfileModuleFunc) (MonoProfiler *prof, MonoImage *module); +typedef void (*MonoProfileAssemblyFunc) (MonoProfiler *prof, MonoAssembly *assembly); +typedef void (*MonoProfileMonitorFunc) (MonoProfiler *prof, MonoObject *obj, MonoProfilerMonitorEvent event); + +typedef void (*MonoProfileExceptionFunc) (MonoProfiler *prof, MonoObject *object); +typedef void (*MonoProfileExceptionClauseFunc) (MonoProfiler *prof, MonoMethod *method, int clause_type, int clause_num); + +typedef void (*MonoProfileAppDomainResult)(MonoProfiler *prof, MonoDomain *domain, int result); +typedef void (*MonoProfileMethodResult) (MonoProfiler *prof, MonoMethod *method, int result); +typedef void (*MonoProfileJitResult) (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, int result); +typedef void (*MonoProfileClassResult) (MonoProfiler *prof, MonoClass *klass, int result); +typedef void (*MonoProfileModuleResult) (MonoProfiler *prof, MonoImage *module, int result); +typedef void (*MonoProfileAssemblyResult) (MonoProfiler *prof, MonoAssembly *assembly, int result); + +typedef void (*MonoProfileMethodInline) (MonoProfiler *prof, MonoMethod *parent, MonoMethod *child, int *ok); + +typedef void (*MonoProfileThreadFunc) (MonoProfiler *prof, uintptr_t tid); +typedef void (*MonoProfileThreadNameFunc) (MonoProfiler *prof, uintptr_t tid, const char *name); +typedef void (*MonoProfileAllocFunc) (MonoProfiler *prof, MonoObject *obj, MonoClass *klass); +typedef void (*MonoProfileStatFunc) (MonoProfiler *prof, mono_byte *ip, void *context); +typedef void (*MonoProfileStatCallChainFunc) (MonoProfiler *prof, int call_chain_depth, mono_byte **ip, void *context); +typedef void (*MonoProfileGCFunc) (MonoProfiler *prof, MonoGCEvent event, int generation); +typedef void (*MonoProfileGCMoveFunc) (MonoProfiler *prof, void **objects, int num); +typedef void (*MonoProfileGCResizeFunc) (MonoProfiler *prof, int64_t new_size); +typedef void (*MonoProfileGCHandleFunc) (MonoProfiler *prof, int op, int type, uintptr_t handle, MonoObject *obj); +typedef void (*MonoProfileGCRootFunc) (MonoProfiler *prof, int num_roots, void **objects, int *root_types, uintptr_t *extra_info); + +typedef void (*MonoProfileIomapFunc) (MonoProfiler *prof, const char *report, const char *pathname, const char *new_pathname); + +typedef mono_bool (*MonoProfileCoverageFilterFunc) (MonoProfiler *prof, MonoMethod *method); + +typedef void (*MonoProfileCoverageFunc) (MonoProfiler *prof, const MonoProfileCoverageEntry *entry); + +typedef void (*MonoProfilerCodeChunkNew) (MonoProfiler *prof, void* chunk, int size); +typedef void (*MonoProfilerCodeChunkDestroy) (MonoProfiler *prof, void* chunk); +typedef void (*MonoProfilerCodeBufferNew) (MonoProfiler *prof, void* buffer, int size, MonoProfilerCodeBufferType type, void *data); + +/* + * Function the profiler may call. + */ +void mono_profiler_install (MonoProfiler *prof, MonoProfileFunc shutdown_callback); +void mono_profiler_set_events (MonoProfileFlags events); + +MonoProfileFlags mono_profiler_get_events (void); + +void mono_profiler_install_appdomain (MonoProfileAppDomainFunc start_load, MonoProfileAppDomainResult end_load, + MonoProfileAppDomainFunc start_unload, MonoProfileAppDomainFunc end_unload); +void mono_profiler_install_assembly (MonoProfileAssemblyFunc start_load, MonoProfileAssemblyResult end_load, + MonoProfileAssemblyFunc start_unload, MonoProfileAssemblyFunc end_unload); +void mono_profiler_install_module (MonoProfileModuleFunc start_load, MonoProfileModuleResult end_load, + MonoProfileModuleFunc start_unload, MonoProfileModuleFunc end_unload); +void mono_profiler_install_class (MonoProfileClassFunc start_load, MonoProfileClassResult end_load, + MonoProfileClassFunc start_unload, MonoProfileClassFunc end_unload); + +void mono_profiler_install_jit_compile (MonoProfileMethodFunc start, MonoProfileMethodResult end); +void mono_profiler_install_jit_end (MonoProfileJitResult end); +void mono_profiler_install_method_free (MonoProfileMethodFunc callback); +void mono_profiler_install_method_invoke (MonoProfileMethodFunc start, MonoProfileMethodFunc end); +void mono_profiler_install_enter_leave (MonoProfileMethodFunc enter, MonoProfileMethodFunc fleave); +void mono_profiler_install_thread (MonoProfileThreadFunc start, MonoProfileThreadFunc end); +void mono_profiler_install_thread_name (MonoProfileThreadNameFunc thread_name_cb); +void mono_profiler_install_transition (MonoProfileMethodResult callback); +void mono_profiler_install_allocation (MonoProfileAllocFunc callback); +void mono_profiler_install_monitor (MonoProfileMonitorFunc callback); +void mono_profiler_install_statistical (MonoProfileStatFunc callback); +void mono_profiler_install_statistical_call_chain (MonoProfileStatCallChainFunc callback, int call_chain_depth, MonoProfilerCallChainStrategy call_chain_strategy); +void mono_profiler_install_exception (MonoProfileExceptionFunc throw_callback, MonoProfileMethodFunc exc_method_leave, MonoProfileExceptionClauseFunc clause_callback); +void mono_profiler_install_coverage_filter (MonoProfileCoverageFilterFunc callback); +void mono_profiler_coverage_get (MonoProfiler *prof, MonoMethod *method, MonoProfileCoverageFunc func); +void mono_profiler_install_gc (MonoProfileGCFunc callback, MonoProfileGCResizeFunc heap_resize_callback); +void mono_profiler_install_gc_moves (MonoProfileGCMoveFunc callback); +void mono_profiler_install_gc_roots (MonoProfileGCHandleFunc handle_callback, MonoProfileGCRootFunc roots_callback); +void mono_profiler_install_runtime_initialized (MonoProfileFunc runtime_initialized_callback); + +void mono_profiler_install_code_chunk_new (MonoProfilerCodeChunkNew callback); +void mono_profiler_install_code_chunk_destroy (MonoProfilerCodeChunkDestroy callback); +void mono_profiler_install_code_buffer_new (MonoProfilerCodeBufferNew callback); + +void mono_profiler_install_iomap (MonoProfileIomapFunc callback); + +void mono_profiler_load (const char *desc); + +MONO_END_DECLS + +#endif /* __MONO_PROFILER_H__ */ + diff --git a/sampdotnethook/include/mono/metadata/reflection.h b/sampdotnethook/include/mono/metadata/reflection.h new file mode 100644 index 0000000..461eb57 --- /dev/null +++ b/sampdotnethook/include/mono/metadata/reflection.h @@ -0,0 +1,137 @@ +#ifndef __METADATA_REFLECTION_H__ +#define __METADATA_REFLECTION_H__ + +#include "object.h" + +MONO_BEGIN_DECLS + +typedef struct MonoTypeNameParse MonoTypeNameParse; + +typedef struct { + MonoMethod *ctor; + uint32_t data_size; + const mono_byte* data; +} MonoCustomAttrEntry; + +typedef struct { + int num_attrs; + int cached; + MonoImage *image; + MonoCustomAttrEntry attrs [MONO_ZERO_LEN_ARRAY]; +} MonoCustomAttrInfo; + +#define MONO_SIZEOF_CUSTOM_ATTR_INFO (offsetof (MonoCustomAttrInfo, attrs)) + +/* + * Information which isn't in the MonoMethod structure is stored here for + * dynamic methods. + */ +typedef struct { + char **param_names; + MonoMarshalSpec **param_marshall; + MonoCustomAttrInfo **param_cattr; + uint8_t** param_defaults; + uint32_t *param_default_types; + char *dllentry, *dll; +} MonoReflectionMethodAux; + +typedef enum { + ResolveTokenError_OutOfRange, + ResolveTokenError_BadTable, + ResolveTokenError_Other +} MonoResolveTokenError; + +int mono_reflection_parse_type (char *name, MonoTypeNameParse *info); +MonoType* mono_reflection_get_type (MonoImage* image, MonoTypeNameParse *info, mono_bool ignorecase, mono_bool *type_resolve); +void mono_reflection_free_type_info (MonoTypeNameParse *info); +MonoType* mono_reflection_type_from_name (char *name, MonoImage *image); +uint32_t mono_reflection_get_token (MonoObject *obj); + +MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly); +MonoReflectionModule* mono_module_get_object (MonoDomain *domain, MonoImage *image); +MonoReflectionModule* mono_module_file_get_object (MonoDomain *domain, MonoImage *image, int table_index); +MonoReflectionType* mono_type_get_object (MonoDomain *domain, MonoType *type); +MonoReflectionMethod* mono_method_get_object (MonoDomain *domain, MonoMethod *method, MonoClass *refclass); +MonoReflectionField* mono_field_get_object (MonoDomain *domain, MonoClass *klass, MonoClassField *field); +MonoReflectionProperty* mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *property); +MonoReflectionEvent* mono_event_get_object (MonoDomain *domain, MonoClass *klass, MonoEvent *event); +/* note: this one is slightly different: we keep the whole array of params in the cache */ +MonoArray* mono_param_get_objects (MonoDomain *domain, MonoMethod *method); +MonoReflectionMethodBody* mono_method_body_get_object (MonoDomain *domain, MonoMethod *method); + +MonoObject *mono_get_dbnull_object (MonoDomain *domain); + +MonoArray* mono_reflection_get_custom_attrs_by_type (MonoObject *obj, MonoClass *attr_klass, MonoError *error); +MonoArray* mono_reflection_get_custom_attrs (MonoObject *obj); +MonoArray* mono_reflection_get_custom_attrs_data (MonoObject *obj); +MonoArray* mono_reflection_get_custom_attrs_blob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues); + +MonoCustomAttrInfo* mono_reflection_get_custom_attrs_info (MonoObject *obj); +MonoArray* mono_custom_attrs_construct (MonoCustomAttrInfo *cinfo); +MonoCustomAttrInfo* mono_custom_attrs_from_index (MonoImage *image, uint32_t idx); +MonoCustomAttrInfo* mono_custom_attrs_from_method (MonoMethod *method); +MonoCustomAttrInfo* mono_custom_attrs_from_class (MonoClass *klass); +MonoCustomAttrInfo* mono_custom_attrs_from_assembly (MonoAssembly *assembly); +MonoCustomAttrInfo* mono_custom_attrs_from_property (MonoClass *klass, MonoProperty *property); +MonoCustomAttrInfo* mono_custom_attrs_from_event (MonoClass *klass, MonoEvent *event); +MonoCustomAttrInfo* mono_custom_attrs_from_field (MonoClass *klass, MonoClassField *field); +MonoCustomAttrInfo* mono_custom_attrs_from_param (MonoMethod *method, uint32_t param); +mono_bool mono_custom_attrs_has_attr (MonoCustomAttrInfo *ainfo, MonoClass *attr_klass); +MonoObject* mono_custom_attrs_get_attr (MonoCustomAttrInfo *ainfo, MonoClass *attr_klass); +void mono_custom_attrs_free (MonoCustomAttrInfo *ainfo); + + +#define MONO_DECLSEC_ACTION_MIN 0x1 +#define MONO_DECLSEC_ACTION_MAX 0x12 + +enum { + MONO_DECLSEC_FLAG_REQUEST = 0x00000001, + MONO_DECLSEC_FLAG_DEMAND = 0x00000002, + MONO_DECLSEC_FLAG_ASSERT = 0x00000004, + MONO_DECLSEC_FLAG_DENY = 0x00000008, + MONO_DECLSEC_FLAG_PERMITONLY = 0x00000010, + MONO_DECLSEC_FLAG_LINKDEMAND = 0x00000020, + MONO_DECLSEC_FLAG_INHERITANCEDEMAND = 0x00000040, + MONO_DECLSEC_FLAG_REQUEST_MINIMUM = 0x00000080, + MONO_DECLSEC_FLAG_REQUEST_OPTIONAL = 0x00000100, + MONO_DECLSEC_FLAG_REQUEST_REFUSE = 0x00000200, + MONO_DECLSEC_FLAG_PREJIT_GRANT = 0x00000400, + MONO_DECLSEC_FLAG_PREJIT_DENY = 0x00000800, + MONO_DECLSEC_FLAG_NONCAS_DEMAND = 0x00001000, + MONO_DECLSEC_FLAG_NONCAS_LINKDEMAND = 0x00002000, + MONO_DECLSEC_FLAG_NONCAS_INHERITANCEDEMAND = 0x00004000, + MONO_DECLSEC_FLAG_LINKDEMAND_CHOICE = 0x00008000, + MONO_DECLSEC_FLAG_INHERITANCEDEMAND_CHOICE = 0x00010000, + MONO_DECLSEC_FLAG_DEMAND_CHOICE = 0x00020000 +}; + +uint32_t mono_declsec_flags_from_method (MonoMethod *method); +uint32_t mono_declsec_flags_from_class (MonoClass *klass); +uint32_t mono_declsec_flags_from_assembly (MonoAssembly *assembly); + +/* this structure MUST be kept in synch with RuntimeDeclSecurityEntry + * located in /mcs/class/corlib/System.Security/SecurityFrame.cs */ +typedef struct { + char *blob; /* pointer to metadata blob */ + uint32_t size; /* size of the metadata blob */ + uint32_t index; +} MonoDeclSecurityEntry; + +typedef struct { + MonoDeclSecurityEntry demand; + MonoDeclSecurityEntry noncasdemand; + MonoDeclSecurityEntry demandchoice; +} MonoDeclSecurityActions; + +MonoBoolean mono_declsec_get_demands (MonoMethod *callee, MonoDeclSecurityActions* demands); +MonoBoolean mono_declsec_get_linkdemands (MonoMethod *callee, MonoDeclSecurityActions* klass, MonoDeclSecurityActions* cmethod); +MonoBoolean mono_declsec_get_inheritdemands_class (MonoClass *klass, MonoDeclSecurityActions* demands); +MonoBoolean mono_declsec_get_inheritdemands_method (MonoMethod *callee, MonoDeclSecurityActions* demands); + +MonoBoolean mono_declsec_get_method_action (MonoMethod *method, uint32_t action, MonoDeclSecurityEntry *entry); +MonoBoolean mono_declsec_get_class_action (MonoClass *klass, uint32_t action, MonoDeclSecurityEntry *entry); +MonoBoolean mono_declsec_get_assembly_action (MonoAssembly *assembly, uint32_t action, MonoDeclSecurityEntry *entry); + +MONO_END_DECLS + +#endif /* __METADATA_REFLECTION_H__ */ diff --git a/sampdotnethook/include/mono/metadata/row-indexes.h b/sampdotnethook/include/mono/metadata/row-indexes.h new file mode 100644 index 0000000..4b4ca6d --- /dev/null +++ b/sampdotnethook/include/mono/metadata/row-indexes.h @@ -0,0 +1,440 @@ + +#ifndef __MONO_METADATA_ROW_INDEXES_H__ +#define __MONO_METADATA_ROW_INDEXES_H__ + +/* + * The last entry in the enum is used to give the number + * of columns in the row. + */ + +enum { + MONO_ASSEMBLY_HASH_ALG, + MONO_ASSEMBLY_MAJOR_VERSION, + MONO_ASSEMBLY_MINOR_VERSION, + MONO_ASSEMBLY_BUILD_NUMBER, + MONO_ASSEMBLY_REV_NUMBER, + MONO_ASSEMBLY_FLAGS, + MONO_ASSEMBLY_PUBLIC_KEY, + MONO_ASSEMBLY_NAME, + MONO_ASSEMBLY_CULTURE, + MONO_ASSEMBLY_SIZE +}; + +enum { + MONO_ASSEMBLYOS_PLATFORM, + MONO_ASSEMBLYOS_MAJOR_VERSION, + MONO_ASSEMBLYOS_MINOR_VERSION, + MONO_ASSEMBLYOS_SIZE +}; + +enum { + MONO_ASSEMBLY_PROCESSOR, + MONO_ASSEMBLY_PROCESSOR_SIZE +}; + +enum { + MONO_ASSEMBLYREF_MAJOR_VERSION, + MONO_ASSEMBLYREF_MINOR_VERSION, + MONO_ASSEMBLYREF_BUILD_NUMBER, + MONO_ASSEMBLYREF_REV_NUMBER, + MONO_ASSEMBLYREF_FLAGS, + MONO_ASSEMBLYREF_PUBLIC_KEY, + MONO_ASSEMBLYREF_NAME, + MONO_ASSEMBLYREF_CULTURE, + MONO_ASSEMBLYREF_HASH_VALUE, + MONO_ASSEMBLYREF_SIZE +}; + +enum { + MONO_ASSEMBLYREFOS_PLATFORM, + MONO_ASSEMBLYREFOS_MAJOR_VERSION, + MONO_ASSEMBLYREFOS_MINOR_VERSION, + MONO_ASSEMBLYREFOS_ASSEMBLYREF, + MONO_ASSEMBLYREFOS_SIZE +}; + +enum { + MONO_ASSEMBLYREFPROC_PROCESSOR, + MONO_ASSEMBLYREFPROC_ASSEMBLYREF, + MONO_ASSEMBLYREFPROC_SIZE +}; + +enum { + MONO_CLASS_LAYOUT_PACKING_SIZE, + MONO_CLASS_LAYOUT_CLASS_SIZE, + MONO_CLASS_LAYOUT_PARENT, + MONO_CLASS_LAYOUT_SIZE +}; + +enum { + MONO_CONSTANT_TYPE, + MONO_CONSTANT_PADDING, + MONO_CONSTANT_PARENT, + MONO_CONSTANT_VALUE, + MONO_CONSTANT_SIZE +}; + +enum { + MONO_CUSTOM_ATTR_PARENT, + MONO_CUSTOM_ATTR_TYPE, + MONO_CUSTOM_ATTR_VALUE, + MONO_CUSTOM_ATTR_SIZE +}; + +enum { + MONO_DECL_SECURITY_ACTION, + MONO_DECL_SECURITY_PARENT, + MONO_DECL_SECURITY_PERMISSIONSET, + MONO_DECL_SECURITY_SIZE +}; + +enum { + MONO_EVENT_MAP_PARENT, + MONO_EVENT_MAP_EVENTLIST, + MONO_EVENT_MAP_SIZE +}; + +enum { + MONO_EVENT_FLAGS, + MONO_EVENT_NAME, + MONO_EVENT_TYPE, + MONO_EVENT_SIZE +}; + +enum { + MONO_EVENT_POINTER_EVENT, + MONO_EVENT_POINTER_SIZE +}; + +enum { + MONO_EXP_TYPE_FLAGS, + MONO_EXP_TYPE_TYPEDEF, + MONO_EXP_TYPE_NAME, + MONO_EXP_TYPE_NAMESPACE, + MONO_EXP_TYPE_IMPLEMENTATION, + MONO_EXP_TYPE_SIZE +}; + +enum { + MONO_FIELD_FLAGS, + MONO_FIELD_NAME, + MONO_FIELD_SIGNATURE, + MONO_FIELD_SIZE +}; + +enum { + MONO_FIELD_LAYOUT_OFFSET, + MONO_FIELD_LAYOUT_FIELD, + MONO_FIELD_LAYOUT_SIZE +}; + +enum { + MONO_FIELD_MARSHAL_PARENT, + MONO_FIELD_MARSHAL_NATIVE_TYPE, + MONO_FIELD_MARSHAL_SIZE +}; + +enum { + MONO_FIELD_POINTER_FIELD, + MONO_FIELD_POINTER_SIZE +}; + +enum { + MONO_FIELD_RVA_RVA, + MONO_FIELD_RVA_FIELD, + MONO_FIELD_RVA_SIZE +}; + +enum { + MONO_FILE_FLAGS, + MONO_FILE_NAME, + MONO_FILE_HASH_VALUE, + MONO_FILE_SIZE +}; + +enum { + MONO_IMPLMAP_FLAGS, + MONO_IMPLMAP_MEMBER, + MONO_IMPLMAP_NAME, + MONO_IMPLMAP_SCOPE, + MONO_IMPLMAP_SIZE +}; + +enum { + MONO_INTERFACEIMPL_CLASS, + MONO_INTERFACEIMPL_INTERFACE, + MONO_INTERFACEIMPL_SIZE +}; + +enum { + MONO_MANIFEST_OFFSET, + MONO_MANIFEST_FLAGS, + MONO_MANIFEST_NAME, + MONO_MANIFEST_IMPLEMENTATION, + MONO_MANIFEST_SIZE +}; + +enum { + MONO_MEMBERREF_CLASS, + MONO_MEMBERREF_NAME, + MONO_MEMBERREF_SIGNATURE, + MONO_MEMBERREF_SIZE +}; + +enum { + MONO_METHOD_RVA, + MONO_METHOD_IMPLFLAGS, + MONO_METHOD_FLAGS, + MONO_METHOD_NAME, + MONO_METHOD_SIGNATURE, + MONO_METHOD_PARAMLIST, + MONO_METHOD_SIZE +}; + +enum { + MONO_METHODIMPL_CLASS, + MONO_METHODIMPL_BODY, + MONO_METHODIMPL_DECLARATION, + MONO_METHODIMPL_SIZE +}; + +enum { + MONO_METHOD_POINTER_METHOD, + MONO_METHOD_POINTER_SIZE +}; + +enum { + MONO_METHOD_SEMA_SEMANTICS, + MONO_METHOD_SEMA_METHOD, + MONO_METHOD_SEMA_ASSOCIATION, + MONO_METHOD_SEMA_SIZE +}; + +enum { + MONO_MODULE_GENERATION, + MONO_MODULE_NAME, + MONO_MODULE_MVID, + MONO_MODULE_ENC, + MONO_MODULE_ENCBASE, + MONO_MODULE_SIZE +}; + +enum { + MONO_MODULEREF_NAME, + MONO_MODULEREF_SIZE +}; + +enum { + MONO_NESTED_CLASS_NESTED, + MONO_NESTED_CLASS_ENCLOSING, + MONO_NESTED_CLASS_SIZE +}; + +enum { + MONO_PARAM_FLAGS, + MONO_PARAM_SEQUENCE, + MONO_PARAM_NAME, + MONO_PARAM_SIZE +}; + +enum { + MONO_PARAM_POINTER_PARAM, + MONO_PARAM_POINTER_SIZE +}; + +enum { + MONO_PROPERTY_FLAGS, + MONO_PROPERTY_NAME, + MONO_PROPERTY_TYPE, + MONO_PROPERTY_SIZE +}; + +enum { + MONO_PROPERTY_POINTER_PROPERTY, + MONO_PROPERTY_POINTER_SIZE +}; + +enum { + MONO_PROPERTY_MAP_PARENT, + MONO_PROPERTY_MAP_PROPERTY_LIST, + MONO_PROPERTY_MAP_SIZE +}; + +enum { + MONO_STAND_ALONE_SIGNATURE, + MONO_STAND_ALONE_SIGNATURE_SIZE +}; + +enum { + MONO_TYPEDEF_FLAGS, + MONO_TYPEDEF_NAME, + MONO_TYPEDEF_NAMESPACE, + MONO_TYPEDEF_EXTENDS, + MONO_TYPEDEF_FIELD_LIST, + MONO_TYPEDEF_METHOD_LIST, + MONO_TYPEDEF_SIZE +}; + +enum { + MONO_TYPEREF_SCOPE, + MONO_TYPEREF_NAME, + MONO_TYPEREF_NAMESPACE, + MONO_TYPEREF_SIZE +}; + +enum { + MONO_TYPESPEC_SIGNATURE, + MONO_TYPESPEC_SIZE +}; + +enum { + MONO_GENERICPARAM_NUMBER, + MONO_GENERICPARAM_FLAGS, + MONO_GENERICPARAM_OWNER, + MONO_GENERICPARAM_NAME, + + MONO_GENERICPARAM_SIZE +}; + +enum { + MONO_METHODSPEC_METHOD, + MONO_METHODSPEC_SIGNATURE, + MONO_METHODSPEC_SIZE +}; + +enum { + MONO_GENPARCONSTRAINT_GENERICPAR, + MONO_GENPARCONSTRAINT_CONSTRAINT, + MONO_GENPARCONSTRAINT_SIZE +}; + +/* + * Coded Tokens + * The _BITS entry is for the bits used in the token. + * The _MASK entry is for mask the index out. + */ + +enum { + MONO_TYPEDEFORREF_TYPEDEF, + MONO_TYPEDEFORREF_TYPEREF, + MONO_TYPEDEFORREF_TYPESPEC, + MONO_TYPEDEFORREF_BITS = 2, + MONO_TYPEDEFORREF_MASK = 3 +}; + +enum { + MONO_HASCONSTANT_FIEDDEF, + MONO_HASCONSTANT_PARAM, + MONO_HASCONSTANT_PROPERTY, + MONO_HASCONSTANT_BITS = 2, + MONO_HASCONSTANT_MASK = 3 +}; + +enum { + MONO_CUSTOM_ATTR_METHODDEF, + MONO_CUSTOM_ATTR_FIELDDEF, + MONO_CUSTOM_ATTR_TYPEREF, + MONO_CUSTOM_ATTR_TYPEDEF, + MONO_CUSTOM_ATTR_PARAMDEF, + MONO_CUSTOM_ATTR_INTERFACE, + MONO_CUSTOM_ATTR_MEMBERREF, + MONO_CUSTOM_ATTR_MODULE, + MONO_CUSTOM_ATTR_PERMISSION, + MONO_CUSTOM_ATTR_PROPERTY, + MONO_CUSTOM_ATTR_EVENT, + MONO_CUSTOM_ATTR_SIGNATURE, + MONO_CUSTOM_ATTR_MODULEREF, + MONO_CUSTOM_ATTR_TYPESPEC, + MONO_CUSTOM_ATTR_ASSEMBLY, + MONO_CUSTOM_ATTR_ASSEMBLYREF, + MONO_CUSTOM_ATTR_FILE, + MONO_CUSTOM_ATTR_EXP_TYPE, + MONO_CUSTOM_ATTR_MANIFEST, + MONO_CUSTOM_ATTR_GENERICPAR, + MONO_CUSTOM_ATTR_BITS = 5, + MONO_CUSTOM_ATTR_MASK = 0x1F +}; + +enum { + MONO_HAS_FIELD_MARSHAL_FIELDSREF, + MONO_HAS_FIELD_MARSHAL_PARAMDEF, + MONO_HAS_FIELD_MARSHAL_BITS = 1, + MONO_HAS_FIELD_MARSHAL_MASK = 1 +}; + +enum { + MONO_HAS_DECL_SECURITY_TYPEDEF, + MONO_HAS_DECL_SECURITY_METHODDEF, + MONO_HAS_DECL_SECURITY_ASSEMBLY, + MONO_HAS_DECL_SECURITY_BITS = 2, + MONO_HAS_DECL_SECURITY_MASK = 3 +}; + +enum { + MONO_MEMBERREF_PARENT_TYPEDEF, /* not used */ + MONO_MEMBERREF_PARENT_TYPEREF, + MONO_MEMBERREF_PARENT_MODULEREF, + MONO_MEMBERREF_PARENT_METHODDEF, + MONO_MEMBERREF_PARENT_TYPESPEC, + MONO_MEMBERREF_PARENT_BITS = 3, + MONO_MEMBERREF_PARENT_MASK = 7 +}; + +enum { + MONO_HAS_SEMANTICS_EVENT, + MONO_HAS_SEMANTICS_PROPERTY, + MONO_HAS_SEMANTICS_BITS = 1, + MONO_HAS_SEMANTICS_MASK = 1 +}; + +enum { + MONO_METHODDEFORREF_METHODDEF, + MONO_METHODDEFORREF_METHODREF, + MONO_METHODDEFORREF_BITS = 1, + MONO_METHODDEFORREF_MASK = 1 +}; + +enum { + MONO_MEMBERFORWD_FIELDDEF, + MONO_MEMBERFORWD_METHODDEF, + MONO_MEMBERFORWD_BITS = 1, + MONO_MEMBERFORWD_MASK = 1 +}; + +enum { + MONO_IMPLEMENTATION_FILE, + MONO_IMPLEMENTATION_ASSEMBLYREF, + MONO_IMPLEMENTATION_EXP_TYPE, + MONO_IMPLEMENTATION_BITS = 2, + MONO_IMPLEMENTATION_MASK = 3 +}; + +enum { + MONO_CUSTOM_ATTR_TYPE_TYPEREF, /* not used */ + MONO_CUSTOM_ATTR_TYPE_TYPEDEF, /* not used */ + MONO_CUSTOM_ATTR_TYPE_METHODDEF, + MONO_CUSTOM_ATTR_TYPE_MEMBERREF, + MONO_CUSTOM_ATTR_TYPE_STRING, /* not used */ + MONO_CUSTOM_ATTR_TYPE_BITS = 3, + MONO_CUSTOM_ATTR_TYPE_MASK = 7 +}; + +enum { + MONO_RESOLTION_SCOPE_MODULE, + MONO_RESOLTION_SCOPE_MODULEREF, + MONO_RESOLTION_SCOPE_ASSEMBLYREF, + MONO_RESOLTION_SCOPE_TYPEREF, + MONO_RESOLTION_SCOPE_BITS = 2, + MONO_RESOLTION_SCOPE_MASK = 3 +}; + +enum { + MONO_TYPEORMETHOD_TYPE, + MONO_TYPEORMETHOD_METHOD, + MONO_TYPEORMETHOD_BITS = 1, + MONO_TYPEORMETHOD_MASK = 1 +}; + +#endif /* __MONO_METADATA_ROW_INDEXES_H__ */ + + diff --git a/sampdotnethook/include/mono/metadata/sgen-bridge.h b/sampdotnethook/include/mono/metadata/sgen-bridge.h new file mode 100644 index 0000000..98bdfe6 --- /dev/null +++ b/sampdotnethook/include/mono/metadata/sgen-bridge.h @@ -0,0 +1,50 @@ +/* + * Copyright 2011 Novell, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _MONO_SGEN_BRIDGE_H_ +#define _MONO_SGEN_BRIDGE_H_ + +#include + +MONO_BEGIN_DECLS + +typedef struct { + int num_objs; + MonoObject *objs [MONO_ZERO_LEN_ARRAY]; +} MonoGCBridgeSCC; + +typedef struct { + int src_scc_index; + int dst_scc_index; +} MonoGCBridgeXRef; + +typedef struct { + mono_bool (*is_bridge_object) (MonoObject *obj); + void (*cross_references) (int num_sccs, MonoGCBridgeSCC **sccs, int num_xrefs, MonoGCBridgeXRef *xrefs); +} MonoGCBridgeCallbacks; + +void mono_gc_register_bridge_callbacks (MonoGCBridgeCallbacks *callbacks); + +MONO_END_DECLS + +#endif diff --git a/sampdotnethook/include/mono/metadata/threads.h b/sampdotnethook/include/mono/metadata/threads.h new file mode 100644 index 0000000..67001be --- /dev/null +++ b/sampdotnethook/include/mono/metadata/threads.h @@ -0,0 +1,51 @@ +/* + * threads.h: Threading API + * + * Author: + * Dick Porter (dick@ximian.com) + * Patrik Torstensson (patrik.torstensson@labs2.com) + * + * (C) 2001 Ximian, Inc + */ + +#ifndef _MONO_METADATA_THREADS_H_ +#define _MONO_METADATA_THREADS_H_ + +#include +#include +#include + +MONO_BEGIN_DECLS + +/* This callback should return TRUE if the runtime must wait for the thread, FALSE otherwise */ +typedef mono_bool (*MonoThreadManageCallback) (MonoThread* thread); + +extern void mono_thread_init (MonoThreadStartCB start_cb, + MonoThreadAttachCB attach_cb); +extern void mono_thread_cleanup (void); +extern void mono_thread_manage(void); + +extern MonoThread *mono_thread_current (void); + +extern void mono_thread_set_main (MonoThread *thread); +extern MonoThread *mono_thread_get_main (void); + +extern void mono_thread_stop (MonoThread *thread); + +extern void mono_thread_new_init (intptr_t tid, void* stack_start, + void* func); +extern void mono_thread_create (MonoDomain *domain, void* func, void* arg); +extern MonoThread *mono_thread_attach (MonoDomain *domain); +extern void mono_thread_detach (MonoThread *thread); +extern void mono_thread_exit (void); + +void mono_thread_set_manage_callback (MonoThread *thread, MonoThreadManageCallback func); + +extern void mono_threads_set_default_stacksize (uint32_t stacksize); +extern uint32_t mono_threads_get_default_stacksize (void); + +void mono_threads_request_thread_dump (void); + +MONO_END_DECLS + +#endif /* _MONO_METADATA_THREADS_H_ */ diff --git a/sampdotnethook/include/mono/metadata/tokentype.h b/sampdotnethook/include/mono/metadata/tokentype.h new file mode 100644 index 0000000..be8904c --- /dev/null +++ b/sampdotnethook/include/mono/metadata/tokentype.h @@ -0,0 +1,41 @@ +#ifndef _MONO_METADATA_TOKENTYPE_H_ +#define _MONO_METADATA_TOKENTYPE_H_ + +/* + * These tokens match the table ID except for the last + * three (string, name and base type which are special) + */ + +typedef enum { + MONO_TOKEN_MODULE = 0x00000000, + MONO_TOKEN_TYPE_REF = 0x01000000, + MONO_TOKEN_TYPE_DEF = 0x02000000, + MONO_TOKEN_FIELD_DEF = 0x04000000, + MONO_TOKEN_METHOD_DEF = 0x06000000, + MONO_TOKEN_PARAM_DEF = 0x08000000, + MONO_TOKEN_INTERFACE_IMPL = 0x09000000, + MONO_TOKEN_MEMBER_REF = 0x0a000000, + MONO_TOKEN_CUSTOM_ATTRIBUTE = 0x0c000000, + MONO_TOKEN_PERMISSION = 0x0e000000, + MONO_TOKEN_SIGNATURE = 0x11000000, + MONO_TOKEN_EVENT = 0x14000000, + MONO_TOKEN_PROPERTY = 0x17000000, + MONO_TOKEN_MODULE_REF = 0x1a000000, + MONO_TOKEN_TYPE_SPEC = 0x1b000000, + MONO_TOKEN_ASSEMBLY = 0x20000000, + MONO_TOKEN_ASSEMBLY_REF = 0x23000000, + MONO_TOKEN_FILE = 0x26000000, + MONO_TOKEN_EXPORTED_TYPE = 0x27000000, + MONO_TOKEN_MANIFEST_RESOURCE = 0x28000000, + MONO_TOKEN_GENERIC_PARAM = 0x2a000000, + MONO_TOKEN_METHOD_SPEC = 0x2b000000, + + /* + * These do not match metadata tables directly + */ + MONO_TOKEN_STRING = 0x70000000, + MONO_TOKEN_NAME = 0x71000000, + MONO_TOKEN_BASE_TYPE = 0x72000000 +} MonoTokenType; + +#endif /* _MONO_METADATA_TOKENTYPE_H_ */ diff --git a/sampdotnethook/include/mono/metadata/verify.h b/sampdotnethook/include/mono/metadata/verify.h new file mode 100644 index 0000000..dd81fe4 --- /dev/null +++ b/sampdotnethook/include/mono/metadata/verify.h @@ -0,0 +1,62 @@ +#ifndef __MONO_METADATA_VERIFY_H__ +#define __MONO_METADATA_VERIFY_H__ + +#include +#include +#include +#include /* GSList dep */ + +MONO_BEGIN_DECLS + +typedef enum { + MONO_VERIFY_OK, + MONO_VERIFY_ERROR, + MONO_VERIFY_WARNING, + MONO_VERIFY_CLS = 4, + MONO_VERIFY_ALL = 7, + + /* Status signaling code that is not verifiable.*/ + MONO_VERIFY_NOT_VERIFIABLE = 8, + + /*OR it with other flags*/ + + /* Abort the verification if the code is not verifiable. + * The standard behavior is to abort if the code is not valid. + * */ + MONO_VERIFY_FAIL_FAST = 16, + + + /* Perform less verification of the code. This flag should be used + * if one wants the verifier to be more compatible to the MS runtime. + * Mind that this is not to be more compatible with MS peverify, but + * with the runtime itself, that has a less strict verifier. + */ + MONO_VERIFY_NON_STRICT = 32, + + /*Skip all visibility related checks*/ + MONO_VERIFY_SKIP_VISIBILITY = 64, + + /*Skip all visibility related checks*/ + MONO_VERIFY_REPORT_ALL_ERRORS = 128 + +} MonoVerifyStatus; + +typedef struct { + char *message; + MonoVerifyStatus status; +} MonoVerifyInfo; + +typedef struct { + MonoVerifyInfo info; + int8_t exception_type; /*should be one of MONO_EXCEPTION_* */ +} MonoVerifyInfoExtended; + + +GSList* mono_method_verify (MonoMethod *method, int level); +void mono_free_verify_list (GSList *list); +char* mono_verify_corlib (void); + +MONO_END_DECLS + +#endif /* __MONO_METADATA_VERIFY_H__ */ + diff --git a/sampdotnethook/include/mono/utils/mono-dl-fallback.h b/sampdotnethook/include/mono/utils/mono-dl-fallback.h new file mode 100644 index 0000000..06945ae --- /dev/null +++ b/sampdotnethook/include/mono/utils/mono-dl-fallback.h @@ -0,0 +1,34 @@ +#ifndef __MONO_UTILS_DL_FALLBACK_H__ +#define __MONO_UTILS_DL_FALLBACK_H__ + +#include + +MONO_BEGIN_DECLS + +enum { + MONO_DL_LAZY = 1, + MONO_DL_LOCAL = 2, + MONO_DL_MASK = 3 +}; + +/* + * This is the dynamic loader fallback API + */ +typedef struct MonoDlFallbackHandler MonoDlFallbackHandler; + +/* + * The "err" variable contents must be allocated using g_malloc or g_strdup + */ +typedef void* (*MonoDlFallbackLoad) (const char *name, int flags, char **err, void *user_data); +typedef void* (*MonoDlFallbackSymbol) (void *handle, const char *name, char **err, void *user_data); +typedef void* (*MonoDlFallbackClose) (void *handle, void *user_data); + +MonoDlFallbackHandler *mono_dl_fallback_register (MonoDlFallbackLoad load_func, MonoDlFallbackSymbol symbol_func, + MonoDlFallbackClose close_func, void *user_data); + +void mono_dl_fallback_unregister (MonoDlFallbackHandler *handler); + +MONO_END_DECLS + +#endif /* __MONO_UTILS_DL_FALLBACK_H__ */ + diff --git a/sampdotnethook/include/mono/utils/mono-error.h b/sampdotnethook/include/mono/utils/mono-error.h new file mode 100644 index 0000000..27d3856 --- /dev/null +++ b/sampdotnethook/include/mono/utils/mono-error.h @@ -0,0 +1,66 @@ +#ifndef __MONO_ERROR_H__ +#define __MONO_ERROR_H__ + +#include "mono-publib.h" + +enum { + /* + The supplied strings were dup'd by means of calling mono_error_dup_strings. + */ + MONO_ERROR_FREE_STRINGS = 0x0001, + + /* + Something happened while processing the error and the resulting message is incomplete. + */ + MONO_ERROR_INCOMPLETE = 0x0002 +}; + +enum { + MONO_ERROR_NONE = 0, + MONO_ERROR_MISSING_METHOD = 1, + MONO_ERROR_MISSING_FIELD = 2, + MONO_ERROR_TYPE_LOAD = 3, + MONO_ERROR_FILE_NOT_FOUND = 4, + MONO_ERROR_BAD_IMAGE = 5, + MONO_ERROR_OUT_OF_MEMORY = 6, + MONO_ERROR_ARGUMENT = 7, + MONO_ERROR_NOT_VERIFIABLE = 8, + /* + * This is a generic error mechanism is you need to raise an arbitrary corlib exception. + * You must pass the exception name otherwise prepare_exception will fail with internal execution. + */ + MONO_ERROR_GENERIC = 9 +}; + +/*Keep in sync with MonoErrorInternal*/ +typedef struct { + unsigned short error_code; + unsigned short hidden_0; /*DON'T TOUCH */ + + void *hidden_1 [12]; /*DON'T TOUCH */ + char hidden_2 [128]; /*DON'T TOUCH */ +} MonoError; + +MONO_BEGIN_DECLS + +void +mono_error_init (MonoError *error); + +void +mono_error_init_flags (MonoError *error, unsigned short flags); + +void +mono_error_cleanup (MonoError *error); + +mono_bool +mono_error_ok (MonoError *error); + +unsigned short +mono_error_get_error_code (MonoError *error); + +const char* +mono_error_get_message (MonoError *error); + +MONO_END_DECLS + +#endif diff --git a/sampdotnethook/include/mono/utils/mono-logger.h b/sampdotnethook/include/mono/utils/mono-logger.h new file mode 100644 index 0000000..fc0745b --- /dev/null +++ b/sampdotnethook/include/mono/utils/mono-logger.h @@ -0,0 +1,15 @@ +#ifndef __MONO_LOGGER_H__ +#define __MONO_LOGGER_H__ + +#include +MONO_BEGIN_DECLS + +void +mono_trace_set_level_string (const char *value); + +void +mono_trace_set_mask_string (const char *value); + +MONO_END_DECLS + +#endif /* __MONO_LOGGER_H__ */ diff --git a/sampdotnethook/include/mono/utils/mono-publib.h b/sampdotnethook/include/mono/utils/mono-publib.h new file mode 100644 index 0000000..5b6e0ff --- /dev/null +++ b/sampdotnethook/include/mono/utils/mono-publib.h @@ -0,0 +1,52 @@ +#ifndef __MONO_PUBLIB_H__ +#define __MONO_PUBLIB_H__ + +/* + * Minimal general purpose header for use in public mono header files. + * We can't include config.h, so we use compiler-specific preprocessor + * directives where needed. + */ + +#ifdef __cplusplus +#define MONO_BEGIN_DECLS extern "C" { +#define MONO_END_DECLS } +#else +#define MONO_BEGIN_DECLS +#define MONO_END_DECLS +#endif + +MONO_BEGIN_DECLS + +/* VS 2010 and later have stdint.h */ +#if defined(_MSC_VER) && _MSC_VER < 1600 + +typedef __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; + +#else + +#include + +#endif /* end of compiler-specific stuff */ + +typedef int32_t mono_bool; +typedef uint8_t mono_byte; +typedef uint16_t mono_unichar2; + +typedef void (*MonoFunc) (void* data, void* user_data); +typedef void (*MonoHFunc) (void* key, void* value, void* user_data); + +void mono_free (void *); + +#define MONO_CONST_RETURN const + +MONO_END_DECLS + +#endif /* __MONO_PUBLIB_H__ */ + diff --git a/sampdotnethook/lib/libmono-2.0.a b/sampdotnethook/lib/libmono-2.0.a new file mode 100644 index 0000000..33542a7 Binary files /dev/null and b/sampdotnethook/lib/libmono-2.0.a differ diff --git a/sampdotnethook/lib/libmono-2.0.so b/sampdotnethook/lib/libmono-2.0.so new file mode 100644 index 0000000..038633a Binary files /dev/null and b/sampdotnethook/lib/libmono-2.0.so differ diff --git a/sampdotnethook/lib/libmono-2.0.so.1 b/sampdotnethook/lib/libmono-2.0.so.1 new file mode 100644 index 0000000..038633a Binary files /dev/null and b/sampdotnethook/lib/libmono-2.0.so.1 differ diff --git a/sampdotnethook/lib/libmono-2.0.so.1.0.0 b/sampdotnethook/lib/libmono-2.0.so.1.0.0 new file mode 100644 index 0000000..038633a Binary files /dev/null and b/sampdotnethook/lib/libmono-2.0.so.1.0.0 differ diff --git a/sampdotnethook/lib/mono-2.0.dll b/sampdotnethook/lib/mono-2.0.dll new file mode 100644 index 0000000..34b365a Binary files /dev/null and b/sampdotnethook/lib/mono-2.0.dll differ diff --git a/sampdotnethook/lib/mono-2.0.exp b/sampdotnethook/lib/mono-2.0.exp new file mode 100644 index 0000000..3b5f3ac Binary files /dev/null and b/sampdotnethook/lib/mono-2.0.exp differ diff --git a/sampdotnethook/lib/mono-2.0.lib b/sampdotnethook/lib/mono-2.0.lib new file mode 100644 index 0000000..3587307 Binary files /dev/null and b/sampdotnethook/lib/mono-2.0.lib differ diff --git a/sampdotnethook/sampdotnethook.cbp b/sampdotnethook/sampdotnethook.cbp new file mode 100644 index 0000000..54bf0ee --- /dev/null +++ b/sampdotnethook/sampdotnethook.cbp @@ -0,0 +1,80 @@ + + + + + + diff --git a/sampdotnethook/sampdotnethook.depend b/sampdotnethook/sampdotnethook.depend new file mode 100644 index 0000000..806d197 --- /dev/null +++ b/sampdotnethook/sampdotnethook.depend @@ -0,0 +1,37 @@ +# depslib dependency file v1.0 +1340756187 source:/home/oliver/samp-dot-net/trunk/sampdotnethook/src/Invoke.cpp + "Invoke.h" + + + +1340929906 /home/oliver/samp-dot-net/trunk/sampdotnethook/src/Invoke.h + + + + + + + + + + + + + "SDK/amx/amx.h" + "SDK/plugincommon.h" + +1340797243 /home/oliver/samp-dot-net/trunk/sampdotnethook/src/SDK/amx/amx.h + + "sclinux.h" + + + + + + + +1339845862 /home/oliver/samp-dot-net/trunk/sampdotnethook/src/SDK/amx/sclinux.h + + +1340996134 /home/oliver/samp-dot-net/trunk/sampdotnethook/src/SDK/plugincommon.h + diff --git a/sampdotnethook/src/Invoke.cpp b/sampdotnethook/src/Invoke.cpp new file mode 100644 index 0000000..ce7896d --- /dev/null +++ b/sampdotnethook/src/Invoke.cpp @@ -0,0 +1,130 @@ +/* + SA-MP Streamer Plugin v2.5.2 + Copyright © 2010 Incognito + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "Invoke.h" + +#include +#include + +Invoke * g_Invoke; + +int Invoke::callNative(const PAWN::Native * native, ...) { + if (amx_list.empty() || amx_map.find(native->name) == amx_map.end()) { + return 0; + } + + unsigned int amx_addr = amx_map[native->name], count = strlen(native->data), variables = 0; + cell * params = new cell[count + 1], * physAddr[6]; + params[0] = count * sizeof(cell); + va_list input; + va_start(input, native); + for (unsigned int i = 0; i < count; ++i) { + switch (native->data[i]) { + case 'd': + case 'i': { + params[i + 1] = va_arg(input, int); + } + break; + case 'f': { + float value = (float)va_arg(input, double); + params[i + 1] = amx_ftoc(value); + } + break; + case 's': { + char * string = va_arg(input, char *); + amx_Allot(amx_list.front(), strlen(string) + 1, ¶ms[i + 1], &physAddr[variables++]); + amx_SetString(physAddr[variables - 1], string, 0, 0, strlen(string) + 1); + } + break; + case 'v': { + va_arg(input, void *); + amx_Allot(amx_list.front(), 1, ¶ms[i + 1], &physAddr[variables++]); + } + break; + case 'p': { + va_arg(input, void *); + int size = va_arg(input, int); + amx_Allot(amx_list.front(), size, ¶ms[++i], &physAddr[variables++]); + params[i + 1] = size; + } + break; + } + } + va_end(input); + amx_Function_t amx_Function = (amx_Function_t)amx_addr; + int value = amx_Function(amx_list.front(), params); + if (variables) { + variables = 0; + va_start(input, native); + for (unsigned int i = 0; i < count; ++i) { + switch (native->data[i]) { + case 's': { + amx_Release(amx_list.front(), params[i + 1]); + } + break; + case 'v': { + unsigned int * value = va_arg(input, unsigned int *), * returnValue = (unsigned int *)physAddr[variables++]; + * value = * returnValue; + amx_Release(amx_list.front(), params[i + 1]); + } + break; + case 'p': { + char * text = va_arg(input, char *); + int size = va_arg(input, int); + amx_GetString(text, physAddr[variables++], 0, size); + amx_Release(amx_list.front(), params[++i]); + } + break; + default: { + va_arg(input, void *); + } + break; + } + } + va_end(input); + } + delete [] params; + return value; +} + +int Invoke::getAddresses() { + if (gotAddresses) { + return 1; + } + AMX_HEADER * amx_hdr = (AMX_HEADER *)(amx_list.back())->base; + std::size_t size = sizeof(PAWN::names) / sizeof(const char *); + for (std::size_t i = 0; i < size; ++i) { + amx_FindNative(amx_list.back(), PAWN::names[i], &amx_idx); + if (amx_idx != 2147483647) { + unsigned int amx_addr = (unsigned int)((AMX_FUNCSTUB *)((char *)amx_hdr + amx_hdr->natives + amx_hdr->defsize * amx_idx))->address; + if (amx_addr) { + if (amx_map.find(PAWN::names[i]) == amx_map.end()) { + amx_map.insert(std::make_pair(PAWN::names[i], amx_addr)); + } + } + } + } + + if (amx_map.size() == size) { + gotAddresses = true; + return 1; + } + + return 0; +} + diff --git a/sampdotnethook/src/Invoke.h b/sampdotnethook/src/Invoke.h new file mode 100644 index 0000000..1270c7d --- /dev/null +++ b/sampdotnethook/src/Invoke.h @@ -0,0 +1,777 @@ +/* + SA-MP Streamer Plugin v2.5.2 + Copyright © 2010 Incognito + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#pragma once + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + #include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "SDK/amx/amx.h" +#include "SDK/plugincommon.h" + +using namespace std; + +namespace PAWN +{ + struct Native + { + const char * name; + const char * data; + }; + + static const char * const names[] = + { + // a_samp.inc + "SendClientMessage", + "SendClientMessageToAll", + "SendPlayerMessageToPlayer", + "SendPlayerMessageToAll", + "SendDeathMessage", + "GameTextForAll", + "GameTextForPlayer", + "GetTickCount", + "GetMaxPlayers", + "SetGameModeText", + "SetTeamCount", + "AddPlayerClass", + "AddPlayerClassEx", + "AddStaticVehicle", + "AddStaticVehicleEx", + "AddStaticPickup", + "CreatePickup", + "DestroyPickup", + "ShowNameTags", + "ShowPlayerMarkers", + "GameModeExit", + "SetWorldTime", + "GetWeaponName", + "EnableTirePopping", + "AllowInteriorWeapons", + "SetWeather", + "SetGravity", + "AllowAdminTeleport", + "SetDeathDropAmount", + "CreateExplosion", + "EnableZoneNames", + "UsePlayerPedAnims", + "DisableInteriorEnterExits", + "SetNameTagDrawDistance", + "DisableNameTagLOS", + "LimitGlobalChatRadius", + "LimitPlayerMarkerRadius", + "ConnectNPC", + "IsPlayerNPC", + "IsPlayerAdmin", + "Kick", + "Ban", + "BanEx", + "SendRconCommand", + "GetServerVarAsString", + "GetServerVarAsInt", + "GetServerVarAsBool", + "GetPlayerNetworkStats", + "GetNetworkStats", + "GetPlayerVersion", + "CreateMenu", + "DestroyMenu", + "AddMenuItem", + "SetMenuColumnHeader", + "ShowMenuForPlayer", + "HideMenuForPlayer", + "IsValidMenu", + "DisableMenu", + "DisableMenuRow", + "GetPlayerMenu", + "TextDrawCreate", + "TextDrawDestroy", + "TextDrawLetterSize", + "TextDrawTextSize", + "TextDrawAlignment", + "TextDrawColor", + "TextDrawUseBox", + "TextDrawBoxColor", + "TextDrawSetShadow", + "TextDrawSetOutline", + "TextDrawBackgroundColor", + "TextDrawFont", + "TextDrawSetProportional", + "TextDrawSetSelectable", + "TextDrawShowForPlayer", + "TextDrawHideForPlayer", + "TextDrawShowForAll", + "TextDrawHideForAll", + "TextDrawSetString", + "GangZoneCreate", + "GangZoneDestroy", + "GangZoneShowForPlayer", + "GangZoneShowForAll", + "GangZoneHideForPlayer", + "GangZoneHideForAll", + "GangZoneFlashForPlayer", + "GangZoneFlashForAll", + "GangZoneStopFlashForPlayer", + "GangZoneStopFlashForAll", + "Create3DTextLabel", + "Delete3DTextLabel", + "Attach3DTextLabelToPlayer", + "Attach3DTextLabelToVehicle", + "Update3DTextLabelText", + "CreatePlayer3DTextLabel", + "DeletePlayer3DTextLabel", + "UpdatePlayer3DTextLabelText", + "ShowPlayerDialog", + + //a_players.inc + "SetSpawnInfo", + "SpawnPlayer", + "SetPlayerPos", + "SetPlayerPosFindZ", + "GetPlayerPos", + "SetPlayerFacingAngle", + "GetPlayerFacingAngle", + //"IsPlayerInRangeOfPoint", + //"GetPlayerDistanceFromPoint", + "IsPlayerStreamedIn", + "SetPlayerInterior", + "GetPlayerInterior", + "SetPlayerHealth", + "GetPlayerHealth", + "SetPlayerArmour", + "GetPlayerArmour", + "SetPlayerAmmo", + "GetPlayerAmmo", + "GetPlayerWeaponState", + "GetPlayerTargetPlayer", + "SetPlayerTeam", + "GetPlayerTeam", + "SetPlayerScore", + "GetPlayerScore", + "GetPlayerDrunkLevel", + "SetPlayerDrunkLevel", + "SetPlayerColor", + "GetPlayerColor", + "SetPlayerSkin", + "GetPlayerSkin", + "GivePlayerWeapon", + "ResetPlayerWeapons", + "SetPlayerArmedWeapon", + "GetPlayerWeaponData", + "GivePlayerMoney", + "ResetPlayerMoney", + "SetPlayerName", + "GetPlayerMoney", + "GetPlayerState", + "GetPlayerIp", + "GetPlayerPing", + "GetPlayerWeapon", + "GetPlayerKeys", + "GetPlayerName", + "SetPlayerTime", + "GetPlayerTime", + "TogglePlayerClock", + "SetPlayerWeather", + "ForceClassSelection", + "SetPlayerWantedLevel", + "GetPlayerWantedLevel", + "SetPlayerFightingStyle", + "GetPlayerFightingStyle", + "SetPlayerVelocity", + "GetPlayerVelocity", + "PlayCrimeReportForPlayer", + "PlayAudioStreamForPlayer", + "StopAudioStreamForPlayer", + "SetPlayerShopName", + "SetPlayerSkillLevel", + "GetPlayerSurfingVehicleID", + "GetPlayerSurfingObjectID", + "RemoveBuildingForPlayer", + "SetPlayerAttachedObject", + "RemovePlayerAttachedObject", + "IsPlayerAttachedObjectSlotUsed", + "EditAttachedObject", + "CreatePlayerTextDraw", + "PlayerTextDrawDestroy", + "PlayerTextDrawLetterSize", + "PlayerTextDrawTextSize", + "PlayerTextDrawAlignment", + "PlayerTextDrawColor", + "PlayerTextDrawUseBox", + "PlayerTextDrawBoxColor", + "PlayerTextDrawSetShadow", + "PlayerTextDrawSetOutline", + "PlayerTextDrawBackgroundColor", + "PlayerTextDrawFont", + "PlayerTextDrawSetProportional", + "PlayerTextDrawSetSelectable", + "PlayerTextDrawShow", + "PlayerTextDrawHide", + "PlayerTextDrawSetString", + "SetPVarInt", + "GetPVarInt", + "SetPVarString", + "GetPVarString", + "SetPVarFloat", + "GetPVarFloat", + "DeletePVar", + "GetPVarsUpperIndex", + "GetPVarNameAtIndex", + "GetPVarType", + "SetPlayerChatBubble", + "PutPlayerInVehicle", + "GetPlayerVehicleID", + "GetPlayerVehicleSeat", + "RemovePlayerFromVehicle", + "TogglePlayerControllable", + "PlayerPlaySound", + "ApplyAnimation", + "ClearAnimations", + "GetPlayerAnimationIndex", + "GetAnimationName", + "GetPlayerSpecialAction", + "SetPlayerSpecialAction", + "SetPlayerCheckpoint", + "DisablePlayerCheckpoint", + "SetPlayerRaceCheckpoint", + "DisablePlayerRaceCheckpoint", + "SetPlayerWorldBounds", + "SetPlayerMarkerForPlayer", + "ShowPlayerNameTagForPlayer", + "SetPlayerMapIcon", + "RemovePlayerMapIcon", + "AllowPlayerTeleport", + "SetPlayerCameraPos", + "SetPlayerCameraLookAt", + "SetCameraBehindPlayer", + "GetPlayerCameraPos", + "GetPlayerCameraFrontVector", + "GetPlayerCameraMode", + "AttachCameraToObject", + "AttachCameraToPlayerObject", + "InterpolateCameraPos", + "InterpolateCameraLookAt", + "IsPlayerConnected", + "IsPlayerInVehicle", + "IsPlayerInAnyVehicle", + "IsPlayerInCheckpoint", + "IsPlayerInRaceCheckpoint", + "SetPlayerVirtualWorld", + "GetPlayerVirtualWorld", + "EnableStuntBonusForPlayer", + "EnableStuntBonusForAll", + "TogglePlayerSpectating", + "PlayerSpectatePlayer", + "PlayerSpectateVehicle", + "StartRecordingPlayerData", + "StopRecordingPlayerData", + "SelectTextDraw", + "CancelSelectTextDraw", + + // a_vehicle.inc + "CreateVehicle", + "DestroyVehicle", + "IsVehicleStreamedIn", + "GetVehiclePos", + "SetVehiclePos", + "GetVehicleZAngle", + "GetVehicleRotationQuat", + "GetVehicleDistanceFromPoint", + "SetVehicleZAngle", + "SetVehicleParamsForPlayer", + "ManualVehicleEngineAndLights", + "SetVehicleParamsEx", + "GetVehicleParamsEx", + "SetVehicleToRespawn", + "LinkVehicleToInterior", + "AddVehicleComponent", + "RemoveVehicleComponent", + "ChangeVehicleColor", + "ChangeVehiclePaintjob", + "SetVehicleHealth", + "GetVehicleHealth", + "AttachTrailerToVehicle", + "DetachTrailerFromVehicle", + "IsTrailerAttachedToVehicle", + "GetVehicleTrailer", + "SetVehicleNumberPlate", + "GetVehicleModel", + "GetVehicleComponentInSlot", + "GetVehicleComponentType", + "RepairVehicle", + "GetVehicleVelocity", + "SetVehicleVelocity", + "SetVehicleAngularVelocity", + "GetVehicleDamageStatus", + "UpdateVehicleDamageStatus", + "GetVehicleModelInfo", + "SetVehicleVirtualWorld", + "GetVehicleVirtualWorld", + + //a_objects.inc + "CreateObject", + "AttachObjectToVehicle", + "AttachObjectToObject", + "AttachObjectToPlayer", + "SetObjectPos", + "GetObjectPos", + "SetObjectRot", + "GetObjectRot", + "IsValidObject", + "DestroyObject", + "MoveObject", + "StopObject", + "IsObjectMoving", + "EditObject", + "EditPlayerObject", + "SelectObject", + "CancelEdit", + "CreatePlayerObject", + "AttachPlayerObjectToVehicle", + "SetPlayerObjectPos", + "GetPlayerObjectPos", + "SetPlayerObjectRot", + "GetPlayerObjectRot", + "IsValidPlayerObject", + "DestroyPlayerObject", + "MovePlayerObject", + "StopPlayerObject", + "IsPlayerObjectMoving", + "AttachPlayerObjectToPlayer", + "SetObjectMaterial", + "SetPlayerObjectMaterial", + "SetObjectMaterialText", + "SetPlayerObjectMaterialText", + }; + + /* ******************************************** * + * a_samp.inc * + * ******************************************** */ + + // Util + static const Native SendClientMessage = { "SendClientMessage", "iis" }; + static const Native SendClientMessageToAll = { "SendClientMessageToAll", "is" }; + static const Native SendPlayerMessageToPlayer = { "SendPlayerMessageToPlayer", "iis" }; + static const Native SendPlayerMessageToAll = { "SendPlayerMessageToAll", "is" }; + static const Native SendDeathMessage = { "SendDeathMessage", "iii" }; + static const Native GameTextForAll = { "GameTextForAll", "sii" }; + static const Native GameTextForPlayer = { "GameTextForPlayer", "isii" }; + static const Native GetTickCount = { "GetTickCount", "i" }; + static const Native GetMaxPlayers = { "GetMaxPlayers", "i" }; + + // Game + static const Native SetGameModeText = { "SetGameModeText", "s" }; + static const Native SetTeamCount = { "SetTeamCount", "i" }; + static const Native AddPlayerClass = { "AddPlayerClass", "iffffiiiiii" }; + static const Native AddPlayerClassEx = { "AddPlayerClassEx", "iiffffiiiiii" }; + static const Native AddStaticVehicle = { "AddStaticVehicle", "iffffii" }; + static const Native AddStaticVehicleEx = { "AddStaticVehicleEx", "iffffiii" }; + static const Native AddStaticPickup = { "AddStaticPickup", "iifffi" }; + static const Native CreatePickup = { "CreatePickup", "iifffi" }; + static const Native DestroyPickup = { "DestroyPickup", "i" }; + static const Native ShowNameTags = { "ShowNameTags", "i" }; + static const Native ShowPlayerMarkers = { "ShowPlayerMarkers", "i" }; + static const Native GameModeExit = { "GameModeExit", "i" }; + static const Native SetWorldTime = { "SetWorldTime", "i" }; + static const Native GetWeaponName = { "GetWeaponName", "ipi" }; + static const Native EnableTirePopping = { "EnableTirePopping", "i" }; + static const Native AllowInteriorWeapons = { "AllowInteriorWeapons", "i" }; + static const Native SetWeather = { "SetWeather", "i" }; + static const Native SetGravity = { "SetGravity", "f" }; + static const Native AllowAdminTeleport = { "AllowAdminTeleport", "i" }; + static const Native SetDeathDropAmount = { "SetDeathDropAmount", "i" }; + static const Native CreateExplosion = { "CreateExplosion", "fffif" }; + static const Native EnableZoneNames = { "EnableZoneNames", "i" }; + static const Native UsePlayerPedAnims = { "UsePlayerPedAnims", "i" }; + static const Native DisableInteriorEnterExits = { "DisableInteriorEnterExits", "i" }; + static const Native SetNameTagDrawDistance = { "SetNameTagDrawDistance", "f" }; + static const Native DisableNameTagLOS = { "DisableNameTagLOS", "i" }; + static const Native LimitGlobalChatRadius = { "LimitGlobalChatRadius", "f" }; + static const Native LimitPlayerMarkerRadius = { "LimitPlayerMarkerRadius", "f" }; + + // Npc + static const Native ConnectNPC = { "ConnectNPC", "ss" }; + static const Native IsPlayerNPC = { "IsPlayerNPC", "i" }; + + // Admin + static const Native IsPlayerAdmin = { "IsPlayerAdmin", "i" }; + static const Native Kick = { "Kick", "i" }; + static const Native Ban = { "Ban", "i" }; + static const Native BanEx = { "BanEx", "is" }; + static const Native SendRconCommand = { "SendRconCommand", "s" }; + static const Native GetServerVarAsString = { "GetServerVarAsString", "spi" }; + static const Native GetServerVarAsInt = { "GetServerVarAsInt", "s" }; + static const Native GetServerVarAsBool = { "GetServerVarAsBool", "s" }; + static const Native GetPlayerNetworkStats = { "GetPlayerNetworkStats", "isi" }; + static const Native GetNetworkStats = { "GetNetworkStats", "si" }; + static const Native GetPlayerVersion = { "GetPlayerVersion", "ipi" }; + + // Menu + static const Native CreateMenu = { "CreateMenu", "siffff" }; + static const Native DestroyMenu = { "DestroyMenu", "i" }; + static const Native AddMenuItem = { "AddMenuItem", "iis" }; + static const Native SetMenuColumnHeader = { "SetMenuColumnHeader", "iis" }; + static const Native ShowMenuForPlayer = { "ShowMenuForPlayer", "ii" }; + static const Native HideMenuForPlayer = { "HideMenuForPlayer", "ii" }; + static const Native IsValidMenu = { "IsValidMenu", "i" }; + static const Native DisableMenu = { "DisableMenu", "i" }; + static const Native DisableMenuRow = { "DisableMenuRow", "ii" }; + static const Native GetPlayerMenu = { "GetPlayerMenu", "i" }; + + // Text Draw + static const Native TextDrawCreate = { "TextDrawCreate", "ffs" }; + static const Native TextDrawDestroy = { "TextDrawDestroy", "i" }; + static const Native TextDrawLetterSize = { "TextDrawLetterSize", "iff" }; + static const Native TextDrawTextSize = { "TextDrawTextSize", "iff" }; + static const Native TextDrawAlignment = { "TextDrawAlignment", "ii" }; + static const Native TextDrawColor = { "TextDrawColor", "ii" }; + static const Native TextDrawUseBox = { "TextDrawUseBox", "ii" }; + static const Native TextDrawBoxColor = { "TextDrawBoxColor", "ii" }; + static const Native TextDrawSetShadow = { "TextDrawSetShadow", "ii" }; + static const Native TextDrawSetOutline = { "TextDrawSetOutline", "ii" }; + static const Native TextDrawBackgroundColor = { "TextDrawBackgroundColor", "ii" }; + static const Native TextDrawFont = { "TextDrawFont", "ii" }; + static const Native TextDrawSetProportional = { "TextDrawSetProportional", "ii" }; + static const Native TextDrawSetSelectable = { "TextDrawSetSelectable", "ii" }; + static const Native TextDrawShowForPlayer = { "TextDrawShowForPlayer", "ii" }; + static const Native TextDrawHideForPlayer = { "TextDrawHideForPlayer", "ii" }; + static const Native TextDrawShowForAll = { "TextDrawShowForAll", "i" }; + static const Native TextDrawHideForAll = { "TextDrawHideForAll", "i" }; + static const Native TextDrawSetString = { "TextDrawSetString", "is" }; + + // Gang Zones + static const Native GangZoneCreate = { "GangZoneCreate", "ffff" }; + static const Native GangZoneDestroy = { "GangZoneDestroy", "i" }; + static const Native GangZoneShowForPlayer = { "GangZoneShowForPlayer", "iii" }; + static const Native GangZoneShowForAll = { "GangZoneShowForAll", "ii" }; + static const Native GangZoneHideForPlayer = { "GangZoneHideForPlayer", "ii" }; + static const Native GangZoneHideForAll = { "GangZoneHideForAll", "i" }; + static const Native GangZoneFlashForPlayer = { "GangZoneFlashForPlayer", "iii" }; + static const Native GangZoneFlashForAll = { "GangZoneFlashForAll", "ii" }; + static const Native GangZoneStopFlashForPlayer = { "GangZoneStopFlashForPlayer", "ii" }; + static const Native GangZoneStopFlashForAll = { "GangZoneStopFlashForAll", "i" }; + + // Global 3D Text Labels + static const Native Create3DTextLabel = { "Create3DTextLabel", "siffffii" }; + static const Native Delete3DTextLabel = { "Delete3DTextLabel", "i" }; + static const Native Attach3DTextLabelToPlayer = { "Attach3DTextLabelToPlayer", "iifff" }; + static const Native Attach3DTextLabelToVehicle = { "Attach3DTextLabelToVehicle", "iifff" }; + static const Native Update3DTextLabelText = { "Update3DTextLabelText", "iis" }; + + // Per-player 3D Text Labels + static const Native CreatePlayer3DTextLabel = { "CreatePlayer3DTextLabel", "isiffffiii" }; + static const Native DeletePlayer3DTextLabel = { "DeletePlayer3DTextLabel", "ii" }; + static const Native UpdatePlayer3DTextLabelText = { "UpdatePlayer3DTextLabelText", "iiis" }; + + // Player GUI Dialog + static const Native ShowPlayerDialog = { "ShowPlayerDialog", "iiissss" }; + + /* ******************************************** * + * a_players.inc * + * ******************************************** */ + + // Player + static const Native SetSpawnInfo = { "SetSpawnInfo", "iiiffffiiiiii" }; + static const Native SpawnPlayer = { "SpawnPlayer", "i" }; + + // Player info + static const Native SetPlayerPos = { "SetPlayerPos", "ifff" }; + static const Native SetPlayerPosFindZ = { "SetPlayerPosFindZ", "ifff" }; + static const Native GetPlayerPos = { "GetPlayerPos", "ivvv" }; + static const Native SetPlayerFacingAngle = { "SetPlayerFacingAngle", "if" }; + static const Native GetPlayerFacingAngle = { "GetPlayerFacingAngle", "iv" }; + static const Native IsPlayerInRangeOfPoint = { "IsPlayerInRangeOfPoint", "iffff" }; + static const Native GetPlayerDistanceFromPoint = { "GetPlayerDistanceFromPoint", "ifff" }; + static const Native IsPlayerStreamedIn = { "IsPlayerStreamedIn", "ii" }; + static const Native SetPlayerInterior = { "SetPlayerInterior", "ii" }; + static const Native GetPlayerInterior = { "GetPlayerInterior", "i" }; + static const Native SetPlayerHealth = { "SetPlayerHealth", "if" }; + static const Native GetPlayerHealth = { "GetPlayerHealth", "iv" }; + static const Native SetPlayerArmour = { "SetPlayerArmour", "if" }; + static const Native GetPlayerArmour = { "GetPlayerArmour", "iv" }; + static const Native SetPlayerAmmo = { "SetPlayerAmmo", "iii" }; + static const Native GetPlayerAmmo = { "GetPlayerAmmo", "i" }; + static const Native GetPlayerWeaponState = { "GetPlayerWeaponState", "i" }; + static const Native GetPlayerTargetPlayer = { "GetPlayerTargetPlayer", "i" }; + static const Native SetPlayerTeam = { "SetPlayerTeam", "ii" }; + static const Native GetPlayerTeam = { "GetPlayerTeam", "i" }; + static const Native SetPlayerScore = { "SetPlayerScore", "ii" }; + static const Native GetPlayerScore = { "GetPlayerScore", "i" }; + static const Native GetPlayerDrunkLevel = { "GetPlayerDrunkLevel", "i" }; + static const Native SetPlayerDrunkLevel = { "SetPlayerDrunkLevel", "ii" }; + static const Native SetPlayerColor = { "SetPlayerColor", "ii" }; + static const Native GetPlayerColor = { "GetPlayerColor", "i" }; + static const Native SetPlayerSkin = { "SetPlayerSkin", "ii" }; + static const Native GetPlayerSkin = { "GetPlayerSkin", "i" }; + static const Native GivePlayerWeapon = { "GivePlayerWeapon", "iii" }; + static const Native ResetPlayerWeapons = { "ResetPlayerWeapons", "i" }; + static const Native SetPlayerArmedWeapon = { "SetPlayerArmedWeapon", "ii" }; + static const Native GetPlayerWeaponData = { "GetPlayerWeaponData", "iivv" }; + static const Native GivePlayerMoney = { "GivePlayerMoney", "ii" }; + static const Native ResetPlayerMoney = { "ResetPlayerMoney", "i" }; + static const Native SetPlayerName = { "SetPlayerName", "is" }; + static const Native GetPlayerMoney = { "GetPlayerMoney", "i" }; + static const Native GetPlayerState = { "GetPlayerState", "i" }; + static const Native GetPlayerIp = { "GetPlayerIp", "ipi" }; + static const Native GetPlayerPing = { "GetPlayerPing", "i" }; + static const Native GetPlayerWeapon = { "GetPlayerWeapon", "i" }; + static const Native GetPlayerKeys = { "GetPlayerKeys", "ivvv" }; + static const Native GetPlayerName = { "GetPlayerName", "ipi" }; + static const Native SetPlayerTime = { "SetPlayerTime", "iii" }; + static const Native GetPlayerTime = { "GetPlayerTime", "ivv" }; + static const Native TogglePlayerClock = { "TogglePlayerClock", "ii" }; + static const Native SetPlayerWeather = { "SetPlayerWeather", "ii" }; + static const Native ForceClassSelection = { "ForceClassSelection", "i" }; + static const Native SetPlayerWantedLevel = { "SetPlayerWantedLevel", "ii" }; + static const Native GetPlayerWantedLevel = { "GetPlayerWantedLevel", "i" }; + static const Native SetPlayerFightingStyle = { "SetPlayerFightingStyle", "ii" }; + static const Native GetPlayerFightingStyle = { "GetPlayerFightingStyle", "i" }; + static const Native SetPlayerVelocity = { "SetPlayerVelocity", "ifff" }; + static const Native GetPlayerVelocity = { "GetPlayerVelocity", "ivvv" }; + static const Native PlayCrimeReportForPlayer = { "PlayCrimeReportForPlayer", "iii" }; + static const Native PlayAudioStreamForPlayer = { "PlayAudioStreamForPlayer", "isffffi" }; + static const Native StopAudioStreamForPlayer = { "StopAudioStreamForPlayer", "i" }; + static const Native SetPlayerShopName = { "SetPlayerShopName", "is" }; + static const Native SetPlayerSkillLevel = { "SetPlayerSkillLevel", "iii" }; + static const Native GetPlayerSurfingVehicleID = { "GetPlayerSurfingVehicleID", "i" }; + static const Native GetPlayerSurfingObjectID = { "GetPlayerSurfingObjectID", "i" }; + static const Native RemoveBuildingForPlayer = { "RemoveBuildingForPlayer", "iiffff" }; + + // Attached to bone objects + static const Native SetPlayerAttachedObject = { "SetPlayerAttachedObject", "iiiifffffffffii" }; + static const Native RemovePlayerAttachedObject = { "RemovePlayerAttachedObject", "ii" }; + static const Native IsPlayerAttachedObjectSlotUsed = { "IsPlayerAttachedObjectSlotUsed", "ii" }; + static const Native EditAttachedObject = { "EditAttachedObject", "ii" }; + + // Per-player TextDraws + static const Native CreatePlayerTextDraw = { "CreatePlayerTextDraw", "iffs" }; + static const Native PlayerTextDrawDestroy = { "PlayerTextDrawDestroy", "ii" }; + static const Native PlayerTextDrawLetterSize = { "PlayerTextDrawLetterSize", "iiff" }; + static const Native PlayerTextDrawTextSize = { "PlayerTextDrawTextSize", "iiff" }; + static const Native PlayerTextDrawAlignment = { "PlayerTextDrawAlignment", "iii" }; + static const Native PlayerTextDrawColor = { "PlayerTextDrawColor", "iii" }; + static const Native PlayerTextDrawUseBox = { "PlayerTextDrawUseBox", "iii" }; + static const Native PlayerTextDrawBoxColor = { "PlayerTextDrawBoxColor", "iii" }; + static const Native PlayerTextDrawSetShadow = { "PlayerTextDrawSetShadow", "iii" }; + static const Native PlayerTextDrawSetOutline = { "PlayerTextDrawSetOutline", "iii" }; + static const Native PlayerTextDrawBackgroundColor = { "PlayerTextDrawBackgroundColor", "iii" }; + static const Native PlayerTextDrawFont = { "PlayerTextDrawFont", "iii" }; + static const Native PlayerTextDrawSetProportional = { "PlayerTextDrawSetProportional", "iii" }; + static const Native PlayerTextDrawSetSelectable = { "PlayerTextDrawSetSelectable", "iii" }; + static const Native PlayerTextDrawShow = { "PlayerTextDrawShow", "ii" }; + static const Native PlayerTextDrawHide = { "PlayerTextDrawHide", "ii" }; + static const Native PlayerTextDrawSetString = { "PlayerTextDrawSetString", "iis" }; + + // Per-player variable system (PVars) + static const Native SetPVarInt = { "SetPVarInt", "isi" }; + static const Native GetPVarInt = { "GetPVarInt", "is" }; + static const Native SetPVarString = { "SetPVarString", "iss" }; + static const Native GetPVarString = { "GetPVarString", "ispi" }; + static const Native SetPVarFloat = { "SetPVarFloat", "isf" }; + static const Native GetPVarFloat = { "GetPVarFloat", "is" }; + static const Native DeletePVar = { "DeletePVar", "is" }; + + // PVar enumeration + static const Native GetPVarsUpperIndex = { "GetPVarsUpperIndex", "i" }; + static const Native GetPVarNameAtIndex = { "GetPVarNameAtIndex", "iisi" }; + static const Native GetPVarType = { "GetPVarType", "is" }; + + // Chat bubble (does this belong in a group?) + static const Native SetPlayerChatBubble = { "SetPlayerChatBubble", "isifi" }; + + // Player controls + static const Native PutPlayerInVehicle = { "PutPlayerInVehicle", "iii" }; + static const Native GetPlayerVehicleID = { "GetPlayerVehicleID", "i" }; + static const Native GetPlayerVehicleSeat = { "GetPlayerVehicleSeat", "i" }; + static const Native RemovePlayerFromVehicle = { "RemovePlayerFromVehicle", "i" }; + static const Native TogglePlayerControllable = { "TogglePlayerControllable", "ii" }; + static const Native PlayerPlaySound = { "PlayerPlaySound", "iifff" }; + static const Native ApplyAnimation = { "ApplyAnimation", "issfiiiiii" }; + static const Native ClearAnimations = { "ClearAnimations", "ii" }; + static const Native GetPlayerAnimationIndex = { "GetPlayerAnimationIndex", "i" }; + static const Native GetAnimationName = { "GetAnimationName", "isisi" }; + static const Native GetPlayerSpecialAction = { "GetPlayerSpecialAction", "i" }; + static const Native SetPlayerSpecialAction = { "SetPlayerSpecialAction", "ii" }; + + // Player world/map related + static const Native SetPlayerCheckpoint = { "SetPlayerCheckpoint", "iffff" }; + static const Native DisablePlayerCheckpoint = { "DisablePlayerCheckpoint", "i" }; + static const Native SetPlayerRaceCheckpoint = { "SetPlayerRaceCheckpoint", "iifffffff" }; + static const Native DisablePlayerRaceCheckpoint = { "DisablePlayerRaceCheckpoint", "i" }; + static const Native SetPlayerWorldBounds = { "SetPlayerWorldBounds", "iffff" }; + static const Native SetPlayerMarkerForPlayer = { "SetPlayerMarkerForPlayer", "iii" }; + static const Native ShowPlayerNameTagForPlayer = { "ShowPlayerNameTagForPlayer", "iii" }; + static const Native SetPlayerMapIcon = { "SetPlayerMapIcon", "iifffiii" }; + static const Native RemovePlayerMapIcon = { "RemovePlayerMapIcon", "ii" }; + static const Native AllowPlayerTeleport = { "AllowPlayerTeleport", "ii" }; + + // Player camera + static const Native SetPlayerCameraPos = { "SetPlayerCameraPos", "ifff" }; + static const Native SetPlayerCameraLookAt = { "SetPlayerCameraLookAt", "ifffi" }; + static const Native SetCameraBehindPlayer = { "SetCameraBehindPlayer", "i" }; + static const Native GetPlayerCameraPos = { "GetPlayerCameraPos", "ivvv" }; + static const Native GetPlayerCameraFrontVector = { "GetPlayerCameraFrontVector", "ivvv" }; + static const Native GetPlayerCameraMode = { "GetPlayerCameraMode", "i" }; + static const Native AttachCameraToObject = { "AttachCameraToObject", "ii" }; + static const Native AttachCameraToPlayerObject = { "AttachCameraToPlayerObject", "ii" }; + static const Native InterpolateCameraPos = { "InterpolateCameraPos", "iffffffii" }; + static const Native InterpolateCameraLookAt = { "InterpolateCameraLookAt", "iffffffii" }; + + // Player conditionals + static const Native IsPlayerConnected = { "IsPlayerConnected", "i" }; + static const Native IsPlayerInVehicle = { "IsPlayerInVehicle", "ii" }; + static const Native IsPlayerInAnyVehicle = { "IsPlayerInAnyVehicle", "i" }; + static const Native IsPlayerInCheckpoint = { "IsPlayerInCheckpoint", "i" }; + static const Native IsPlayerInRaceCheckpoint = { "IsPlayerInRaceCheckpoint", "i" }; + + // Virtual Worlds + static const Native SetPlayerVirtualWorld = { "SetPlayerVirtualWorld", "ii" }; + static const Native GetPlayerVirtualWorld = { "GetPlayerVirtualWorld", "i" }; + + // Insane Stunts + static const Native EnableStuntBonusForPlayer = { "EnableStuntBonusForPlayer", "ii" }; + static const Native EnableStuntBonusForAll = { "EnableStuntBonusForAll", "i" }; + + // Spectating + static const Native TogglePlayerSpectating = { "TogglePlayerSpectating", "ii" }; + static const Native PlayerSpectatePlayer = { "PlayerSpectatePlayer", "iii" }; + static const Native PlayerSpectateVehicle = { "PlayerSpectateVehicle", "iii" }; + + // Recording for NPC playback + static const Native StartRecordingPlayerData = { "StartRecordingPlayerData", "iis" }; + static const Native StopRecordingPlayerData = { "StopRecordingPlayerData", "i" }; + static const Native SelectTextDraw = { "SelectTextDraw", "ii" }; + static const Native CancelSelectTextDraw = { "CancelSelectTextDraw", "i" }; + + /* ******************************************** * + * a_vehicles.inc * + * ******************************************** */ + + // Vehicle + static const Native CreateVehicle = { "CreateVehicle", "iffffiii" }; + static const Native DestroyVehicle = { "DestroyVehicle", "i" }; + static const Native IsVehicleStreamedIn = { "IsVehicleStreamedIn", "ii" }; + static const Native GetVehiclePos = { "GetVehiclePos", "ivvv" }; + static const Native SetVehiclePos = { "SetVehiclePos", "ifff" }; + static const Native GetVehicleZAngle = { "GetVehicleZAngle", "iv" }; + static const Native GetVehicleRotationQuat = { "GetVehicleRotationQuat", "ivvvv" }; + static const Native GetVehicleDistanceFromPoint = { "GetVehicleDistanceFromPoint", "ifff" }; + static const Native SetVehicleZAngle = { "SetVehicleZAngle", "if" }; + static const Native SetVehicleParamsForPlayer = { "SetVehicleParamsForPlayer", "iiii" }; + static const Native ManualVehicleEngineAndLights = { "ManualVehicleEngineAndLights", "" }; + static const Native SetVehicleParamsEx = { "SetVehicleParamsEx", "iiiiiiii" }; + static const Native GetVehicleParamsEx = { "GetVehicleParamsEx", "ivvvvvvv" }; + static const Native SetVehicleToRespawn = { "SetVehicleToRespawn", "i" }; + static const Native LinkVehicleToInterior = { "LinkVehicleToInterior", "ii" }; + static const Native AddVehicleComponent = { "AddVehicleComponent", "ii" }; + static const Native RemoveVehicleComponent = { "RemoveVehicleComponent", "ii" }; + static const Native ChangeVehicleColor = { "ChangeVehicleColor", "iii" }; + static const Native ChangeVehiclePaintjob = { "ChangeVehiclePaintjob", "ii" }; + static const Native SetVehicleHealth = { "SetVehicleHealth", "if" }; + static const Native GetVehicleHealth = { "GetVehicleHealth", "iv" }; + static const Native AttachTrailerToVehicle = { "AttachTrailerToVehicle", "ii" }; + static const Native DetachTrailerFromVehicle = { "DetachTrailerFromVehicle", "i" }; + static const Native IsTrailerAttachedToVehicle = { "IsTrailerAttachedToVehicle", "i" }; + static const Native GetVehicleTrailer = { "GetVehicleTrailer", "i" }; + static const Native SetVehicleNumberPlate = { "SetVehicleNumberPlate", "is" }; + static const Native GetVehicleModel = { "GetVehicleModel", "i" }; + static const Native GetVehicleComponentInSlot = { "GetVehicleComponentInSlot", "ii" }; + static const Native GetVehicleComponentType = { "GetVehicleComponentType", "i" }; + static const Native RepairVehicle = { "RepairVehicle", "i" }; + static const Native GetVehicleVelocity = { "GetVehicleVelocity", "ivvv" }; + static const Native SetVehicleVelocity = { "SetVehicleVelocity", "ifff" }; + static const Native SetVehicleAngularVelocity = { "SetVehicleAngularVelocity", "ifff" }; + static const Native GetVehicleDamageStatus = { "GetVehicleDamageStatus", "ivvvv" }; + static const Native UpdateVehicleDamageStatus = { "UpdateVehicleDamageStatus", "iiiii" }; + static const Native GetVehicleModelInfo = { "GetVehicleModelInfo", "iivvv" }; + static const Native SetVehicleVirtualWorld = { "SetVehicleVirtualWorld", "ii" }; + static const Native GetVehicleVirtualWorld = { "GetVehicleVirtualWorld", "i" }; + + /* ******************************************** * + * a_objects.inc * + * ******************************************** */ + + // Objects + static const Native CreateObject = { "CreateObject", "ifffffff" }; + static const Native AttachObjectToVehicle = { "AttachObjectToVehicle", "iiffffff" }; + static const Native AttachObjectToObject = { "AttachObjectToObject", "iiffffffi" }; + static const Native AttachObjectToPlayer = { "AttachObjectToPlayer", "iiffffff" }; + static const Native SetObjectPos = { "SetObjectPos", "ifff" }; + static const Native GetObjectPos = { "GetObjectPos", "ivvv" }; + static const Native SetObjectRot = { "SetObjectRot", "ifff" }; + static const Native GetObjectRot = { "GetObjectRot", "ivvv" }; + static const Native IsValidObject = { "IsValidObject", "i" }; + static const Native DestroyObject = { "DestroyObject", "i" }; + static const Native MoveObject = { "MoveObject", "ifffffff" }; + static const Native StopObject = { "StopObject", "i" }; + static const Native IsObjectMoving = { "IsObjectMoving", "i" }; + static const Native EditObject = { "EditObject", "ii" }; + static const Native EditPlayerObject = { "EditPlayerObject", "ii" }; + static const Native SelectObject = { "SelectObject", "i" }; + static const Native CancelEdit = { "CancelEdit", "i" }; + static const Native CreatePlayerObject = { "CreatePlayerObject", "iifffffff" }; + static const Native AttachPlayerObjectToVehicle = { "AttachPlayerObjectToVehicle", "iiiffffff" }; + static const Native SetPlayerObjectPos = { "SetPlayerObjectPos", "iifff" }; + static const Native GetPlayerObjectPos = { "GetPlayerObjectPos", "iivvv" }; + static const Native SetPlayerObjectRot = { "SetPlayerObjectRot", "iifff" }; + static const Native GetPlayerObjectRot = { "GetPlayerObjectRot", "iivvv" }; + static const Native IsValidPlayerObject = { "IsValidPlayerObject", "ii" }; + static const Native DestroyPlayerObject = { "DestroyPlayerObject", "ii" }; + static const Native MovePlayerObject = { "MovePlayerObject", "iifffffff" }; + static const Native StopPlayerObject = { "StopPlayerObject", "ii" }; + static const Native IsPlayerObjectMoving = { "IsPlayerObjectMoving", "ii" }; + static const Native AttachPlayerObjectToPlayer = { "AttachPlayerObjectToPlayer", "iiiffffff" }; + static const Native SetObjectMaterial = { "SetObjectMaterial", "iiissi" }; + static const Native SetPlayerObjectMaterial = { "SetPlayerObjectMaterial", "iiiissi" }; + static const Native SetObjectMaterialText = { "SetObjectMaterialText", "isiiiiiiii" }; + static const Native SetPlayerObjectMaterialText = { "SetPlayerObjectMaterialText", "iisiiiiiiii" }; +}; + +class + Invoke +{ +public: + Invoke() + { + gotAddresses = false; + } + + + int callNative(const PAWN::Native * native, ...); + int getAddresses(); + + int amx_idx; + + std::list amx_list; + bool gotAddresses; +private: + std::map amx_map; +}; + +typedef int (* amx_Function_t)(AMX * amx, cell * params); + +extern Invoke *g_Invoke; diff --git a/sampdotnethook/src/Mono.cpp b/sampdotnethook/src/Mono.cpp new file mode 100644 index 0000000..715bcdb --- /dev/null +++ b/sampdotnethook/src/Mono.cpp @@ -0,0 +1,71 @@ +#include "Mono.h" + +Mono *g_Mono; + +void Mono::init() { + /*#ifndef __win32__ + mono_set_dirs ("../lib/", "/etc/mono"); + #endif*/ + + // Set up domain + this->domain = mono_jit_init_version("sampdotnet", "v2.0.50727"); + + // Set up assembly, image and class for Script.dll invoke + this->assembly = mono_domain_assembly_open(this->domain, "Script.dll"); + this->image = mono_assembly_get_image(this->assembly); + this->klass = mono_class_from_name(this->image, "Script", "Script"); + + // Invoke the loading method for Script.dll + this->callMethod("Script:Load", 0); + + // That last method invoke was the last time we'll be calling to Script.dll + this->assembly = mono_domain_assembly_open (this->domain, "sampdotnet.dll"); + this->image = mono_assembly_get_image (this->assembly); + this->klass = 0; // We don't need this anymore +} + +MonoString* Mono::createString(const char* string) { + return mono_string_new(this->domain, string); +} + +int Mono::callReturn(const char* name, void* args[]) { + // Set method parameters + MonoMethodDesc* desc = mono_method_desc_new(name, false); + MonoMethod* method = 0; + + // Determine if we're using the Class model or Image model + if(this->klass != 0) { + method = mono_method_desc_search_in_class(desc, this->klass); + } else { + method = mono_method_desc_search_in_image(desc, this->image); + } + + // Free MonoMethodDesc object + mono_method_desc_free(desc); + + // Invoke and return the value + MonoObject* result = mono_runtime_invoke(method, this->klass, args, 0); + int int_result = 0; + int_result = *(int*)mono_object_unbox(result); + return int_result; +} + +void Mono::callMethod(const char* name, void* args[]) { + // Set method parameters + MonoMethodDesc* desc = mono_method_desc_new(name, false); + MonoMethod* method = 0; + + // Determine if we're using the Class model or Image model + if(this->klass != 0) { + method = mono_method_desc_search_in_class(desc, this->klass); + } else { + method = mono_method_desc_search_in_image(desc, this->image); + } + + // Free MonoMethodDesc object + mono_method_desc_free(desc); + + // Invoke + mono_runtime_invoke(method, this->klass, args, 0); +} + diff --git a/sampdotnethook/src/Mono.h b/sampdotnethook/src/Mono.h new file mode 100644 index 0000000..5b68cb6 --- /dev/null +++ b/sampdotnethook/src/Mono.h @@ -0,0 +1,29 @@ +#ifndef MONO_H +#define MONO_H + +#include "common.h" +#include +#include + +#include +#include +#include + +class Mono { +public: + void init(); + MonoString* createString(const char* string); + int callReturn(const char* name, void* args[]); + void callMethod(const char* name, void* args[]); +private: + MonoDomain* domain; + MonoAssembly* assembly; + MonoImage* image; + MonoClass* klass; +}; + +extern Mono *g_Mono; + +#endif // MONO_H + + diff --git a/sampdotnethook/src/SDK/amx/amx.h b/sampdotnethook/src/SDK/amx/amx.h new file mode 100644 index 0000000..a787721 --- /dev/null +++ b/sampdotnethook/src/SDK/amx/amx.h @@ -0,0 +1,452 @@ +/* Pawn Abstract Machine (for the Pawn language) + * + * Copyright (c) ITB CompuPhase, 1997-2005 + * + * This software is provided "as-is", without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in + * a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Version: $Id: amx.h,v 1.5 2006/03/26 16:56:15 spookie Exp $ + */ + +#ifndef AMX_H_INCLUDED +#define AMX_H_INCLUDED + +#include + +#if defined __linux || defined __linux__ +#define __LINUX__ +#endif +#if defined FREEBSD && !defined __FreeBSD__ +#define __FreeBSD__ +#endif +#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ +#include "sclinux.h" +#endif + +#define HAVE_STDINT_H // Too much hassle for all of the conditionals for cross-platform support. + // Let's just get on with it and assume stdint.h is available + +#if defined HAVE_STDINT_H + #include +#else + #if defined __LCC__ || defined __DMC__ || defined __LINUX__ || (defined __WATCOMC__ && __WATCOMC__ >= 1200) + #if defined HAVE_INTTYPES_H + #include + #else + #include + #define HAS_STDINT_H + #endif + #elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L + #if !defined _STDINT_H + /* The ISO C99 defines the int16_t and int_32t types. If the compiler got + * here, these types are probably undefined. + */ + #if defined __MACH__ + #include + typedef unsigned short int uint16_t; + typedef unsigned long int uint32_t; + #elif defined __FreeBSD__ + #include + #else + typedef short int int16_t; + typedef unsigned short int uint16_t; + #if defined SN_TARGET_PS2 + typedef int int32_t; + typedef unsigned int uint32_t; + #else + typedef long int int32_t; + typedef unsigned long int uint32_t; + #endif + #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + typedef __int64 int64_t; + typedef unsigned __int64 uint64_t; + #define HAVE_I64 + #elif defined __GNUC__ + typedef long long int64_t; + typedef unsigned long long uint64_t; + #define HAVE_I64 + #endif // WIN32 + #endif // Unix + #endif // STDINT_H + #endif // STDC_VERSION + #define HAVE_STDINT_H +#endif +#if defined _LP64 || defined WIN64 || defined _WIN64 + #if !defined __64BIT__ + #define __64BIT__ + #endif +#endif + +#if HAVE_ALLOCA_H + #include +#endif +/*#if defined __WIN32__ || defined _WIN32 || defined WIN32 + #if !defined alloca + #define xalloca(n) _alloca(n) + #endif +#endif*/ + +#if !defined arraysize + #define arraysize(array) (sizeof(array) / sizeof((array)[0])) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined PAWN_DLL + #if !defined AMX_NATIVE_CALL + #define AMX_NATIVE_CALL __stdcall + #endif + #if !defined AMXAPI + #define AMXAPI __stdcall + #endif +#endif + +/* calling convention for native functions */ +#if !defined AMX_NATIVE_CALL + #define AMX_NATIVE_CALL +#endif +/* calling convention for all interface functions and callback functions */ +#if !defined AMXAPI + #if defined STDECL + #define AMXAPI __stdcall + #elif defined CDECL + #define AMXAPI __cdecl + #elif defined GCC_HASCLASSVISIBILITY + #define AMXAPI __attribute__ ((visibility("default"))) + #else + #define AMXAPI + #endif +#endif +#if !defined AMXEXPORT + #define AMXEXPORT +#endif + +/* File format version Required AMX version + * 0 (original version) 0 + * 1 (opcodes JUMP.pri, SWITCH and CASETBL) 1 + * 2 (compressed files) 2 + * 3 (public variables) 2 + * 4 (opcodes SWAP.pri/alt and PUSHADDR) 4 + * 5 (tagnames table) 4 + * 6 (reformatted header) 6 + * 7 (name table, opcodes SYMTAG & SYSREQ.D) 7 + * 8 (opcode STMT, renewed debug interface) 8 + */ +#define CUR_FILE_VERSION 8 /* current file version; also the current AMX version */ +#define MIN_FILE_VERSION 6 /* lowest supported file format version for the current AMX version */ +#define MIN_AMX_VERSION 8 /* minimum AMX version needed to support the current file format */ + +#if !defined PAWN_CELL_SIZE + #define PAWN_CELL_SIZE 32 /* by default, use 32-bit cells */ +#endif +#if PAWN_CELL_SIZE==16 + typedef uint16_t ucell; + typedef int16_t cell; +#elif PAWN_CELL_SIZE==32 + typedef uint32_t ucell; + typedef int32_t cell; +#elif PAWN_CELL_SIZE==64 + typedef uint64_t ucell; + typedef int64_t cell; +#else + #error Unsupported cell size (PAWN_CELL_SIZE) +#endif + +#define UNPACKEDMAX ((1L << (sizeof(cell)-1)*8) - 1) +#define UNLIMITED (~1u >> 1) + +struct tagAMX; +typedef cell (AMX_NATIVE_CALL *AMX_NATIVE)(struct tagAMX *amx, cell *params); +typedef int (AMXAPI *AMX_CALLBACK)(struct tagAMX *amx, cell index, + cell *result, cell *params); +typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx); +#if !defined _FAR + #define _FAR +#endif + +#if defined _MSC_VER + #pragma warning(disable:4103) /* disable warning message 4103 that complains + * about pragma pack in a header file */ + #pragma warning(disable:4100) /* "'%$S' : unreferenced formal parameter" */ +#endif + +/* Some compilers do not support the #pragma align, which should be fine. Some + * compilers give a warning on unknown #pragmas, which is not so fine... + */ +#if (defined SN_TARGET_PS2 || defined __GNUC__) && !defined AMX_NO_ALIGN + #define AMX_NO_ALIGN +#endif + +#if defined __GNUC__ + #define PACKED __attribute__((packed)) +#else + #define PACKED +#endif + +#if !defined AMX_NO_ALIGN + #if defined __LINUX__ || defined __FreeBSD__ + #pragma pack(1) /* structures must be packed (byte-aligned) */ + #elif defined MACOS && defined __MWERKS__ + #pragma options align=mac68k + #else + #pragma pack(push) + #pragma pack(1) /* structures must be packed (byte-aligned) */ + #if defined __TURBOC__ + #pragma option -a- /* "pack" pragma for older Borland compilers */ + #endif + #endif +#endif + +typedef struct tagAMX_NATIVE_INFO { + const char _FAR *name PACKED; + AMX_NATIVE func PACKED; +} PACKED AMX_NATIVE_INFO; + +#define AMX_USERNUM 4 +#define sEXPMAX 19 /* maximum name length for file version <= 6 */ +#define sNAMEMAX 31 /* maximum name length of symbol name */ + +typedef struct tagAMX_FUNCSTUB { + ucell address PACKED; + char name[sEXPMAX+1]; +} PACKED AMX_FUNCSTUB; + +typedef struct tagFUNCSTUBNT { + ucell address PACKED; + uint32_t nameofs PACKED; +} PACKED AMX_FUNCSTUBNT; + +/* The AMX structure is the internal structure for many functions. Not all + * fields are valid at all times; many fields are cached in local variables. + */ +typedef struct tagAMX { + unsigned char _FAR *base PACKED; /* points to the AMX header plus the code, optionally also the data */ + unsigned char _FAR *data PACKED; /* points to separate data+stack+heap, may be NULL */ + AMX_CALLBACK callback PACKED; + AMX_DEBUG debug PACKED; /* debug callback */ + /* for external functions a few registers must be accessible from the outside */ + cell cip PACKED; /* instruction pointer: relative to base + amxhdr->cod */ + cell frm PACKED; /* stack frame base: relative to base + amxhdr->dat */ + cell hea PACKED; /* top of the heap: relative to base + amxhdr->dat */ + cell hlw PACKED; /* bottom of the heap: relative to base + amxhdr->dat */ + cell stk PACKED; /* stack pointer: relative to base + amxhdr->dat */ + cell stp PACKED; /* top of the stack: relative to base + amxhdr->dat */ + int flags PACKED; /* current status, see amx_Flags() */ + /* user data */ + long usertags[AMX_USERNUM] PACKED; + void _FAR *userdata[AMX_USERNUM] PACKED; + /* native functions can raise an error */ + int error PACKED; + /* passing parameters requires a "count" field */ + int paramcount; + /* the sleep opcode needs to store the full AMX status */ + cell pri PACKED; + cell alt PACKED; + cell reset_stk PACKED; + cell reset_hea PACKED; + cell sysreq_d PACKED; /* relocated address/value for the SYSREQ.D opcode */ + #if defined JIT + /* support variables for the JIT */ + int reloc_size PACKED; /* required temporary buffer for relocations */ + long code_size PACKED; /* estimated memory footprint of the native code */ + #endif +} PACKED AMX; + +/* The AMX_HEADER structure is both the memory format as the file format. The + * structure is used internaly. + */ +typedef struct tagAMX_HEADER { + int32_t size PACKED; /* size of the "file" */ + uint16_t magic PACKED; /* signature */ + char file_version; /* file format version */ + char amx_version; /* required version of the AMX */ + int16_t flags PACKED; + int16_t defsize PACKED; /* size of a definition record */ + int32_t cod PACKED; /* initial value of COD - code block */ + int32_t dat PACKED; /* initial value of DAT - data block */ + int32_t hea PACKED; /* initial value of HEA - start of the heap */ + int32_t stp PACKED; /* initial value of STP - stack top */ + int32_t cip PACKED; /* initial value of CIP - the instruction pointer */ + int32_t publics PACKED; /* offset to the "public functions" table */ + int32_t natives PACKED; /* offset to the "native functions" table */ + int32_t libraries PACKED; /* offset to the table of libraries */ + int32_t pubvars PACKED; /* the "public variables" table */ + int32_t tags PACKED; /* the "public tagnames" table */ + int32_t nametable PACKED; /* name table */ +} PACKED AMX_HEADER; + +#if PAWN_CELL_SIZE==16 + #define AMX_MAGIC 0xf1e2 +#elif PAWN_CELL_SIZE==32 + #define AMX_MAGIC 0xf1e0 +#elif PAWN_CELL_SIZE==64 + #define AMX_MAGIC 0xf1e1 +#endif + +enum +{ + AMX_ERR_NONE, + /* reserve the first 15 error codes for exit codes of the abstract machine */ + AMX_ERR_EXIT, /* forced exit */ + AMX_ERR_ASSERT, /* assertion failed */ + AMX_ERR_STACKERR, /* stack/heap collision */ + AMX_ERR_BOUNDS, /* index out of bounds */ + AMX_ERR_MEMACCESS, /* invalid memory access */ + AMX_ERR_INVINSTR, /* invalid instruction */ + AMX_ERR_STACKLOW, /* stack underflow */ + AMX_ERR_HEAPLOW, /* heap underflow */ + AMX_ERR_CALLBACK, /* no callback, or invalid callback */ + AMX_ERR_NATIVE, /* native function failed */ + AMX_ERR_DIVIDE, /* divide by zero */ + AMX_ERR_SLEEP, /* go into sleepmode - code can be restarted */ + AMX_ERR_INVSTATE, /* invalid state for this access */ + + AMX_ERR_MEMORY = 16, /* out of memory */ + AMX_ERR_FORMAT, /* invalid file format */ + AMX_ERR_VERSION, /* file is for a newer version of the AMX */ + AMX_ERR_NOTFOUND, /* function not found */ + AMX_ERR_INDEX, /* invalid index parameter (bad entry point) */ + AMX_ERR_DEBUG, /* debugger cannot run */ + AMX_ERR_INIT, /* AMX not initialized (or doubly initialized) */ + AMX_ERR_USERDATA, /* unable to set user data field (table full) */ + AMX_ERR_INIT_JIT, /* cannot initialize the JIT */ + AMX_ERR_PARAMS, /* parameter error */ + AMX_ERR_DOMAIN, /* domain error, expression result does not fit in range */ + AMX_ERR_GENERAL, /* general error (unknown or unspecific error) */ +}; + +/* AMX_FLAG_CHAR16 0x01 no longer used */ +#define AMX_FLAG_DEBUG 0x02 /* symbolic info. available */ +#define AMX_FLAG_COMPACT 0x04 /* compact encoding */ +#define AMX_FLAG_BYTEOPC 0x08 /* opcode is a byte (not a cell) */ +#define AMX_FLAG_NOCHECKS 0x10 /* no array bounds checking; no STMT opcode */ +#define AMX_FLAG_NTVREG 0x1000 /* all native functions are registered */ +#define AMX_FLAG_JITC 0x2000 /* abstract machine is JIT compiled */ +#define AMX_FLAG_BROWSE 0x4000 /* busy browsing */ +#define AMX_FLAG_RELOC 0x8000 /* jump/call addresses relocated */ + +#define AMX_EXEC_MAIN -1 /* start at program entry point */ +#define AMX_EXEC_CONT -2 /* continue from last address */ + +#define AMX_USERTAG(a,b,c,d) ((a) | ((b)<<8) | ((long)(c)<<16) | ((long)(d)<<24)) + +#if !defined AMX_COMPACTMARGIN + #define AMX_COMPACTMARGIN 64 +#endif + +/* for native functions that use floating point parameters, the following + * two macros are convenient for casting a "cell" into a "float" type _without_ + * changing the bit pattern + */ +#if PAWN_CELL_SIZE==32 + #define amx_ftoc(f) ( * ((cell*)&f) ) /* float to cell */ + #define amx_ctof(c) ( * ((float*)&c) ) /* cell to float */ +#elif PAWN_CELL_SIZE==64 + #define amx_ftoc(f) ( * ((cell*)&f) ) /* float to cell */ + #define amx_ctof(c) ( * ((double*)&c) ) /* cell to float */ +#else + #error Unsupported cell size +#endif + +#define amx_StrParam(amx,param,result) \ + do { \ + cell *amx_cstr_; int amx_length_; \ + amx_GetAddr((amx), (param), &amx_cstr_); \ + amx_StrLen(amx_cstr_, &amx_length_); \ + if (amx_length_ > 0 && \ + ((result) = (char*)alloca((amx_length_ + 1) * sizeof(*(result)))) != NULL) \ + amx_GetString((char*)(result), amx_cstr_, sizeof(*(result))>1, amx_length_ + 1); \ + else (result) = NULL; \ + } while (0) + +uint16_t * AMXAPI amx_Align16(uint16_t *v); +uint32_t * AMXAPI amx_Align32(uint32_t *v); +#if defined _I64_MAX || defined HAVE_I64 + uint64_t * AMXAPI amx_Align64(uint64_t *v); +#endif +int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr); +int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params); +int AMXAPI amx_Cleanup(AMX *amx); +int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data); +int AMXAPI amx_Exec(AMX *amx, cell *retval, int index); +int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index); +int AMXAPI amx_FindPublic(AMX *amx, const char *funcname, int *index); +int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr); +int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname); +int AMXAPI amx_Flags(AMX *amx,uint16_t *flags); +int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr); +int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname); +int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname); +int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr); +int AMXAPI amx_GetString(char *dest,const cell *source, int use_wchar, size_t size); +int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id); +int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr); +int AMXAPI amx_Init(AMX *amx, void *program); +int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code); +int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap); +int AMXAPI amx_NameLength(AMX *amx, int *length); +AMX_NATIVE_INFO * AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func); +int AMXAPI amx_NumNatives(AMX *amx, int *number); +int AMXAPI amx_NumPublics(AMX *amx, int *number); +int AMXAPI amx_NumPubVars(AMX *amx, int *number); +int AMXAPI amx_NumTags(AMX *amx, int *number); +int AMXAPI amx_Push(AMX *amx, cell value); +int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells); +int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar); +int AMXAPI amx_RaiseError(AMX *amx, int error); +int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number); +int AMXAPI amx_Release(AMX *amx, cell amx_addr); +int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback); +int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug); +int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size); +int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr); +int AMXAPI amx_StrLen(const cell *cstring, int *length); +int AMXAPI amx_UTF8Check(const char *string, int *length); +int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value); +int AMXAPI amx_UTF8Len(const cell *cstr, int *length); +int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value); + +#if PAWN_CELL_SIZE==16 + #define amx_AlignCell(v) amx_Align16(v) +#elif PAWN_CELL_SIZE==32 + #define amx_AlignCell(v) amx_Align32(v) +#elif PAWN_CELL_SIZE==64 && (defined _I64_MAX || defined HAVE_I64) + #define amx_AlignCell(v) amx_Align64(v) +#else + #error Unsupported cell size +#endif + +#define amx_RegisterFunc(amx, name, func) \ + amx_Register((amx), amx_NativeInfo((name),(func)), 1); + +#if !defined AMX_NO_ALIGN + #if defined __LINUX__ || defined __FreeBSD__ + #pragma pack() /* reset default packing */ + #elif defined MACOS && defined __MWERKS__ + #pragma options align=reset + #else + #pragma pack(pop) /* reset previous packing */ + #endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* AMX_H_INCLUDED */ + diff --git a/sampdotnethook/src/SDK/amx/sclinux.h b/sampdotnethook/src/SDK/amx/sclinux.h new file mode 100644 index 0000000..774ecfa --- /dev/null +++ b/sampdotnethook/src/SDK/amx/sclinux.h @@ -0,0 +1,37 @@ +/* + * Things needed to compile under linux. + * + * Should be reworked totally to use GNU's 'configure' + */ +#ifndef SCLINUX_H +#define SCLINUX_H + +#define stricmp(a,b) strcasecmp(a,b) +#define strnicmp(a,b,c) strncasecmp(a,b,c) + +/* + * WinWorld wants '\'. Unices do not. + */ +#define DIRECTORY_SEP_CHAR '/' +#define DIRECTORY_SEP_STR "/" + +/* + * SC assumes that a computer is Little Endian unless told otherwise. It uses + * (and defines) the macros BYTE_ORDER and BIG_ENDIAN. + * For Linux, we must overrule these settings with those defined in glibc. + */ +#if !defined __BYTE_ORDER +# include +#endif + +#if defined __OpenBSD__ || defined __FreeBSD__ +# define __BYTE_ORDER BYTE_ORDER +# define __LITTLE_ENDIAN LITTLE_ENDIAN +# define __BIG_ENDIAN BIG_ENDIAN +#endif + +#if !defined __BYTE_ORDER +# error "Can't figure computer byte order (__BYTE_ORDER macro not found)" +#endif + +#endif /* SCLINUX_H */ diff --git a/sampdotnethook/src/SDK/amxplugin.cpp b/sampdotnethook/src/SDK/amxplugin.cpp new file mode 100644 index 0000000..0a392ac --- /dev/null +++ b/sampdotnethook/src/SDK/amxplugin.cpp @@ -0,0 +1,334 @@ +//---------------------------------------------------------- +// +// SA-MP Multiplayer Modification For GTA:SA +// Copyright 2004-2009 SA-MP Team +// +//---------------------------------------------------------- +// +// This provides an interface to call amx library functions +// within samp-server. +// +//---------------------------------------------------------- + +#include "amx/amx.h" +#include "plugincommon.h" + +//---------------------------------------------------------- + +void *pAMXFunctions; + +//---------------------------------------------------------- + +typedef uint16_t * AMXAPI (*amx_Align16_t)(uint16_t *v); +uint16_t * AMXAPI amx_Align16(uint16_t *v) +{ + amx_Align16_t fn = ((amx_Align16_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Align16]; + return fn(v); +} + +typedef uint32_t * AMXAPI (*amx_Align32_t)(uint32_t *v); +uint32_t * AMXAPI amx_Align32(uint32_t *v) +{ + amx_Align32_t fn = ((amx_Align32_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Align32]; + return fn(v); +} + +#if defined _I64_MAX || defined HAVE_I64 +typedef uint64_t * AMXAPI (*amx_Align64_t)(uint64_t *v); + uint64_t * AMXAPI amx_Align64(uint64_t *v) +{ + amx_Align64_t fn = ((amx_Align64_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Align64]; + return fn(v); +} + +#endif +typedef int AMXAPI (*amx_Allot_t)(AMX *amx, int cells, cell *amx_addr, cell **phys_addr); +int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr) +{ + amx_Allot_t fn = ((amx_Allot_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Allot]; + return fn(amx, cells, amx_addr, phys_addr); +} + +typedef int AMXAPI (*amx_Callback_t)(AMX *amx, cell index, cell *result, cell *params); +int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params) +{ + amx_Callback_t fn = ((amx_Callback_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Callback]; + return fn(amx, index, result, params); +} + +typedef int AMXAPI (*amx_Cleanup_t)(AMX *amx); +int AMXAPI amx_Cleanup(AMX *amx) +{ + amx_Cleanup_t fn = ((amx_Cleanup_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Cleanup]; + return fn(amx); +} + +typedef int AMXAPI (*amx_Clone_t)(AMX *amxClone, AMX *amxSource, void *data); +int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data) +{ + amx_Clone_t fn = ((amx_Clone_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Clone]; + return fn(amxClone, amxSource, data); +} + +typedef int AMXAPI (*amx_Exec_t)(AMX *amx, cell *retval, int index); +int AMXAPI amx_Exec(AMX *amx, cell *retval, int index) +{ + amx_Exec_t fn = ((amx_Exec_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Exec]; + return fn(amx, retval, index); +} + +typedef int AMXAPI (*amx_FindNative_t)(AMX *amx, const char *name, int *index); +int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index) +{ + amx_FindNative_t fn = ((amx_FindNative_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindNative]; + return fn(amx, name, index); +} + +typedef int AMXAPI (*amx_FindPublic_t)(AMX *amx, const char *funcname, int *index); +int AMXAPI amx_FindPublic(AMX *amx, const char *funcname, int *index) +{ + amx_FindPublic_t fn = ((amx_FindPublic_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindPublic]; + return fn(amx, funcname, index); +} + +typedef int AMXAPI (*amx_FindPubVar_t)(AMX *amx, const char *varname, cell *amx_addr); +int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr) +{ + amx_FindPubVar_t fn = ((amx_FindPubVar_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindPubVar]; + return fn(amx, varname, amx_addr); +} + +typedef int AMXAPI (*amx_FindTagId_t)(AMX *amx, cell tag_id, char *tagname); +int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname) +{ + amx_FindTagId_t fn = ((amx_FindTagId_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindTagId]; + return fn(amx, tag_id, tagname); +} + +typedef int AMXAPI (*amx_Flags_t)(AMX *amx,uint16_t *flags); +int AMXAPI amx_Flags(AMX *amx,uint16_t *flags) +{ + amx_Flags_t fn = ((amx_Flags_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Flags]; + return fn(amx,flags); +} + +typedef int AMXAPI (*amx_GetAddr_t)(AMX *amx,cell amx_addr,cell **phys_addr); +int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr) +{ + amx_GetAddr_t fn = ((amx_GetAddr_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetAddr]; + return fn(amx,amx_addr,phys_addr); +} + +typedef int AMXAPI (*amx_GetNative_t)(AMX *amx, int index, char *funcname); +int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname) +{ + amx_GetNative_t fn = ((amx_GetNative_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetNative]; + return fn(amx, index, funcname); +} + +typedef int AMXAPI (*amx_GetPublic_t)(AMX *amx, int index, char *funcname); +int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname) +{ + amx_GetPublic_t fn = ((amx_GetPublic_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetPublic]; + return fn(amx, index, funcname); +} + +typedef int AMXAPI (*amx_GetPubVar_t)(AMX *amx, int index, char *varname, cell *amx_addr); +int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr) +{ + amx_GetPubVar_t fn = ((amx_GetPubVar_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetPubVar]; + return fn(amx, index, varname, amx_addr); +} + +typedef int AMXAPI (*amx_GetString_t)(char *dest,const cell *source, int use_wchar, size_t size); +int AMXAPI amx_GetString(char *dest,const cell *source, int use_wchar, size_t size) +{ + amx_GetString_t fn = ((amx_GetString_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetString]; + return fn(dest,source, use_wchar, size); +} + +typedef int AMXAPI (*amx_GetTag_t)(AMX *amx, int index, char *tagname, cell *tag_id); +int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id) +{ + amx_GetTag_t fn = ((amx_GetTag_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetTag]; + return fn(amx, index, tagname, tag_id); +} + +typedef int AMXAPI (*amx_GetUserData_t)(AMX *amx, long tag, void **ptr); +int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr) +{ + amx_GetUserData_t fn = ((amx_GetUserData_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetUserData]; + return fn(amx, tag, ptr); +} + +typedef int AMXAPI (*amx_Init_t)(AMX *amx, void *program); +int AMXAPI amx_Init(AMX *amx, void *program) +{ + amx_Init_t fn = ((amx_Init_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Init]; + return fn(amx, program); +} + +typedef int AMXAPI (*amx_InitJIT_t)(AMX *amx, void *reloc_table, void *native_code); +int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code) +{ + amx_InitJIT_t fn = ((amx_InitJIT_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_InitJIT]; + return fn(amx, reloc_table, native_code); +} + +typedef int AMXAPI (*amx_MemInfo_t)(AMX *amx, long *codesize, long *datasize, long *stackheap); +int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap) +{ + amx_MemInfo_t fn = ((amx_MemInfo_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_MemInfo]; + return fn(amx, codesize, datasize, stackheap); +} + +typedef int AMXAPI (*amx_NameLength_t)(AMX *amx, int *length); +int AMXAPI amx_NameLength(AMX *amx, int *length) +{ + amx_NameLength_t fn = ((amx_NameLength_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NameLength]; + return fn(amx, length); +} + +typedef AMX_NATIVE_INFO * AMXAPI (*amx_NativeInfo_t)(const char *name, AMX_NATIVE func); +AMX_NATIVE_INFO * AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func) +{ + amx_NativeInfo_t fn = ((amx_NativeInfo_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NativeInfo]; + return fn(name, func); +} + +typedef int AMXAPI (*amx_NumNatives_t)(AMX *amx, int *number); +int AMXAPI amx_NumNatives(AMX *amx, int *number) +{ + amx_NumNatives_t fn = ((amx_NumNatives_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumNatives]; + return fn(amx, number); +} + +typedef int AMXAPI (*amx_NumPublics_t)(AMX *amx, int *number); +int AMXAPI amx_NumPublics(AMX *amx, int *number) +{ + amx_NumPublics_t fn = ((amx_NumPublics_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumPublics]; + return fn(amx, number); +} + +typedef int AMXAPI (*amx_NumPubVars_t)(AMX *amx, int *number); +int AMXAPI amx_NumPubVars(AMX *amx, int *number) +{ + amx_NumPubVars_t fn = ((amx_NumPubVars_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumPubVars]; + return fn(amx, number); +} + +typedef int AMXAPI (*amx_NumTags_t)(AMX *amx, int *number); +int AMXAPI amx_NumTags(AMX *amx, int *number) +{ + amx_NumTags_t fn = ((amx_NumTags_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumTags]; + return fn(amx, number); +} + +typedef int AMXAPI (*amx_Push_t)(AMX *amx, cell value); +int AMXAPI amx_Push(AMX *amx, cell value) +{ + amx_Push_t fn = ((amx_Push_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Push]; + return fn(amx, value); +} + +typedef int AMXAPI (*amx_PushArray_t)(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells); +int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells) +{ + amx_PushArray_t fn = ((amx_PushArray_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_PushArray]; + return fn(amx, amx_addr, phys_addr, array, numcells); +} + +typedef int AMXAPI (*amx_PushString_t)(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar); +int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar) +{ + amx_PushString_t fn = ((amx_PushString_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_PushString]; + return fn(amx, amx_addr, phys_addr, string, pack, use_wchar); +} + +typedef int AMXAPI (*amx_RaiseError_t)(AMX *amx, int error); +int AMXAPI amx_RaiseError(AMX *amx, int error) +{ + amx_RaiseError_t fn = ((amx_RaiseError_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_RaiseError]; + return fn(amx, error); +} + +typedef int AMXAPI (*amx_Register_t)(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number); +int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number) +{ + amx_Register_t fn = ((amx_Register_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Register]; + return fn(amx, nativelist, number); +} + +typedef int AMXAPI (*amx_Release_t)(AMX *amx, cell amx_addr); +int AMXAPI amx_Release(AMX *amx, cell amx_addr) +{ + amx_Release_t fn = ((amx_Release_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Release]; + return fn(amx, amx_addr); +} + +typedef int AMXAPI (*amx_SetCallback_t)(AMX *amx, AMX_CALLBACK callback); +int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback) +{ + amx_SetCallback_t fn = ((amx_SetCallback_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetCallback]; + return fn(amx, callback); +} + +typedef int AMXAPI (*amx_SetDebugHook_t)(AMX *amx, AMX_DEBUG debug); +int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug) +{ + amx_SetDebugHook_t fn = ((amx_SetDebugHook_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetDebugHook]; + return fn(amx, debug); +} + +typedef int AMXAPI (*amx_SetString_t)(cell *dest, const char *source, int pack, int use_wchar, size_t size); +int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size) +{ + amx_SetString_t fn = ((amx_SetString_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetString]; + return fn(dest, source, pack, use_wchar, size); +} + +typedef int AMXAPI (*amx_SetUserData_t)(AMX *amx, long tag, void *ptr); +int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr) +{ + amx_SetUserData_t fn = ((amx_SetUserData_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetUserData]; + return fn(amx, tag, ptr); +} + +typedef int AMXAPI (*amx_StrLen_t)(const cell *cstring, int *length); +int AMXAPI amx_StrLen(const cell *cstring, int *length) +{ + amx_StrLen_t fn = ((amx_StrLen_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_StrLen]; + return fn(cstring, length); +} + +typedef int AMXAPI (*amx_UTF8Check_t)(const char *string, int *length); +int AMXAPI amx_UTF8Check(const char *string, int *length) +{ + amx_UTF8Check_t fn = ((amx_UTF8Check_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Check]; + return fn(string, length); +} + +typedef int AMXAPI (*amx_UTF8Get_t)(const char *string, const char **endptr, cell *value); +int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value) +{ + amx_UTF8Get_t fn = ((amx_UTF8Get_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Get]; + return fn(string, endptr, value); +} + +typedef int AMXAPI (*amx_UTF8Len_t)(const cell *cstr, int *length); +int AMXAPI amx_UTF8Len(const cell *cstr, int *length) +{ + amx_UTF8Len_t fn = ((amx_UTF8Len_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Len]; + return fn(cstr, length); +} + +typedef int AMXAPI (*amx_UTF8Put_t)(char *string, char **endptr, int maxchars, cell value); +int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value) +{ + amx_UTF8Put_t fn = ((amx_UTF8Put_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Put]; + return fn(string, endptr, maxchars, value); +} + +//---------------------------------------------------------- +// EOF + diff --git a/sampdotnethook/src/SDK/plugincommon.h b/sampdotnethook/src/SDK/plugincommon.h new file mode 100644 index 0000000..e9120b7 --- /dev/null +++ b/sampdotnethook/src/SDK/plugincommon.h @@ -0,0 +1,119 @@ +//---------------------------------------------------------- +// +// SA-MP Multiplayer Modification For GTA:SA +// Copyright 2004-2009 SA-MP Team +// +//---------------------------------------------------------- + +#pragma once + +//---------------------------------------------------------- + +#define SAMP_PLUGIN_VERSION 0x0200 + +//---------------------------------------------------------- + +#ifdef __cplusplus + #define PLUGIN_EXTERN_C extern "C" +#else + #define PLUGIN_EXTERN_C +#endif + +#if defined(__LINUX__) || defined(__FreeBSD__) || defined(__OpenBSD__) + #ifndef __GNUC__ + #pragma message "Warning: Not using a GNU compiler." + #endif + #define PLUGIN_CALL + #ifndef SAMPSVR + // Compile code with -fvisibility=hidden to hide non-exported functions. + #define PLUGIN_EXPORT PLUGIN_EXTERN_C __attribute__((visibility("default"))) + #else + #define PLUGIN_EXPORT PLUGIN_EXTERN_C + #endif +#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) + #ifndef _MSC_VER +// #pragma message "Warning: Not using a VC++ compiler." + #endif + #define PLUGIN_CALL __stdcall +// #define PLUGIN_CALL __cdecl + #define PLUGIN_EXPORT PLUGIN_EXTERN_C __declspec( dllexport ) +#else + #error "You must define one of WIN32, LINUX or FREEBSD" +#endif + +//---------------------------------------------------------- + +enum SUPPORTS_FLAGS +{ + SUPPORTS_VERSION = SAMP_PLUGIN_VERSION, + SUPPORTS_VERSION_MASK = 0xffff, + SUPPORTS_AMX_NATIVES = 0x10000, + SUPPORTS_PROCESS_TICK = 0x20000 +}; + +//---------------------------------------------------------- + +enum PLUGIN_DATA_TYPE +{ + // For some debugging + PLUGIN_DATA_LOGPRINTF = 0x00, // void (*logprintf)(char* format, ...) + + // AMX + PLUGIN_DATA_AMX_EXPORTS = 0x10, // void* AmxFunctionTable[] (see PLUGIN_AMX_EXPORT) + PLUGIN_DATA_CALLPUBLIC_FS = 0x11, // int (*AmxCallPublicFilterScript)(char *szFunctionName) + PLUGIN_DATA_CALLPUBLIC_GM = 0x12, // int (*AmxCallPublicGameMode)(char *szFunctionName) + +}; + +//---------------------------------------------------------- + +enum PLUGIN_AMX_EXPORT +{ + PLUGIN_AMX_EXPORT_Align16 = 0, + PLUGIN_AMX_EXPORT_Align32 = 1, + PLUGIN_AMX_EXPORT_Align64 = 2, + PLUGIN_AMX_EXPORT_Allot = 3, + PLUGIN_AMX_EXPORT_Callback = 4, + PLUGIN_AMX_EXPORT_Cleanup = 5, + PLUGIN_AMX_EXPORT_Clone = 6, + PLUGIN_AMX_EXPORT_Exec = 7, + PLUGIN_AMX_EXPORT_FindNative = 8, + PLUGIN_AMX_EXPORT_FindPublic = 9, + PLUGIN_AMX_EXPORT_FindPubVar = 10, + PLUGIN_AMX_EXPORT_FindTagId = 11, + PLUGIN_AMX_EXPORT_Flags = 12, + PLUGIN_AMX_EXPORT_GetAddr = 13, + PLUGIN_AMX_EXPORT_GetNative = 14, + PLUGIN_AMX_EXPORT_GetPublic = 15, + PLUGIN_AMX_EXPORT_GetPubVar = 16, + PLUGIN_AMX_EXPORT_GetString = 17, + PLUGIN_AMX_EXPORT_GetTag = 18, + PLUGIN_AMX_EXPORT_GetUserData = 19, + PLUGIN_AMX_EXPORT_Init = 20, + PLUGIN_AMX_EXPORT_InitJIT = 21, + PLUGIN_AMX_EXPORT_MemInfo = 22, + PLUGIN_AMX_EXPORT_NameLength = 23, + PLUGIN_AMX_EXPORT_NativeInfo = 24, + PLUGIN_AMX_EXPORT_NumNatives = 25, + PLUGIN_AMX_EXPORT_NumPublics = 26, + PLUGIN_AMX_EXPORT_NumPubVars = 27, + PLUGIN_AMX_EXPORT_NumTags = 28, + PLUGIN_AMX_EXPORT_Push = 29, + PLUGIN_AMX_EXPORT_PushArray = 30, + PLUGIN_AMX_EXPORT_PushString = 31, + PLUGIN_AMX_EXPORT_RaiseError = 32, + PLUGIN_AMX_EXPORT_Register = 33, + PLUGIN_AMX_EXPORT_Release = 34, + PLUGIN_AMX_EXPORT_SetCallback = 35, + PLUGIN_AMX_EXPORT_SetDebugHook = 36, + PLUGIN_AMX_EXPORT_SetString = 37, + PLUGIN_AMX_EXPORT_SetUserData = 38, + PLUGIN_AMX_EXPORT_StrLen = 39, + PLUGIN_AMX_EXPORT_UTF8Check = 40, + PLUGIN_AMX_EXPORT_UTF8Get = 41, + PLUGIN_AMX_EXPORT_UTF8Len = 42, + PLUGIN_AMX_EXPORT_UTF8Put = 43, +}; + +//---------------------------------------------------------- +// EOF diff --git a/sampdotnethook/src/a_players.cpp b/sampdotnethook/src/a_players.cpp new file mode 100644 index 0000000..a600c61 --- /dev/null +++ b/sampdotnethook/src/a_players.cpp @@ -0,0 +1,618 @@ +#include "a_samp.h" + +void _samp_SetSpawnInfo(int playerid, int team, int skin, float x, float y, float z, float rotation, int weapon1, int weapon1_ammo, int weapon2, int weapon2_ammo, int weapon3, int weapon3_ammo) { + g_Invoke->callNative(&PAWN::SetSpawnInfo, playerid, team, skin, x, y, z, rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo); +} + +void _samp_SpawnPlayer(int playerid) { + g_Invoke->callNative(&PAWN::SpawnPlayer, playerid); +} + +void _samp_SetPlayerPos(int playerid, float x, float y, float z) { + g_Invoke->callNative(&PAWN::SetPlayerPos, playerid, x, y, z); +} + +void _samp_SetPlayerPosFindZ(int playerid, float x, float y, float z) { + g_Invoke->callNative(&PAWN::SetPlayerPosFindZ, playerid, x, y, z); +} + +void _samp_GetPlayerPos(int playerid, float& x, float& y, float& z) { + float _x = 0.0; + float _y = 0.0; + float _z = 0.0; + g_Invoke->callNative(&PAWN::GetPlayerPos, playerid, &_x, &_y, &_z); + x = _x; + y = _y; + z = _z; +} + +void _samp_SetPlayerFacingAngle(int playerid, float ang) { + g_Invoke->callNative(&PAWN::SetPlayerFacingAngle, playerid, ang); +} + +void _samp_GetPlayerFacingAngle(int playerid, float& ang) { + float _ang = 0.0; + g_Invoke->callNative(&PAWN::GetPlayerFacingAngle, playerid, &_ang); + ang = _ang; +} + +/*void IsPlayerInRangeOfPoint(int playerid, float range, float x, float y, float z) { + g_Invoke->callNative(&PAWN::IsPlayerInRangeOfPoint, playerid, range, x, y, z); +}*/ + +/*float GetPlayerDistanceFromPoint(int playerid, float x, float y, float z) { + return (float)g_Invoke->callNative(&PAWN::GetPlayerDistanceFromPoint, playerid, x, y, z); +}*/ + +int _samp_IsPlayerStreamedIn(int playerid, int forplayerid) { + return g_Invoke->callNative(&PAWN::IsPlayerStreamedIn, playerid, forplayerid); +} + +void _samp_SetPlayerInterior(int playerid, int interiorid) { + g_Invoke->callNative(&PAWN::SetPlayerInterior, playerid, interiorid); +} + +int _samp_GetPlayerInterior(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerInterior, playerid); +} + +void _samp_SetPlayerHealth(int playerid, float health) { + g_Invoke->callNative(&PAWN::SetPlayerHealth, playerid, health); +} + +void _samp_GetPlayerHealth(int playerid, float& health) { + float _health = 0.0; + g_Invoke->callNative(&PAWN::GetPlayerHealth, playerid, &_health); + health = _health; +} + +void _samp_SetPlayerArmour(int playerid, float armour) { + g_Invoke->callNative(&PAWN::SetPlayerArmour, playerid, armour); +} + +void _samp_GetPlayerArmour(int playerid, float& armour) { + float _armour = 0.0; + g_Invoke->callNative(&PAWN::GetPlayerArmour, playerid, &_armour); + armour = _armour; +} + +void _samp_SetPlayerAmmo(int playerid, int weaponslot, int ammo) { + g_Invoke->callNative(&PAWN::SetPlayerAmmo, playerid, weaponslot, ammo); +} + +int _samp_GetPlayerAmmo(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerAmmo, playerid); +} + +int _samp_GetPlayerWeaponState(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerWeaponState, playerid); +} + +int _samp_GetPlayerTargetPlayer(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerTargetPlayer, playerid); +} + +void _samp_SetPlayerTeam(int playerid, int teamid) { + g_Invoke->callNative(&PAWN::SetPlayerTeam, playerid, teamid); +} + +int _samp_GetPlayerTeam(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerTeam, playerid); +} + +void _samp_SetPlayerScore(int playerid, int score) { + g_Invoke->callNative(&PAWN::SetPlayerScore, playerid, score); +} + +int _samp_GetPlayerScore(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerScore, playerid); +} + +int _samp_GetPlayerDrunkLevel(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerDrunkLevel, playerid); +} + +void _samp_SetPlayerDrunkLevel(int playerid, int level) { + g_Invoke->callNative(&PAWN::SetPlayerDrunkLevel, playerid, level); +} + +void _samp_SetPlayerColor(int playerid, unsigned int color) { + g_Invoke->callNative(&PAWN::SetPlayerColor, playerid, color); +} + +unsigned int _samp_GetPlayerColor(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerColor, playerid); +} + +void _samp_SetPlayerSkin(int playerid, int skinid) { + g_Invoke->callNative(&PAWN::SetPlayerSkin, playerid, skinid); +} + +int _samp_GetPlayerSkin(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerSkin, playerid); +} + +void _samp_GivePlayerWeapon(int playerid, int weaponid, int ammo) { + g_Invoke->callNative(&PAWN::GivePlayerWeapon, playerid, weaponid, ammo); +} + +void _samp_ResetPlayerWeapons(int playerid) { + g_Invoke->callNative(&PAWN::ResetPlayerWeapons, playerid); +} + +void _samp_SetPlayerArmedWeapon(int playerid, int weaponid) { + g_Invoke->callNative(&PAWN::SetPlayerArmedWeapon, playerid, weaponid); +} + +void _samp_GetPlayerWeaponData(int playerid, int slot, int& weapons, int& ammo) { + int _weapons = 0; + int _ammo = 0; + g_Invoke->callNative(&PAWN::GetPlayerWeaponData, playerid, slot, &_weapons, &_ammo); + weapons = _weapons; + ammo = _ammo; +} + +void _samp_GivePlayerMoney(int playerid, int money) { + g_Invoke->callNative(&PAWN::GivePlayerMoney, playerid, money); +} + +void _samp_ResetPlayerMoney(int playerid) { + g_Invoke->callNative(&PAWN::ResetPlayerMoney, playerid); +} + +void _samp_SetPlayerName(int playerid, char* name) { + g_Invoke->callNative(&PAWN::SetPlayerName, playerid, name); +} + +int _samp_GetPlayerMoney(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerMoney, playerid); +} + +int _samp_GetPlayerState(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerState, playerid); +} + +void _samp_GetPlayerIp(int playerid, char* name, int len) { + g_Invoke->callNative(&PAWN::GetPlayerIp, playerid, name, len); +} + +int _samp_GetPlayerPing(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerPing, playerid); +} + +int _samp_GetPlayerWeapon(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerWeapon, playerid); +} + +void _samp_GetPlayerKeys(int playerid, int& keys, int& updown, int& leftright) { + int _keys = 0; + int _updown = 0; + int _leftright = 0; + g_Invoke->callNative(&PAWN::GetPlayerKeys, playerid, &_keys, &_updown, &_leftright); + keys = _keys; + updown = _updown; + leftright = _leftright; +} + +void _samp_GetPlayerName(int playerid, char* name, int len) { + g_Invoke->callNative(&PAWN::GetPlayerName, playerid, name, len); +} + +void _samp_SetPlayerTime(int playerid, int hour, int minute) { + g_Invoke->callNative(&PAWN::SetPlayerTime, playerid, hour, minute); +} + +void _samp_GetPlayerTime(int playerid, int& hour, int& minute) { + int _hour = 0; + int _minute = 0; + g_Invoke->callNative(&PAWN::GetPlayerTime, playerid, &_hour, &_minute); + hour = _hour; + minute = _minute; +} + +void _samp_TogglePlayerClock(int playerid, int toggle) { + g_Invoke->callNative(&PAWN::TogglePlayerClock, playerid, toggle); +} + +void _samp_SetPlayerWeather(int playerid, int weather) { + g_Invoke->callNative(&PAWN::SetPlayerWeather, playerid, weather); +} + +void _samp_ForceClassSelection(int playerid) { + g_Invoke->callNative(&PAWN::ForceClassSelection, playerid); +} + +void _samp_SetPlayerWantedLevel(int playerid, int level) { + g_Invoke->callNative(&PAWN::SetPlayerWantedLevel, playerid, level); +} + +int _samp_GetPlayerWantedLevel(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerWantedLevel, playerid); +} + +void _samp_SetPlayerFightingStyle(int playerid, int style) { + g_Invoke->callNative(&PAWN::SetPlayerFightingStyle, playerid, style); +} + +int _samp_GetPlayerFightingStyle(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerFightingStyle, playerid); +} + +void _samp_SetPlayerVelocity(int playerid, float x, float y, float z) { + g_Invoke->callNative(&PAWN::SetPlayerVelocity, playerid, x, y, z); +} + +void _samp_GetPlayerVelocity(int playerid, float& x, float& y, float& z) { + float _x = 0.0; + float _y = 0.0; + float _z = 0.0; + g_Invoke->callNative(&PAWN::GetPlayerVelocity, playerid, &_x, &_y, &_z); + x = _x; + y = _y; + z = _z; +} + +void _samp_PlayCrimeReportForPlayer(int playerid, int suspectid, int crime) { + g_Invoke->callNative(&PAWN::PlayCrimeReportForPlayer, playerid, suspectid, crime); +} + +void _samp_PlayAudioStreamForPlayer(int playerid, char* url, float posx , float posy , float posz , float distance , int usepos ) { + g_Invoke->callNative(&PAWN::PlayAudioStreamForPlayer, playerid, url, posx = 0.0, posy = 0.0, posz = 0.0, distance = 50.0, usepos = 0); +} + +void _samp_StopAudioStreamForPlayer(int playerid) { + g_Invoke->callNative(&PAWN::StopAudioStreamForPlayer, playerid); +} + +void _samp_SetPlayerShopName(int playerid, char* shopname) { + g_Invoke->callNative(&PAWN::SetPlayerShopName, playerid, shopname); +} + +void _samp_SetPlayerSkillLevel(int playerid, int skill, int level) { + g_Invoke->callNative(&PAWN::SetPlayerSkillLevel, playerid, skill, level); +} + +int _samp_GetPlayerSurfingVehicleID(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerSurfingVehicleID, playerid); +} + +int _samp_GetPlayerSurfingObjectID(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerSurfingObjectID, playerid); +} + +void _samp_RemoveBuildingForPlayer(int playerid, int modelid, float fx, float fy, float fz, float fradius) { + g_Invoke->callNative(&PAWN::RemoveBuildingForPlayer, playerid, modelid, fx, fy, fz, fradius); +} + +void _samp_SetPlayerAttachedObject(int playerid, int index, int modelid, int bone, float foffsetx , float foffsety , float foffsetz , float frotx , float froty , float frotz , float fscalex , float fscaley , float fscalez , int materialcolor1 , int materialcolor2 ) { + g_Invoke->callNative(&PAWN::SetPlayerAttachedObject, playerid, index, modelid, bone, foffsetx = 0.0, foffsety = 0.0, foffsetz = 0.0, frotx = 0.0, froty = 0.0, frotz = 0.0, fscalex = 1.0, fscaley = 1.0, fscalez = 1.0, materialcolor1 = 0, materialcolor2 = 0); +} + +void _samp_RemovePlayerAttachedObject(int playerid, int index) { + g_Invoke->callNative(&PAWN::RemovePlayerAttachedObject, playerid, index); +} + +void _samp_IsPlayerAttachedObjectSlotUsed(int playerid, int index) { + g_Invoke->callNative(&PAWN::IsPlayerAttachedObjectSlotUsed, playerid, index); +} + +void _samp_EditAttachedObject(int playerid, int index) { + g_Invoke->callNative(&PAWN::EditAttachedObject, playerid, index); +} + +int _samp_CreatePlayerTextDraw(int playerid, float x, float y, char* text) { + return g_Invoke->callNative(&PAWN::CreatePlayerTextDraw, playerid, x, y, text); +} + +void _samp_PlayerTextDrawDestroy(int playerid, int text) { + g_Invoke->callNative(&PAWN::PlayerTextDrawDestroy, playerid, text); +} + +void _samp_PlayerTextDrawLetterSize(int playerid, int text, float x, float y) { + g_Invoke->callNative(&PAWN::PlayerTextDrawLetterSize, playerid, text, x, y); +} + +void _samp_PlayerTextDrawTextSize(int playerid, int text, float x, float y) { + g_Invoke->callNative(&PAWN::PlayerTextDrawTextSize, playerid, text, x, y); +} + +void _samp_PlayerTextDrawAlignment(int playerid, int text, int alignment) { + g_Invoke->callNative(&PAWN::PlayerTextDrawAlignment, playerid, text, alignment); +} + +void _samp_PlayerTextDrawColor(int playerid, int text, unsigned int color) { + g_Invoke->callNative(&PAWN::PlayerTextDrawColor, playerid, text, color); +} + +void _samp_PlayerTextDrawUseBox(int playerid, int text, int use) { + g_Invoke->callNative(&PAWN::PlayerTextDrawUseBox, playerid, text, use); +} + +void _samp_PlayerTextDrawBoxColor(int playerid, int text, unsigned int color) { + g_Invoke->callNative(&PAWN::PlayerTextDrawBoxColor, playerid, text, color); +} + +void _samp_PlayerTextDrawSetShadow(int playerid, int text, int size) { + g_Invoke->callNative(&PAWN::PlayerTextDrawSetShadow, playerid, text, size); +} + +void _samp_PlayerTextDrawSetOutline(int playerid, int text, int size) { + g_Invoke->callNative(&PAWN::PlayerTextDrawSetOutline, playerid, text, size); +} + +void _samp_PlayerTextDrawBackgroundColor(int playerid, int text, unsigned int color) { + g_Invoke->callNative(&PAWN::PlayerTextDrawBackgroundColor, playerid, text, color); +} + +void _samp_PlayerTextDrawFont(int playerid, int text, int font) { + g_Invoke->callNative(&PAWN::PlayerTextDrawFont, playerid, text, font); +} + +void _samp_PlayerTextDrawSetProportional(int playerid, int text, int set) { + g_Invoke->callNative(&PAWN::PlayerTextDrawSetProportional, playerid, text, set); +} + +void _samp_PlayerTextDrawSetSelectable(int playerid, int text, int set) { + g_Invoke->callNative(&PAWN::PlayerTextDrawSetSelectable, playerid, text, set); +} + +void _samp_PlayerTextDrawShow(int playerid, int text) { + g_Invoke->callNative(&PAWN::PlayerTextDrawShow, playerid, text); +} + +void _samp_PlayerTextDrawHide(int playerid, int text) { + g_Invoke->callNative(&PAWN::PlayerTextDrawHide, playerid, text); +} + +void _samp_PlayerTextDrawSetString(int playerid, int text, char* string) { + g_Invoke->callNative(&PAWN::PlayerTextDrawSetString, playerid, text, string); +} + +void _samp_SetPVarInt(int playerid, char* varname, int int_value) { + g_Invoke->callNative(&PAWN::SetPVarInt, playerid, varname, int_value); +} + +void _samp_GetPVarInt(int playerid, char* varname) { + g_Invoke->callNative(&PAWN::GetPVarInt, playerid, varname); +} + +void _samp_SetPVarString(int playerid, char* varname, char* string_value) { + g_Invoke->callNative(&PAWN::SetPVarString, playerid, varname, string_value); +} + +void _samp_GetPVarString(int playerid, char* varname, char* string_return, int len) { + g_Invoke->callNative(&PAWN::GetPVarString, playerid, varname, string_return, len); +} + +void _samp_SetPVarFloat(int playerid, char* varname, float float_value) { + g_Invoke->callNative(&PAWN::SetPVarFloat, playerid, varname, float_value); +} + +float _samp_GetPVarFloat(int playerid, char* varname) { + return (float)g_Invoke->callNative(&PAWN::GetPVarFloat, playerid, varname); +} + +void _samp_DeletePVar(int playerid, char* varname) { + g_Invoke->callNative(&PAWN::DeletePVar, playerid, varname); +} + +int _samp_GetPVarsUpperIndex(int playerid) { + return g_Invoke->callNative(&PAWN::GetPVarsUpperIndex, playerid); +} + +void _samp_GetPVarNameAtIndex(int playerid, int index, char* ret_varname, int ret_len) { + g_Invoke->callNative(&PAWN::GetPVarNameAtIndex, playerid, index, ret_varname, ret_len); +} + +int _samp_GetPVarType(int playerid, char* varname) { + return g_Invoke->callNative(&PAWN::GetPVarType, playerid, varname); +} + +void _samp_SetPlayerChatBubble(int playerid, char* text, unsigned int color, float drawdistance, int expiretime) { + g_Invoke->callNative(&PAWN::SetPlayerChatBubble, playerid, text, color, drawdistance, expiretime); +} + +void _samp_PutPlayerInVehicle(int playerid, int vehicleid, int seatid) { + g_Invoke->callNative(&PAWN::PutPlayerInVehicle, playerid, vehicleid, seatid); +} + +int _samp_GetPlayerVehicleID(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerVehicleID, playerid); +} + +int _samp_GetPlayerVehicleSeat(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerVehicleSeat, playerid); +} + +void _samp_RemovePlayerFromVehicle(int playerid) { + g_Invoke->callNative(&PAWN::RemovePlayerFromVehicle, playerid); +} + +void _samp_TogglePlayerControllable(int playerid, int toggle) { + g_Invoke->callNative(&PAWN::TogglePlayerControllable, playerid, toggle); +} + +void _samp_PlayerPlaySound(int playerid, int soundid, float x, float y, float z) { + g_Invoke->callNative(&PAWN::PlayerPlaySound, playerid, soundid, x, y, z); +} + +void _samp_ApplyAnimation(int playerid, char* animlib, char* animname, float fdelta, int loop, int lockx, int locky, int freeze, int time, int forcesync ) { + g_Invoke->callNative(&PAWN::ApplyAnimation, playerid, animlib, animname, fdelta, loop, lockx, locky, freeze, time, forcesync = 0); +} + +void _samp_ClearAnimations(int playerid, int forcesync ) { + g_Invoke->callNative(&PAWN::ClearAnimations, playerid, forcesync = 0); +} + +int _samp_GetPlayerAnimationIndex(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerAnimationIndex, playerid); +} + +void _samp_GetAnimationName(int index, char* animlib, int len1, char* animname, int len2) { + g_Invoke->callNative(&PAWN::GetAnimationName, index, animlib, len1, animname, len2); +} + +int _samp_GetPlayerSpecialAction(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerSpecialAction, playerid); +} + +void _samp_SetPlayerSpecialAction(int playerid, int actionid) { + g_Invoke->callNative(&PAWN::SetPlayerSpecialAction, playerid, actionid); +} + +void _samp_SetPlayerCheckpoint(int playerid, float x, float y, float z, float size) { + g_Invoke->callNative(&PAWN::SetPlayerCheckpoint, playerid, x, y, z, size); +} + +void _samp_DisablePlayerCheckpoint(int playerid) { + g_Invoke->callNative(&PAWN::DisablePlayerCheckpoint, playerid); +} + +void _samp_SetPlayerRaceCheckpoint(int playerid, int type, float x, float y, float z, float nextx, float nexty, float nextz, float size) { + g_Invoke->callNative(&PAWN::SetPlayerRaceCheckpoint, playerid, type, x, y, z, nextx, nexty, nextz, size); +} + +void _samp_DisablePlayerRaceCheckpoint(int playerid) { + g_Invoke->callNative(&PAWN::DisablePlayerRaceCheckpoint, playerid); +} + +void _samp_SetPlayerWorldBounds(int playerid, float x_max, float x_min, float y_max, float y_min) { + g_Invoke->callNative(&PAWN::SetPlayerWorldBounds, playerid, x_max, x_min, y_max, y_min); +} + +void _samp_SetPlayerMarkerForPlayer(int playerid, int showplayerid, unsigned int color) { + g_Invoke->callNative(&PAWN::SetPlayerMarkerForPlayer, playerid, showplayerid, color); +} + +void _samp_ShowPlayerNameTagForPlayer(int playerid, int showplayerid, int show) { + g_Invoke->callNative(&PAWN::ShowPlayerNameTagForPlayer, playerid, showplayerid, show); +} + +void _samp_SetPlayerMapIcon(int playerid, int iconid, float x, float y, float z, int markertype, unsigned int color, int style) { + g_Invoke->callNative(&PAWN::SetPlayerMapIcon, playerid, iconid, x, y, z, markertype, color, style); +} + +void _samp_RemovePlayerMapIcon(int playerid, int iconid) { + g_Invoke->callNative(&PAWN::RemovePlayerMapIcon, playerid, iconid); +} + +void _samp_AllowPlayerTeleport(int playerid, int allow) { + g_Invoke->callNative(&PAWN::AllowPlayerTeleport, playerid, allow); +} + +void _samp_SetPlayerCameraPos(int playerid, float x, float y, float z) { + g_Invoke->callNative(&PAWN::SetPlayerCameraPos, playerid, x, y, z); +} + +void _samp_SetPlayerCameraLookAt(int playerid, float x, float y, float z, int cut) { + g_Invoke->callNative(&PAWN::SetPlayerCameraLookAt, playerid, x, y, z, cut); +} + +void _samp_SetCameraBehindPlayer(int playerid) { + g_Invoke->callNative(&PAWN::SetCameraBehindPlayer, playerid); +} + +void _samp_GetPlayerCameraPos(int playerid, float& x, float& y, float& z) { + float _x = 0.0; + float _y = 0.0; + float _z = 0.0; + g_Invoke->callNative(&PAWN::GetPlayerCameraPos, playerid, &_x, &_y, &_z); + x = _x; + y = _y; + z = _z; +} + +void _samp_GetPlayerCameraFrontVector(int playerid, float& x, float& y, float& z) { + float _x = 0.0; + float _y = 0.0; + float _z = 0.0; + g_Invoke->callNative(&PAWN::GetPlayerCameraFrontVector, playerid, &_x, &_y, &_z); + x = _x; + y = _y; + z = _z; +} + +int _samp_GetPlayerCameraMode(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerCameraMode, playerid); +} + +void _samp_AttachCameraToObject(int playerid, int objectid) { + g_Invoke->callNative(&PAWN::AttachCameraToObject, playerid, objectid); +} + +void _samp_AttachCameraToPlayerObject(int playerid, int playerobjectid) { + g_Invoke->callNative(&PAWN::AttachCameraToPlayerObject, playerid, playerobjectid); +} + +void _samp_InterpolateCameraPos(int playerid, float fromx, float fromy, float fromz, float tox, float toy, float toz, int time, int cut) { + g_Invoke->callNative(&PAWN::InterpolateCameraPos, playerid, fromx, fromy, fromz, tox, toy, toz, time, cut); +} + +void _samp_InterpolateCameraLookAt(int playerid, float fromx, float fromy, float fromz, float tox, float toy, float toz, int time, int cut) { + g_Invoke->callNative(&PAWN::InterpolateCameraLookAt, playerid, fromx, fromy, fromz, tox, toy, toz, time, cut); +} + +int _samp_IsPlayerConnected(int playerid) { + return g_Invoke->callNative(&PAWN::IsPlayerConnected, playerid); +} + +int _samp_IsPlayerInVehicle(int playerid, int vehicleid) { + return g_Invoke->callNative(&PAWN::IsPlayerInVehicle, playerid, vehicleid); +} + +int _samp_IsPlayerInAnyVehicle(int playerid) { + return g_Invoke->callNative(&PAWN::IsPlayerInAnyVehicle, playerid); +} + +int _samp_IsPlayerInCheckpoint(int playerid) { + return g_Invoke->callNative(&PAWN::IsPlayerInCheckpoint, playerid); +} + +int _samp_IsPlayerInRaceCheckpoint(int playerid) { + return g_Invoke->callNative(&PAWN::IsPlayerInRaceCheckpoint, playerid); +} + +void _samp_SetPlayerVirtualWorld(int playerid, int worldid) { + g_Invoke->callNative(&PAWN::SetPlayerVirtualWorld, playerid, worldid); +} + +int _samp_GetPlayerVirtualWorld(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerVirtualWorld, playerid); +} + +void _samp_EnableStuntBonusForPlayer(int playerid, int enable) { + g_Invoke->callNative(&PAWN::EnableStuntBonusForPlayer, playerid, enable); +} + +void _samp_EnableStuntBonusForAll(int enable) { + g_Invoke->callNative(&PAWN::EnableStuntBonusForAll, enable); +} + +void _samp_TogglePlayerSpectating(int playerid, int toggle) { + g_Invoke->callNative(&PAWN::TogglePlayerSpectating, playerid, toggle); +} + +void _samp_PlayerSpectatePlayer(int playerid, int targetplayerid, int mode) { + g_Invoke->callNative(&PAWN::PlayerSpectatePlayer, playerid, targetplayerid, mode); +} + +void _samp_PlayerSpectateVehicle(int playerid, int targetvehicleid, int mode) { + g_Invoke->callNative(&PAWN::PlayerSpectateVehicle, playerid, targetvehicleid, mode); +} + +void _samp_StartRecordingPlayerData(int playerid, int recordtype, char* recordname) { + g_Invoke->callNative(&PAWN::StartRecordingPlayerData, playerid, recordtype, recordname); +} + +void _samp_StopRecordingPlayerData(int playerid) { + g_Invoke->callNative(&PAWN::StopRecordingPlayerData, playerid); +} + +void _samp_SelectTextDraw(int playerid, int hovercolor) { + g_Invoke->callNative(&PAWN::SelectTextDraw, playerid, hovercolor); +} + +void _samp_CancelSelectTextDraw(int playerid) { + g_Invoke->callNative(&PAWN::CancelSelectTextDraw, playerid); +} + diff --git a/sampdotnethook/src/a_players.h b/sampdotnethook/src/a_players.h new file mode 100644 index 0000000..dde6472 --- /dev/null +++ b/sampdotnethook/src/a_players.h @@ -0,0 +1,149 @@ +#ifndef A_PLAYERS_H +#define A_PLAYERS_H + +PLUGIN_EXPORT void _samp_SetSpawnInfo(int playerid, int team, int skin, float x, float y, float z, float rotation, int weapon1, int weapon1_ammo, int weapon2, int weapon2_ammo, int weapon3, int weapon3_ammo); +PLUGIN_EXPORT void _samp_SpawnPlayer(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerPos(int playerid, float x, float y, float z); +PLUGIN_EXPORT void _samp_SetPlayerPosFindZ(int playerid, float x, float y, float z); +PLUGIN_EXPORT void _samp_GetPlayerPos(int playerid, float& x, float& y, float& z); +PLUGIN_EXPORT void _samp_SetPlayerFacingAngle(int playerid, float ang); +PLUGIN_EXPORT void _samp_GetPlayerFacingAngle(int playerid, float& ang); +//void IsPlayerInRangeOfPoint(int playerid, float range, float x, float y, float z); +//float GetPlayerDistanceFromPoint(int playerid, float x, float y, float z); +PLUGIN_EXPORT int _samp_IsPlayerStreamedIn(int playerid, int forplayerid); +PLUGIN_EXPORT void _samp_SetPlayerInterior(int playerid, int interiorid); +PLUGIN_EXPORT int _samp_GetPlayerInterior(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerHealth(int playerid, float health); +PLUGIN_EXPORT void _samp_GetPlayerHealth(int playerid, float& health); +PLUGIN_EXPORT void _samp_SetPlayerArmour(int playerid, float armour); +PLUGIN_EXPORT void _samp_GetPlayerArmour(int playerid, float& armour); +PLUGIN_EXPORT void _samp_SetPlayerAmmo(int playerid, int weaponslot, int ammo); +PLUGIN_EXPORT int _samp_GetPlayerAmmo(int playerid); +PLUGIN_EXPORT int _samp_GetPlayerWeaponState(int playerid); +PLUGIN_EXPORT int _samp_GetPlayerTargetPlayer(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerTeam(int playerid, int teamid); +PLUGIN_EXPORT int _samp_GetPlayerTeam(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerScore(int playerid, int score); +PLUGIN_EXPORT int _samp_GetPlayerScore(int playerid); +PLUGIN_EXPORT int _samp_GetPlayerDrunkLevel(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerDrunkLevel(int playerid, int level); +PLUGIN_EXPORT void _samp_SetPlayerColor(int playerid, int color); +PLUGIN_EXPORT unsigned int _samp_GetPlayerColor(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerSkin(int playerid, int skinid); +PLUGIN_EXPORT int _samp_GetPlayerSkin(int playerid); +PLUGIN_EXPORT void _samp_GivePlayerWeapon(int playerid, int weaponid, int ammo); +PLUGIN_EXPORT void _samp_ResetPlayerWeapons(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerArmedWeapon(int playerid, int weaponid); +PLUGIN_EXPORT void _samp_GetPlayerWeaponData(int playerid, int slot, int& weapons, int& ammo); +PLUGIN_EXPORT void _samp_GivePlayerMoney(int playerid, int money); +PLUGIN_EXPORT void _samp_ResetPlayerMoney(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerName(int playerid, char* name); +PLUGIN_EXPORT int _samp_GetPlayerMoney(int playerid); +PLUGIN_EXPORT int _samp_GetPlayerState(int playerid); +PLUGIN_EXPORT void _samp_GetPlayerIp(int playerid, char* name, int len); +PLUGIN_EXPORT int _samp_GetPlayerPing(int playerid); +PLUGIN_EXPORT int _samp_GetPlayerWeapon(int playerid); +PLUGIN_EXPORT void _samp_GetPlayerKeys(int playerid, int& keys, int& updown, int& leftright); +PLUGIN_EXPORT void _samp_GetPlayerName(int playerid, char* name, int len); +PLUGIN_EXPORT void _samp_SetPlayerTime(int playerid, int hour, int minute); +PLUGIN_EXPORT void _samp_GetPlayerTime(int playerid, int& hour, int& minute); +PLUGIN_EXPORT void _samp_TogglePlayerClock(int playerid, int toggle); +PLUGIN_EXPORT void _samp_SetPlayerWeather(int playerid, int weather); +PLUGIN_EXPORT void _samp_ForceClassSelection(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerWantedLevel(int playerid, int level); +PLUGIN_EXPORT int _samp_GetPlayerWantedLevel(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerFightingStyle(int playerid, int style); +PLUGIN_EXPORT int _samp_GetPlayerFightingStyle(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerVelocity(int playerid, float x, float y, float z); +PLUGIN_EXPORT void _samp_GetPlayerVelocity(int playerid, float& x, float& y, float& z); +PLUGIN_EXPORT void _samp_PlayCrimeReportForPlayer(int playerid, int suspectid, int crime); +PLUGIN_EXPORT void _samp_PlayAudioStreamForPlayer(int playerid, char* url, float posx=0.0, float posy=0.0, float posz=0.0, float distance=50.0, int usepos=0); +PLUGIN_EXPORT void _samp_StopAudioStreamForPlayer(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerShopName(int playerid, char* shopname); +PLUGIN_EXPORT void _samp_SetPlayerSkillLevel(int playerid, int skill, int level); +PLUGIN_EXPORT int _samp_GetPlayerSurfingVehicleID(int playerid); +PLUGIN_EXPORT int _samp_GetPlayerSurfingObjectID(int playerid); +PLUGIN_EXPORT void _samp_RemoveBuildingForPlayer(int playerid, int modelid, float fx, float fy, float fz, float fradius); +PLUGIN_EXPORT void _samp_SetPlayerAttachedObject(int playerid, int index, int modelid, int bone, float foffsetx=0.0, float foffsety=0.0, float foffsetz=0.0, float frotx=0.0, float froty=0.0, float frotz=0.0, float fscalex=1.0, float fscaley=1.0, float fscalez=1.0, int materialcolor1=0, int materialcolor2=0); +PLUGIN_EXPORT void _samp_RemovePlayerAttachedObject(int playerid, int index); +PLUGIN_EXPORT void _samp_IsPlayerAttachedObjectSlotUsed(int playerid, int index); +PLUGIN_EXPORT void _samp_EditAttachedObject(int playerid, int index); +PLUGIN_EXPORT int _samp_CreatePlayerTextDraw(int playerid, float x, float y, char* text); +PLUGIN_EXPORT void _samp_PlayerTextDrawDestroy(int playerid, int text); +PLUGIN_EXPORT void _samp_PlayerTextDrawLetterSize(int playerid, int text, float x, float y); +PLUGIN_EXPORT void _samp_PlayerTextDrawTextSize(int playerid, int text, float x, float y); +PLUGIN_EXPORT void _samp_PlayerTextDrawAlignment(int playerid, int text, int alignment); +PLUGIN_EXPORT void _samp_PlayerTextDrawColor(int playerid, int text, int color); +PLUGIN_EXPORT void _samp_PlayerTextDrawUseBox(int playerid, int text, int use); +PLUGIN_EXPORT void _samp_PlayerTextDrawBoxColor(int playerid, int text, int color); +PLUGIN_EXPORT void _samp_PlayerTextDrawSetShadow(int playerid, int text, int size); +PLUGIN_EXPORT void _samp_PlayerTextDrawSetOutline(int playerid, int text, int size); +PLUGIN_EXPORT void _samp_PlayerTextDrawBackgroundColor(int playerid, int text, int color); +PLUGIN_EXPORT void _samp_PlayerTextDrawFont(int playerid, int text, int font); +PLUGIN_EXPORT void _samp_PlayerTextDrawSetProportional(int playerid, int text, int set); +PLUGIN_EXPORT void _samp_PlayerTextDrawSetSelectable(int playerid, int text, int set); +PLUGIN_EXPORT void _samp_PlayerTextDrawShow(int playerid, int text); +PLUGIN_EXPORT void _samp_PlayerTextDrawHide(int playerid, int text); +PLUGIN_EXPORT void _samp_PlayerTextDrawSetString(int playerid, int text, char* string); +PLUGIN_EXPORT void _samp_SetPVarInt(int playerid, char* varname, int int_value); +PLUGIN_EXPORT void _samp_GetPVarInt(int playerid, char* varname); +PLUGIN_EXPORT void _samp_SetPVarString(int playerid, char* varname, char* string_value); +PLUGIN_EXPORT void _samp_GetPVarString(int playerid, char* varname, char* string_return, int len); +PLUGIN_EXPORT void _samp_SetPVarFloat(int playerid, char* varname, float float_value); +PLUGIN_EXPORT float _samp_GetPVarFloat(int playerid, char* varname); +PLUGIN_EXPORT void _samp_DeletePVar(int playerid, char* varname); +PLUGIN_EXPORT int _samp_GetPVarsUpperIndex(int playerid); +PLUGIN_EXPORT void _samp_GetPVarNameAtIndex(int playerid, int index, char* ret_varname, int ret_len); +PLUGIN_EXPORT int _samp_GetPVarType(int playerid, char* varname); +PLUGIN_EXPORT void _samp_SetPlayerChatBubble(int playerid, char* text, int color, float drawdistance, int expiretime); +PLUGIN_EXPORT void _samp_PutPlayerInVehicle(int playerid, int vehicleid, int seatid); +PLUGIN_EXPORT int _samp_GetPlayerVehicleID(int playerid); +PLUGIN_EXPORT int _samp_GetPlayerVehicleSeat(int playerid); +PLUGIN_EXPORT void _samp_RemovePlayerFromVehicle(int playerid); +PLUGIN_EXPORT void _samp_TogglePlayerControllable(int playerid, int toggle); +PLUGIN_EXPORT void _samp_PlayerPlaySound(int playerid, int soundid, float x, float y, float z); +PLUGIN_EXPORT void _samp_ApplyAnimation(int playerid, char* animlib, char* animname, float fdelta, int loop, int lockx, int locky, int freeze, int time, int forcesync=0); +PLUGIN_EXPORT void _samp_ClearAnimations(int playerid, int forcesync=0); +PLUGIN_EXPORT int _samp_GetPlayerAnimationIndex(int playerid); +PLUGIN_EXPORT void _samp_GetAnimationName(int index, char* animlib, int len1, char* animname, int len2); +PLUGIN_EXPORT int _samp_GetPlayerSpecialAction(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerSpecialAction(int playerid, int actionid); +PLUGIN_EXPORT void _samp_SetPlayerCheckpoint(int playerid, float x, float y, float z, float size); +PLUGIN_EXPORT void _samp_DisablePlayerCheckpoint(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerRaceCheckpoint(int playerid, int type, float x, float y, float z, float nextx, float nexty, float nextz, float size); +PLUGIN_EXPORT void _samp_DisablePlayerRaceCheckpoint(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerWorldBounds(int playerid, float x_max, float x_min, float y_max, float y_min); +PLUGIN_EXPORT void _samp_SetPlayerMarkerForPlayer(int playerid, int showplayerid, int color); +PLUGIN_EXPORT void _samp_ShowPlayerNameTagForPlayer(int playerid, int showplayerid, int show); +PLUGIN_EXPORT void _samp_SetPlayerMapIcon(int playerid, int iconid, float x, float y, float z, int markertype, int color, int style=0); +PLUGIN_EXPORT void _samp_RemovePlayerMapIcon(int playerid, int iconid); +PLUGIN_EXPORT void _samp_AllowPlayerTeleport(int playerid, int allow); +PLUGIN_EXPORT void _samp_SetPlayerCameraPos(int playerid, float x, float y, float z); +PLUGIN_EXPORT void _samp_SetPlayerCameraLookAt(int playerid, float x, float y, float z, int cut=2); +PLUGIN_EXPORT void _samp_SetCameraBehindPlayer(int playerid); +PLUGIN_EXPORT void _samp_GetPlayerCameraPos(int playerid, float& x, float& y, float& z); +PLUGIN_EXPORT void _samp_GetPlayerCameraFrontVector(int playerid, float& x, float& y, float& z); +PLUGIN_EXPORT int _samp_GetPlayerCameraMode(int playerid); +PLUGIN_EXPORT void _samp_AttachCameraToObject(int playerid, int objectid); +PLUGIN_EXPORT void _samp_AttachCameraToPlayerObject(int playerid, int playerobjectid); +PLUGIN_EXPORT void _samp_InterpolateCameraPos(int playerid, float fromx, float fromy, float fromz, float tox, float toy, float toz, int time, int cut=2); +PLUGIN_EXPORT void _samp_InterpolateCameraLookAt(int playerid, float fromx, float fromy, float fromz, float tox, float toy, float toz, int time, int cut=2); +PLUGIN_EXPORT int _samp_IsPlayerConnected(int playerid); +PLUGIN_EXPORT int _samp_IsPlayerInVehicle(int playerid, int vehicleid); +PLUGIN_EXPORT int _samp_IsPlayerInAnyVehicle(int playerid); +PLUGIN_EXPORT int _samp_IsPlayerInCheckpoint(int playerid); +PLUGIN_EXPORT int _samp_IsPlayerInRaceCheckpoint(int playerid); +PLUGIN_EXPORT void _samp_SetPlayerVirtualWorld(int playerid, int worldid); +PLUGIN_EXPORT int _samp_GetPlayerVirtualWorld(int playerid); +PLUGIN_EXPORT void _samp_EnableStuntBonusForPlayer(int playerid, int enable); +PLUGIN_EXPORT void _samp_EnableStuntBonusForAll(int enable); +PLUGIN_EXPORT void _samp_TogglePlayerSpectating(int playerid, int toggle); +PLUGIN_EXPORT void _samp_PlayerSpectatePlayer(int playerid, int targetplayerid, int mode=1); +PLUGIN_EXPORT void _samp_PlayerSpectateVehicle(int playerid, int targetvehicleid, int mode=1); +PLUGIN_EXPORT void _samp_StartRecordingPlayerData(int playerid, int recordtype, char* recordname); +PLUGIN_EXPORT void _samp_StopRecordingPlayerData(int playerid); +PLUGIN_EXPORT void _samp_SelectTextDraw(int playerid, int hovercolor); +PLUGIN_EXPORT void _samp_CancelSelectTextDraw(int playerid); + +#endif // A_PLAYERS_H + diff --git a/sampdotnethook/src/a_samp.cpp b/sampdotnethook/src/a_samp.cpp new file mode 100644 index 0000000..e790714 --- /dev/null +++ b/sampdotnethook/src/a_samp.cpp @@ -0,0 +1,406 @@ +#include "a_samp.h" + +void _samp_SendClientMessage(int playerid, unsigned int color, char* message) { + g_Invoke->callNative(&PAWN::SendClientMessage, playerid, color, message); +} + +void _samp_SendClientMessageToAll(unsigned int color, char* message) { + g_Invoke->callNative(&PAWN::SendClientMessageToAll, color, message); +} + +void _samp_SendPlayerMessageToPlayer(int playerid, int senderid, char* message) { + g_Invoke->callNative(&PAWN::SendPlayerMessageToPlayer, playerid, senderid, message); +} + +void _samp_SendPlayerMessageToAll(int senderid, char* message) { + g_Invoke->callNative(&PAWN::SendPlayerMessageToAll, senderid, message); +} + +void _samp_SendDeathMessage(int killer, int killee, int weapon) { + g_Invoke->callNative(&PAWN::SendDeathMessage, killer, killee, weapon); +} + +void _samp_GameTextForAll(char* string, int time, int style) { + g_Invoke->callNative(&PAWN::GameTextForAll, string, time, style); +} + +void _samp_GameTextForPlayer(int playerid, char* string, int time, int style) { + g_Invoke->callNative(&PAWN::GameTextForPlayer, playerid, string, time, style); +} + +int _samp_GetTickCount() { + return g_Invoke->callNative(&PAWN::GetTickCount); +} + +int _samp_GetMaxPlayers() { + return g_Invoke->callNative(&PAWN::GetMaxPlayers); +} + +void _samp_SetGameModeText(char* string) { + g_Invoke->callNative(&PAWN::SetGameModeText, string); +} + +void _samp_SetTeamCount(int count) { // No effect + g_Invoke->callNative(&PAWN::SetTeamCount, count); +} + +int _samp_AddPlayerClass(int modelid, float spawn_x, float spawn_y, float spawn_z, float z_angle, int weapon1, int weapon1_ammo, int weapon2, int weapon2_ammo, int weapon3, int weapon3_ammo) { + return g_Invoke->callNative(&PAWN::AddPlayerClass, modelid, spawn_x, spawn_y, spawn_z, z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo); +} + +int _samp_AddPlayerClassEx(int teamid, int modelid, float spawn_x, float spawn_y, float spawn_z, float z_angle, int weapon1, int weapon1_ammo, int weapon2, int weapon2_ammo, int weapon3, int weapon3_ammo) { + return g_Invoke->callNative(&PAWN::AddPlayerClassEx, teamid, modelid, spawn_x, spawn_y, spawn_z, z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo); +} + +int _samp_AddStaticVehicle(int modelid, float spawn_x, float spawn_y, float spawn_z, float z_angle, int color1, int color2) { + return g_Invoke->callNative(&PAWN::AddStaticVehicle, modelid, spawn_x, spawn_y, spawn_z, z_angle, color1, color2); +} + +int _samp_AddStaticVehicleEx(int modelid, float spawn_x, float spawn_y, float spawn_z, float z_angle, int color1, int color2, int respawn_delay) { + return g_Invoke->callNative(&PAWN::AddStaticVehicleEx, modelid, spawn_x, spawn_y, spawn_z, z_angle, color1, color2, respawn_delay); +} + +int _samp_AddStaticPickup(int model, int type, float x, float y, float z, int virtualworld) { + return g_Invoke->callNative(&PAWN::AddStaticPickup, model, type, x, y, z, virtualworld); +} + +int _samp_CreatePickup(int model, int type, float x, float y, float z, int virtualworld) { + return g_Invoke->callNative(&PAWN::CreatePickup, model, type, x, y, z, virtualworld); +} + +void _samp_DestroyPickup(int pickup) { + g_Invoke->callNative(&PAWN::DestroyPickup, pickup); +} + +void _samp_ShowNameTags(int show) { + g_Invoke->callNative(&PAWN::ShowNameTags, show); +} + +void _samp_ShowPlayerMarkers(int mode) { + g_Invoke->callNative(&PAWN::ShowPlayerMarkers, mode); +} + +void _samp_GameModeExit() { + g_Invoke->callNative(&PAWN::GameModeExit); +} + +void _samp_SetWorldTime(int hour) { + g_Invoke->callNative(&PAWN::SetWorldTime, hour); +} + +void _samp_GetWeaponName(int weaponid, char* weapon, int len) { + char _weapon[50]; + g_Invoke->callNative(&PAWN::GetWeaponName, weaponid, _weapon, len); + strncpy(_weapon, weapon, len); +} + +void _samp_EnableTirePopping(int enable) { // Deprecated + g_Invoke->callNative(&PAWN::EnableTirePopping, enable); +} + +void _samp_AllowInteriorWeapons(int allow) { + g_Invoke->callNative(&PAWN::AllowInteriorWeapons, allow); +} + +void _samp_SetWeather(int weatherid) { + g_Invoke->callNative(&PAWN::SetWeather, weatherid); +} + +void _samp_SetGravity(float gravity) { + g_Invoke->callNative(&PAWN::SetGravity, gravity); +} + +void _samp_AllowAdminTeleport(int allow) { // Deprecated + g_Invoke->callNative(&PAWN::AllowAdminTeleport, allow); +} + +void _samp_SetDeathDropAmount(int amount) { // Deprecated + g_Invoke->callNative(&PAWN::SetDeathDropAmount, amount); +} + +void _samp_CreateExplosion(float x, float y, float z, int type, float radius) { + g_Invoke->callNative(&PAWN::CreateExplosion, x, y, z, type, radius); +} + +void _samp_EnableZoneNames(int enable) { + g_Invoke->callNative(&PAWN::EnableZoneNames, enable); +} + +void _samp_UsePlayerPedAnims() { + g_Invoke->callNative(&PAWN::UsePlayerPedAnims); +} + +void _samp_DisableInteriorEnterExits() { + g_Invoke->callNative(&PAWN::DisableInteriorEnterExits); +} + +void _samp_SetNameTagDrawDistance(float distance) { + g_Invoke->callNative(&PAWN::SetNameTagDrawDistance, distance); +} + +void _samp_DisableNameTagLOS() { + g_Invoke->callNative(&PAWN::DisableNameTagLOS); +} + +void _samp_LimitGlobalChatRadius(float chat_radius) { + g_Invoke->callNative(&PAWN::LimitGlobalChatRadius, chat_radius); +} + +void _samp_LimitPlayerMarkerRadius(float marker_radius) { + g_Invoke->callNative(&PAWN::LimitPlayerMarkerRadius, marker_radius); +} + +void _samp_ConnectNPC(char* name, char* script) { + g_Invoke->callNative(&PAWN::ConnectNPC, name, script); +} + +int _samp_IsPlayerNPC(int playerid) { + return g_Invoke->callNative(&PAWN::IsPlayerNPC, playerid); +} + +int _samp_IsPlayerAdmin(int playerid) { + return g_Invoke->callNative(&PAWN::IsPlayerAdmin, playerid); +} + +void _samp_Kick(int playerid) { + g_Invoke->callNative(&PAWN::Kick, playerid); +} + +void _samp_Ban(int playerid) { + g_Invoke->callNative(&PAWN::Ban, playerid); +} + +void _samp_BanEx(int playerid, char* reason) { + g_Invoke->callNative(&PAWN::BanEx, playerid, reason); +} + +void _samp_SendRconCommand(char* command) { + g_Invoke->callNative(&PAWN::SendRconCommand, command); +} + +void _samp_GetServerVarAsString(char* varname, char* buffer, int len) { + char _buffer[1024]; + g_Invoke->callNative(&PAWN::GetServerVarAsString, varname, _buffer, len); + strncpy(_buffer, buffer, len); +} + +int _samp_GetServerVarAsInt(char* varname) { + return g_Invoke->callNative(&PAWN::GetServerVarAsInt, varname); +} + +int _samp_GetServerVarAsBool(char* varname) { + return g_Invoke->callNative(&PAWN::GetServerVarAsBool, varname); +} + +void _samp_GetPlayerNetworkStats(int playerid, char* retstr, int retstr_size) { + char _retstr[1024]; + g_Invoke->callNative(&PAWN::GetPlayerNetworkStats, playerid, _retstr, retstr_size); + strncpy(_retstr, retstr, retstr_size); +} + +void _samp_GetNetworkStats(char* retstr, int retstr_size) { + char _retstr[1024]; + g_Invoke->callNative(&PAWN::GetNetworkStats, _retstr, retstr_size); + strncpy(_retstr, retstr, retstr_size); +} + +int _samp_GetPlayerVersion(int playerid, char* version, int len) { + char _version[10]; + int iRet = g_Invoke->callNative(&PAWN::GetPlayerVersion, playerid, _version, len); + strncpy(_version, version, len); + return iRet; +} + +int _samp_CreateMenu(char* title, int columns, float x, float y, float col1width, float col2width ) { + return g_Invoke->callNative(&PAWN::CreateMenu, title, columns, x, y, col1width, col2width); +} + +int _samp_DestroyMenu(int menuid) { + return g_Invoke->callNative(&PAWN::DestroyMenu, menuid); +} + +void _samp_AddMenuItem(int menuid, int column, char* menutext) { + g_Invoke->callNative(&PAWN::AddMenuItem, menuid, column, menutext); +} + +void _samp_SetMenuColumnHeader(int menuid, int column, char* columnheader) { + g_Invoke->callNative(&PAWN::SetMenuColumnHeader, menuid, column, columnheader); +} + +void _samp_ShowMenuForPlayer(int menuid, int playerid) { + g_Invoke->callNative(&PAWN::ShowMenuForPlayer, menuid, playerid); +} + +void _samp_HideMenuForPlayer(int menuid, int playerid) { + g_Invoke->callNative(&PAWN::HideMenuForPlayer, menuid, playerid); +} + +int _samp_IsValidMenu(int menuid) { + return g_Invoke->callNative(&PAWN::IsValidMenu, menuid); +} + +void _samp_DisableMenu(int menuid) { + g_Invoke->callNative(&PAWN::DisableMenu, menuid); +} + +void _samp_DisableMenuRow(int menuid, int row) { + g_Invoke->callNative(&PAWN::DisableMenuRow, menuid, row); +} + +int _samp_GetPlayerMenu(int playerid) { + return g_Invoke->callNative(&PAWN::GetPlayerMenu, playerid); +} + +int _samp_TextDrawCreate(float x, float y, char* text) { + return g_Invoke->callNative(&PAWN::TextDrawCreate, x, y, text); +} + +void _samp_TextDrawDestroy(int text) { + g_Invoke->callNative(&PAWN::TextDrawDestroy, text); +} + +void _samp_TextDrawLetterSize(int text, float x, float y) { + g_Invoke->callNative(&PAWN::TextDrawLetterSize, text, x, y); +} + +void _samp_TextDrawTextSize(int text, float x, float y) { + g_Invoke->callNative(&PAWN::TextDrawTextSize, text, x, y); +} + +void _samp_TextDrawAlignment(int text, int alignment) { + g_Invoke->callNative(&PAWN::TextDrawAlignment, text, alignment); +} + +void _samp_TextDrawColor(int text, unsigned int color) { + g_Invoke->callNative(&PAWN::TextDrawColor, text, color); +} + +void _samp_TextDrawUseBox(int text, int use) { + g_Invoke->callNative(&PAWN::TextDrawUseBox, text, use); +} + +void _samp_TextDrawBoxColor(int text, unsigned int color) { + g_Invoke->callNative(&PAWN::TextDrawBoxColor, text, color); +} + +void _samp_TextDrawSetShadow(int text, int size) { + g_Invoke->callNative(&PAWN::TextDrawSetShadow, text, size); +} + +void _samp_TextDrawSetOutline(int text, int size) { + g_Invoke->callNative(&PAWN::TextDrawSetOutline, text, size); +} + +void _samp_TextDrawBackgroundColor(int text, unsigned int color) { + g_Invoke->callNative(&PAWN::TextDrawBackgroundColor, text, color); +} + +void _samp_TextDrawFont(int text, int font) { + g_Invoke->callNative(&PAWN::TextDrawFont, text, font); +} + +void _samp_TextDrawSetProportional(int text, int set) { + g_Invoke->callNative(&PAWN::TextDrawSetProportional, text, set); +} + +void _samp_TextDrawSetSelectable(int text, int set) { + g_Invoke->callNative(&PAWN::TextDrawSetSelectable, text, set); +} + +void _samp_TextDrawShowForPlayer(int playerid, int text) { + g_Invoke->callNative(&PAWN::TextDrawShowForPlayer, playerid, text); +} + +void _samp_TextDrawHideForPlayer(int playerid, int text) { + g_Invoke->callNative(&PAWN::TextDrawHideForPlayer, playerid, text); +} + +void _samp_TextDrawShowForAll(int text) { + g_Invoke->callNative(&PAWN::TextDrawShowForAll, text); +} + +void _samp_TextDrawHideForAll(int text) { + g_Invoke->callNative(&PAWN::TextDrawHideForAll, text); +} + +void _samp_TextDrawSetString(int text, char* string) { + g_Invoke->callNative(&PAWN::TextDrawSetString, text, string); +} + +int _samp_GangZoneCreate(float minx, float miny, float maxx, float maxy) { + return g_Invoke->callNative(&PAWN::GangZoneCreate, minx, miny, maxx, maxy); +} + +void _samp_GangZoneDestroy(int zone) { + g_Invoke->callNative(&PAWN::GangZoneDestroy, zone); +} + +void _samp_GangZoneShowForPlayer(int playerid, int zone, unsigned int color) { + g_Invoke->callNative(&PAWN::GangZoneShowForPlayer, playerid, zone, color); +} + +int _samp_GangZoneShowForAll(int zone, unsigned int color) { + return g_Invoke->callNative(&PAWN::GangZoneShowForAll, zone, color); +} + +void _samp_GangZoneHideForPlayer(int playerid, int zone) { + g_Invoke->callNative(&PAWN::GangZoneHideForPlayer, playerid, zone); +} + +void _samp_GangZoneHideForAll(int zone) { + g_Invoke->callNative(&PAWN::GangZoneHideForAll, zone); +} + +void _samp_GangZoneFlashForPlayer(int playerid, int zone, unsigned int flashcolor) { + g_Invoke->callNative(&PAWN::GangZoneFlashForPlayer, playerid, zone, flashcolor); +} + +void _samp_GangZoneFlashForAll(int zone, unsigned int flashcolor) { + g_Invoke->callNative(&PAWN::GangZoneFlashForAll, zone, flashcolor); +} + +void _samp_GangZoneStopFlashForPlayer(int playerid, int zone) { + g_Invoke->callNative(&PAWN::GangZoneStopFlashForPlayer, playerid, zone); +} + +void _samp_GangZoneStopFlashForAll(int zone) { + g_Invoke->callNative(&PAWN::GangZoneStopFlashForAll, zone); +} + +int _samp_Create3DTextLabel(char* text, unsigned int color, float x, float y, float z, float drawdistance, int virtualworld, int testLOS) { + return g_Invoke->callNative(&PAWN::Create3DTextLabel, text, color, x, y, z, drawdistance, virtualworld, testLOS); +} + +int _samp_Delete3DTextLabel(int id) { + return g_Invoke->callNative(&PAWN::Delete3DTextLabel, id); +} + +void _samp_Attach3DTextLabelToPlayer(int id, int playerid, float offsetx, float offsety, float offsetz) { + g_Invoke->callNative(&PAWN::Attach3DTextLabelToPlayer, id, playerid, offsetx, offsety, offsetz); +} + +void _samp_Attach3DTextLabelToVehicle(int id, int vehicleid, float offsetx, float offsety, float offsetz) { + g_Invoke->callNative(&PAWN::Attach3DTextLabelToVehicle, id, vehicleid, offsetx, offsety, offsetz); +} + +void _samp_Update3DTextLabelText(int id, unsigned int color, char* text) { + g_Invoke->callNative(&PAWN::Update3DTextLabelText, id, color, text); +} + +int _samp_CreatePlayer3DTextLabel(int playerid, char* text, unsigned int color, float x, float y, float z, float drawdistance, int attachedplayer, int attachedvehicle, int testLOS) { + return g_Invoke->callNative(&PAWN::CreatePlayer3DTextLabel, playerid, text, color, x, y, z, drawdistance, attachedplayer, attachedvehicle, testLOS); +} + +void _samp_DeletePlayer3DTextLabel(int playerid, int id) { + g_Invoke->callNative(&PAWN::DeletePlayer3DTextLabel, playerid, id); +} + +void _samp_UpdatePlayer3DTextLabelText(int playerid, int id, unsigned int color, char* text) { + g_Invoke->callNative(&PAWN::UpdatePlayer3DTextLabelText, playerid, id, color, text); +} + +void _samp_ShowPlayerDialog(int playerid, int dialogid, int style, char* caption, char* info, char* button1, char* button2) { + g_Invoke->callNative(&PAWN::ShowPlayerDialog, playerid, dialogid, style, caption, info, button1, button2); +} + + diff --git a/sampdotnethook/src/a_samp.h b/sampdotnethook/src/a_samp.h new file mode 100644 index 0000000..8beef5d --- /dev/null +++ b/sampdotnethook/src/a_samp.h @@ -0,0 +1,156 @@ +#ifndef A_SAMP_H +#define A_SAMP_H + +#include + +#include "common.h" + +#include "SDK/amx/amx.h" +#include "SDK/plugincommon.h" +#include "Invoke.h" + +#include "a_players.h" +#include "a_vehicles.h" +#include "a_objects.h" + +// Limits and internal constants +#define MAX_PLAYER_NAME (24) +#define MAX_PLAYERS (500) +#define MAX_VEHICLES (2000) +#define INVALID_PLAYER_ID (0xFFFF) +#define INVALID_VEHICLE_ID (0xFFFF) +#define NO_TEAM (255) +#define MAX_OBJECTS (1000) +#define INVALID_OBJECT_ID (0xFFFF) +#define MAX_GANG_ZONES (1024) +#define MAX_TEXT_DRAWS (2048) +#define MAX_PLAYER_TEXT_DRAWS (256) +#define MAX_MENUS (128) +#define MAX_3DTEXT_GLOBAL (1024) +#define MAX_3DTEXT_PLAYER (1024) +#define MAX_PICKUPS (4096) +#define INVALID_MENU (0xFF) +#define INVALID_TEXT_DRAW (0xFFFF) +#define INVALID_GANG_ZONE (-1) +#define INVALID_3DTEXT_ID (0xFFFF) + +// Util +PLUGIN_EXPORT void _samp_SendClientMessage(int playerid, unsigned int color, char* message); +PLUGIN_EXPORT void _samp_SendClientMessageToAll(unsigned int color, char* message); +PLUGIN_EXPORT void _samp_SendPlayerMessageToPlayer(int playerid, int senderid, char* message); +PLUGIN_EXPORT void _samp_SendPlayerMessageToAll(int senderid, char* message); +PLUGIN_EXPORT void _samp_SendDeathMessage(int killer, int killee, int weapon); +PLUGIN_EXPORT void _samp_GameTextForAll(char* string, int time, int style); +PLUGIN_EXPORT void _samp_GameTextForPlayer(int playerid, char* string, int time, int style); +PLUGIN_EXPORT int _samp_GetTickCount(); +PLUGIN_EXPORT int _samp_GetMaxPlayers(); + +// Game +PLUGIN_EXPORT void _samp_SetGameModeText(char* string); +PLUGIN_EXPORT void _samp_SetTeamCount(int count); // No effect +PLUGIN_EXPORT int _samp_AddPlayerClass(int modelid, float spawn_x, float spawn_y, float spawn_z, float z_angle, int weapon1, int weapon1_ammo, int weapon2, int weapon2_ammo, int weapon3, int weapon3_ammo); +PLUGIN_EXPORT int _samp_AddPlayerClassEx(int teamid, int modelid, float spawn_x, float spawn_y, float spawn_z, float z_angle, int weapon1, int weapon1_ammo, int weapon2, int weapon2_ammo, int weapon3, int weapon3_ammo); +PLUGIN_EXPORT int _samp_AddStaticVehicle(int modelid, float spawn_x, float spawn_y, float spawn_z, float z_angle, int color1, int color2rt); +PLUGIN_EXPORT int _samp_AddStaticVehicleEx(int modelid, float spawn_x, float spawn_y, float spawn_z, float z_angle, int color1, int color2, int respawn_delay); +PLUGIN_EXPORT int _samp_AddStaticPickup(int model, int type, float x, float y, float z, int virtualworld=0); +PLUGIN_EXPORT int _samp_CreatePickup(int model, int type, float x, float y, float z, int virtualworld=0); +PLUGIN_EXPORT void _samp_DestroyPickup(int pickup); +PLUGIN_EXPORT void _samp_ShowNameTags(int show); +PLUGIN_EXPORT void _samp_ShowPlayerMarkers(int mode); +PLUGIN_EXPORT void _samp_GameModeExit(); +PLUGIN_EXPORT void _samp_SetWorldTime(int hour); +PLUGIN_EXPORT void _samp_GetWeaponName(int weaponid, char* weapon, int len); +PLUGIN_EXPORT void _samp_EnableTirePopping(int enable); // Deprecated +PLUGIN_EXPORT void _samp_AllowInteriorWeapons(int allow); +PLUGIN_EXPORT void _samp_SetWeather(int weatherid); +PLUGIN_EXPORT void _samp_SetGravity(float gravity); +PLUGIN_EXPORT void _samp_AllowAdminTeleport(int allow); // Deprecated +PLUGIN_EXPORT void _samp_SetDeathDropAmount(int amount); // Deprecated +PLUGIN_EXPORT void _samp_CreateExplosion(float x, float y, float z, int type, float radius); +PLUGIN_EXPORT void _samp_EnableZoneNames(int enable); +PLUGIN_EXPORT void _samp_UsePlayerPedAnims(); +PLUGIN_EXPORT void _samp_DisableInteriorEnterExits(); +PLUGIN_EXPORT void _samp_SetNameTagDrawDistance(float distance); +PLUGIN_EXPORT void _samp_DisableNameTagLOS(); +PLUGIN_EXPORT void _samp_LimitGlobalChatRadius(float chat_radius); +PLUGIN_EXPORT void _samp_LimitPlayerMarkerRadius(float marker_radius); + +// Npc +PLUGIN_EXPORT void _samp_ConnectNPC(char* name, char* script); +PLUGIN_EXPORT int _samp_IsPlayerNPC(int playerid); + +// Admin +PLUGIN_EXPORT int _samp_IsPlayerAdmin(int playerid); +PLUGIN_EXPORT void _samp_Kick(int playerid); +PLUGIN_EXPORT void _samp_Ban(int playerid); +PLUGIN_EXPORT void _samp_BanEx(int playerid, char* reason); +PLUGIN_EXPORT void _samp_SendRconCommand(char* command); +PLUGIN_EXPORT void _samp_GetServerVarAsString(char* varname, char* buffer, int len); +PLUGIN_EXPORT int _samp_GetServerVarAsInt(char* varname); +PLUGIN_EXPORT int _samp_GetServerVarAsBool(char* varname); +PLUGIN_EXPORT void _samp_GetPlayerNetworkStats(int playerid, char* retstr, int retstr_size); +PLUGIN_EXPORT void _samp_GetNetworkStats(char* retstr, int retstr_size); +PLUGIN_EXPORT int _samp_GetPlayerVersion(int playerid, char* version, int len); + +// Menu +PLUGIN_EXPORT int _samp_CreateMenu(char* title, int columns, float x, float y, float col1width, float col2width=0.0); +PLUGIN_EXPORT int _samp_DestroyMenu(int menuid); +PLUGIN_EXPORT void _samp_AddMenuItem(int menuid, int column, char* menutext); +PLUGIN_EXPORT void _samp_SetMenuColumnHeader(int menuid, int column, char* columnheader); +PLUGIN_EXPORT void _samp_ShowMenuForPlayer(int menuid, int playerid); +PLUGIN_EXPORT void _samp_HideMenuForPlayer(int menuid, int playerid); +PLUGIN_EXPORT int _samp_IsValidMenu(int menuid); +PLUGIN_EXPORT void _samp_DisableMenu(int menuid); +PLUGIN_EXPORT void _samp_DisableMenuRow(int menuid, int row); +PLUGIN_EXPORT int _samp_GetPlayerMenu(int playerid); + +// Text Draw +PLUGIN_EXPORT int _samp_TextDrawCreate(float x, float y, char* text); +PLUGIN_EXPORT void _samp_TextDrawDestroy(int text); +PLUGIN_EXPORT void _samp_TextDrawLetterSize(int text, float x, float y); +PLUGIN_EXPORT void _samp_TextDrawTextSize(int text, float x, float y); +PLUGIN_EXPORT void _samp_TextDrawAlignment(int text, int alignment); +PLUGIN_EXPORT void _samp_TextDrawColor(int text, unsigned int color); +PLUGIN_EXPORT void _samp_TextDrawUseBox(int text, int use); +PLUGIN_EXPORT void _samp_TextDrawBoxColor(int text, int color); +PLUGIN_EXPORT void _samp_TextDrawSetShadow(int text, int size); +PLUGIN_EXPORT void _samp_TextDrawSetOutline(int text, int size); +PLUGIN_EXPORT void _samp_TextDrawBackgroundColor(int text, unsigned int color); +PLUGIN_EXPORT void _samp_TextDrawFont(int text, int font); +PLUGIN_EXPORT void _samp_TextDrawSetProportional(int text, int set); +PLUGIN_EXPORT void _samp_TextDrawSetSelectable(int text, int set); +PLUGIN_EXPORT void _samp_TextDrawShowForPlayer(int playerid, int text); +PLUGIN_EXPORT void _samp_TextDrawHideForPlayer(int playerid, int text); +PLUGIN_EXPORT void _samp_TextDrawShowForAll(int text); +PLUGIN_EXPORT void _samp_TextDrawHideForAll(int text); +PLUGIN_EXPORT void _samp_TextDrawSetString(int text, char* string); + +// Gang Zones +PLUGIN_EXPORT int _samp_GangZoneCreate(float minx, float miny, float maxx, float maxy); +PLUGIN_EXPORT void _samp_GangZoneDestroy(int zone); +PLUGIN_EXPORT void _samp_GangZoneShowForPlayer(int playerid, int zone, unsigned int color); +PLUGIN_EXPORT int _samp_GangZoneShowForAll(int zone, unsigned int color); +PLUGIN_EXPORT void _samp_GangZoneHideForPlayer(int playerid, int zone); +PLUGIN_EXPORT void _samp_GangZoneHideForAll(int zone); +PLUGIN_EXPORT void _samp_GangZoneFlashForPlayer(int playerid, int zone, unsigned int flashcolor); +PLUGIN_EXPORT void _samp_GangZoneFlashForAll(int zone, unsigned int flashcolor); +PLUGIN_EXPORT void _samp_GangZoneStopFlashForPlayer(int playerid, int zone); +PLUGIN_EXPORT void _samp_GangZoneStopFlashForAll(int zone); + +// Global 3D Text Labels +PLUGIN_EXPORT int _samp_Create3DTextLabel(char* text, int color, float x, float y, float z, float drawdistance, int virtualworld, int testlos=0); +PLUGIN_EXPORT int _samp_Delete3DTextLabel(int id); +PLUGIN_EXPORT void _samp_Attach3DTextLabelToPlayer(int id, int playerid, float offsetx, float offsety, float offsetz); +PLUGIN_EXPORT void _samp_Attach3DTextLabelToVehicle(int id, int vehicleid, float offsetx, float offsety, float offsetz); +PLUGIN_EXPORT void _samp_Update3DTextLabelText(int id, int color, char* text); + +// Per-player 3D Text Labels +PLUGIN_EXPORT int _samp_CreatePlayer3DTextLabel(int playerid, char* text, int color, float x, float y, float z, float drawdistance, int attachedplayer=INVALID_PLAYER_ID, int attachedvehicle=INVALID_VEHICLE_ID, int testlos=0); +PLUGIN_EXPORT void _samp_DeletePlayer3DTextLabel(int playerid, int id); +PLUGIN_EXPORT void _samp_UpdatePlayer3DTextLabelText(int playerid, int id, int color, char* text); + +// Player GUI Dialog +PLUGIN_EXPORT void _samp_ShowPlayerDialog(int playerid, int dialogid, int style, char* caption, char* info, char* button1, char* button2); + +#endif // A_SAMP_H + diff --git a/sampdotnethook/src/a_vehicles.cpp b/sampdotnethook/src/a_vehicles.cpp new file mode 100644 index 0000000..03ab828 --- /dev/null +++ b/sampdotnethook/src/a_vehicles.cpp @@ -0,0 +1,206 @@ +#include "a_samp.h" + +int _samp_CreateVehicle(int vehicletype, float x, float y, float z, float rotation, int color1, int color2, int respawn_delay) { + return g_Invoke->callNative(&PAWN::CreateVehicle, vehicletype, x, y, z, rotation, color1, color2, respawn_delay); +} + +void _samp_DestroyVehicle(int vehicleid) { + g_Invoke->callNative(&PAWN::DestroyVehicle, vehicleid); +} + +void _samp_IsVehicleStreamedIn(int vehicleid, int forplayerid) { + g_Invoke->callNative(&PAWN::IsVehicleStreamedIn, vehicleid, forplayerid); +} + +void _samp_GetVehiclePos(int vehicleid, float& x, float& y, float& z) { + float _x = 0.0; + float _y = 0.0; + float _z = 0.0; + g_Invoke->callNative(&PAWN::GetVehiclePos, vehicleid, &_x, &_y, &_z); + x = _x; + y = _y; + z = _z; +} + +void _samp_SetVehiclePos(int vehicleid, float x, float y, float z) { + g_Invoke->callNative(&PAWN::SetVehiclePos, vehicleid, x, y, z); +} + +void _samp_GetVehicleZAngle(int vehicleid, float& z_angle) { + float _z_angle = 0.0; + g_Invoke->callNative(&PAWN::GetVehicleZAngle, vehicleid, &_z_angle); + z_angle = _z_angle; +} + +void _samp_GetVehicleRotationQuat(int vehicleid, float& w, float& x, float& y, float& z) { + float _w = 0.0; + float _x = 0.0; + float _y = 0.0; + float _z = 0.0; + g_Invoke->callNative(&PAWN::GetVehicleRotationQuat, vehicleid, &_w, &_x, &_y, &_z); + w = _w; + x = _x; + y = _y; + z = _z; +} + +void _samp_GetVehicleDistanceFromPoint(int vehicleid, float x, float y, float z) { + g_Invoke->callNative(&PAWN::GetVehicleDistanceFromPoint, vehicleid, x, y, z); +} + +void _samp_SetVehicleZAngle(int vehicleid, float z_angle) { + g_Invoke->callNative(&PAWN::SetVehicleZAngle, vehicleid, z_angle); +} + +void _samp_SetVehicleParamsForPlayer(int vehicleid, int playerid, int objective, int doorslocked) { + g_Invoke->callNative(&PAWN::SetVehicleParamsForPlayer, vehicleid, playerid, objective, doorslocked); +} + +void _samp_ManualVehicleEngineAndLights() { + //g_Invoke->callNative(&PAWN::ManualVehicleEngineAndLights); +} + +void _samp_SetVehicleParamsEx(int vehicleid, int engine, int lights, int alarm, int doors, int bonnet, int boot, int objective) { + g_Invoke->callNative(&PAWN::SetVehicleParamsEx, vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); +} + +void _samp_GetVehicleParamsEx(int vehicleid, int& engine, int& lights, int& alarm, int& doors, int& bonnet, int& boot, int& objective) { + int _engine = 0; + int _lights = 0; + int _alarm = 0; + int _doors = 0; + int _bonnet = 0; + int _boot = 0; + int _objective = 0; + g_Invoke->callNative(&PAWN::GetVehicleParamsEx, vehicleid, &_engine, &_lights, &_alarm, &_doors, &_bonnet, &_boot, &_objective); + engine = _engine; + lights = _lights; + alarm = _alarm; + doors = _doors; + bonnet = _bonnet; + boot = _boot; + objective = _objective; +} + +void _samp_SetVehicleToRespawn(int vehicleid) { + g_Invoke->callNative(&PAWN::SetVehicleToRespawn, vehicleid); +} + +void _samp_LinkVehicleToInterior(int vehicleid, int interiorid) { + g_Invoke->callNative(&PAWN::LinkVehicleToInterior, vehicleid, interiorid); +} + +void _samp_AddVehicleComponent(int vehicleid, int componentid) { + g_Invoke->callNative(&PAWN::AddVehicleComponent, vehicleid, componentid); +} + +void _samp_RemoveVehicleComponent(int vehicleid, int componentid) { + g_Invoke->callNative(&PAWN::RemoveVehicleComponent, vehicleid, componentid); +} + +void _samp_ChangeVehicleColor(int vehicleid, int color1, int color2) { + g_Invoke->callNative(&PAWN::ChangeVehicleColor, vehicleid, color1, color2); +} + +void _samp_ChangeVehiclePaintjob(int vehicleid, int paintjobid) { + g_Invoke->callNative(&PAWN::ChangeVehiclePaintjob, vehicleid, paintjobid); +} + +void _samp_SetVehicleHealth(int vehicleid, float health) { + g_Invoke->callNative(&PAWN::SetVehicleHealth, vehicleid, health); +} + +void _samp_GetVehicleHealth(int vehicleid, float& health) { + float _health = 0.0; + g_Invoke->callNative(&PAWN::GetVehicleHealth, vehicleid, &_health); + health = _health; +} + +void _samp_AttachTrailerToVehicle(int trailerid, int vehicleid) { + g_Invoke->callNative(&PAWN::AttachTrailerToVehicle, trailerid, vehicleid); +} + +void _samp_DetachTrailerFromVehicle(int vehicleid) { + g_Invoke->callNative(&PAWN::DetachTrailerFromVehicle, vehicleid); +} + +int _samp_IsTrailerAttachedToVehicle(int vehicleid) { + return g_Invoke->callNative(&PAWN::IsTrailerAttachedToVehicle, vehicleid); +} + +int _samp_GetVehicleTrailer(int vehicleid) { + return g_Invoke->callNative(&PAWN::GetVehicleTrailer, vehicleid); +} + +void _samp_SetVehicleNumberPlate(int vehicleid, char* numberplate) { + g_Invoke->callNative(&PAWN::SetVehicleNumberPlate, vehicleid, numberplate); +} + +int _samp_GetVehicleModel(int vehicleid) { + return g_Invoke->callNative(&PAWN::GetVehicleModel, vehicleid); +} + +int _samp_GetVehicleComponentInSlot(int vehicleid, int slot) { + return g_Invoke->callNative(&PAWN::GetVehicleComponentInSlot, vehicleid, slot); +} + +int _samp_GetVehicleComponentType(int component) { + return g_Invoke->callNative(&PAWN::GetVehicleComponentType, component); +} + +void _samp_RepairVehicle(int vehicleid) { + g_Invoke->callNative(&PAWN::RepairVehicle, vehicleid); +} + +void _samp_GetVehicleVelocity(int vehicleid, float& x, float& y, float& z) { + float _x = 0.0; + float _y = 0.0; + float _z = 0.0; + g_Invoke->callNative(&PAWN::GetVehicleVelocity, vehicleid, &_x, &_y, &_z); + x = _x; + y = _y; + z = _z; +} + +void _samp_SetVehicleVelocity(int vehicleid, float x, float y, float z) { + g_Invoke->callNative(&PAWN::SetVehicleVelocity, vehicleid, x, y, z); +} + +void _samp_SetVehicleAngularVelocity(int vehicleid, float x, float y, float z) { + g_Invoke->callNative(&PAWN::SetVehicleAngularVelocity, vehicleid, x, y, z); +} + +void _samp_GetVehicleDamageStatus(int vehicleid, int& panels, int& doors, int& lights, int& tires) { + int _panels = 0; + int _doors = 0; + int _lights = 0; + int _tires = 0; + g_Invoke->callNative(&PAWN::GetVehicleDamageStatus, vehicleid, &_panels, &_doors, &_lights, &_tires); + panels = _panels; + doors = _doors; + lights = _lights; + tires = _tires; +} + +void _samp_UpdateVehicleDamageStatus(int vehicleid, int panels, int doors, int lights, int tires) { + g_Invoke->callNative(&PAWN::UpdateVehicleDamageStatus, vehicleid, panels, doors, lights, tires); +} + +void _samp_GetVehicleModelInfo(int vehiclemodel, int infotype, float& x, float& y, float& z) { + float _x = 0.0; + float _y = 0.0; + float _z = 0.0; + g_Invoke->callNative(&PAWN::GetVehicleModelInfo, vehiclemodel, infotype, &_x, &_y, &_z); + x = _x; + y = _y; + z = _z; +} + +void _samp_SetVehicleVirtualWorld(int vehicleid, int worldid) { + g_Invoke->callNative(&PAWN::SetVehicleVirtualWorld, vehicleid, worldid); +} + +int _samp_GetVehicleVirtualWorld(int vehicleid) { + return g_Invoke->callNative(&PAWN::GetVehicleVirtualWorld, vehicleid); +} + diff --git a/sampdotnethook/src/a_vehicles.h b/sampdotnethook/src/a_vehicles.h new file mode 100644 index 0000000..411f43e --- /dev/null +++ b/sampdotnethook/src/a_vehicles.h @@ -0,0 +1,44 @@ +#ifndef _A_VEHICLES_H +#define _A_VEHICLES_H + +PLUGIN_EXPORT int _samp_CreateVehicle(int vehicletype, float x, float y, float z, float rotation, int color1, int color2, int respawn_delay); +PLUGIN_EXPORT void _samp_DestroyVehicle(int vehicleid); +PLUGIN_EXPORT void _samp_IsVehicleStreamedIn(int vehicleid, int forplayerid); +PLUGIN_EXPORT void _samp_GetVehiclePos(int vehicleid, float& x, float& y, float& z); +PLUGIN_EXPORT void _samp_SetVehiclePos(int vehicleid, float x, float y, float z); +PLUGIN_EXPORT void _samp_GetVehicleZAngle(int vehicleid, float& z_angle); +PLUGIN_EXPORT void _samp_GetVehicleRotationQuat(int vehicleid, float& w, float& x, float& y, float& z); +PLUGIN_EXPORT void _samp_GetVehicleDistanceFromPoint(int vehicleid, float x, float y, float z); +PLUGIN_EXPORT void _samp_SetVehicleZAngle(int vehicleid, float z_angle); +PLUGIN_EXPORT void _samp_SetVehicleParamsForPlayer(int vehicleid, int playerid, int objective, int doorslocked); +PLUGIN_EXPORT void _samp_ManualVehicleEngineAndLights(int ); +PLUGIN_EXPORT void _samp_SetVehicleParamsEx(int vehicleid, int engine, int lights, int alarm, int doors, int bonnet, int boot, int objective); +PLUGIN_EXPORT void _samp_GetVehicleParamsEx(int vehicleid, int& engine, int& lights, int& alarm, int& doors, int& bonnet, int& boot, int& objective); +PLUGIN_EXPORT void _samp_SetVehicleToRespawn(int vehicleid); +PLUGIN_EXPORT void _samp_LinkVehicleToInterior(int vehicleid, int interiorid); +PLUGIN_EXPORT void _samp_AddVehicleComponent(int vehicleid, int componentid); +PLUGIN_EXPORT void _samp_RemoveVehicleComponent(int vehicleid, int componentid); +PLUGIN_EXPORT void _samp_ChangeVehicleColor(int vehicleid, int color1, int color2); +PLUGIN_EXPORT void _samp_ChangeVehiclePaintjob(int vehicleid, int paintjobid); +PLUGIN_EXPORT void _samp_SetVehicleHealth(int vehicleid, float health); +PLUGIN_EXPORT void _samp_GetVehicleHealth(int vehicleid, float& health); +PLUGIN_EXPORT void _samp_AttachTrailerToVehicle(int trailerid, int vehicleid); +PLUGIN_EXPORT void _samp_DetachTrailerFromVehicle(int vehicleid); +PLUGIN_EXPORT int _samp_IsTrailerAttachedToVehicle(int vehicleid); +PLUGIN_EXPORT int _samp_GetVehicleTrailer(int vehicleid); +PLUGIN_EXPORT void _samp_SetVehicleNumberPlate(int vehicleid, char* numberplate); +PLUGIN_EXPORT int _samp_GetVehicleModel(int vehicleid); +PLUGIN_EXPORT int _samp_GetVehicleComponentInSlot(int vehicleid, int slot); +PLUGIN_EXPORT int _samp_GetVehicleComponentType(int component); +PLUGIN_EXPORT void _samp_RepairVehicle(int vehicleid); +PLUGIN_EXPORT void _samp_GetVehicleVelocity(int vehicleid, float& x, float& y, float& z); +PLUGIN_EXPORT void _samp_SetVehicleVelocity(int vehicleid, float x, float y, float z); +PLUGIN_EXPORT void _samp_SetVehicleAngularVelocity(int vehicleid, float x, float y, float z); +PLUGIN_EXPORT void _samp_GetVehicleDamageStatus(int vehicleid, int& panels, int& doors, int& lights, int& tires); +PLUGIN_EXPORT void _samp_UpdateVehicleDamageStatus(int vehicleid, int panels, int doors, int lights, int tires); +PLUGIN_EXPORT void _samp_GetVehicleModelInfo(int vehiclemodel, int infotype, float& x, float& y, float& z); +PLUGIN_EXPORT void _samp_SetVehicleVirtualWorld(int vehicleid, int worldid); +PLUGIN_EXPORT int _samp_GetVehicleVirtualWorld(int vehicleid); + +#endif //_A_VEHICLES_H + diff --git a/sampdotnethook/src/add.h b/sampdotnethook/src/add.h new file mode 100644 index 0000000..68a05f4 --- /dev/null +++ b/sampdotnethook/src/add.h @@ -0,0 +1,24 @@ +#ifndef ADD_H_INCLUDED +#define ADD_H_INCLUDED + +#ifdef _WIN32 + + /* You should define ADD_EXPORTS *only* when building the DLL. */ + #ifdef ADD_EXPORTS + #define ADDAPI __declspec(dllexport) + #else + #define ADDAPI __declspec(dllimport) + #endif + + /* Define calling convention in one place, for convenience. */ + #define ADDCALL __cdecl + +#else /* _WIN32 not defined. */ + + /* Define with no value on non-Windows OSes. */ + #define ADDAPI + #define ADDCALL + +#endif + +#endif // ADD_H_INCLUDED diff --git a/sampdotnethook/src/callbacks.cpp b/sampdotnethook/src/callbacks.cpp new file mode 100644 index 0000000..da6749e --- /dev/null +++ b/sampdotnethook/src/callbacks.cpp @@ -0,0 +1,816 @@ +#include "callbacks.h" +#include "Mono.h" + +#include +#include + +// PAWN native: native CBOnGameModeInit(); +cell AMX_NATIVE_CALL CBOnGameModeInit(AMX *amx, cell *params) { + g_Mono->callMethod("Internal:OnGameModeInit", 0); + return 1; +} + +// PAWN native: native CBOnGameModeExit(); +cell AMX_NATIVE_CALL CBOnGameModeExit(AMX *amx, cell *params) { + g_Mono->callMethod("Internal:OnGameModeExit", 0); + return 1; +} + +// PAWN native: native CBOnPlayerConnect(playerid); +cell AMX_NATIVE_CALL CBOnPlayerConnect(AMX *amx, cell *params) { + // Create variables to store the arguments + void *args[1]; + int playerid = params[1]; + args[0] = &playerid; + + // Call the method + g_Mono->callMethod("Internal:OnPlayerConnect", args); + return 1; +} + +// PAWN native: native CBOnPlayerDisconnect(playerid, reason); +cell AMX_NATIVE_CALL CBOnPlayerDisconnect(AMX *amx, cell *params) { + // Create variables to store the arguments + void *args[2]; + int + playerid = params[1], + reason = params[2]; + args[0] = &playerid; + args[1] = &reason; + + // Call the method + g_Mono->callMethod("Internal:OnPlayerDisconnect", args); + + return 1; +} + +// PAWN native: native CBOnPlayerSpawn(playerid); +cell AMX_NATIVE_CALL CBOnPlayerSpawn(AMX *amx, cell *params) { + // Create variables to store the arguments + void *args[1]; + int playerid = params[1]; + args[0] = &playerid; + + // Call the method and return result + return g_Mono->callReturn("Internal:OnPlayerSpawn", args); +} + +// PAWN native: native CBOnPlayerDeath(playerid, killerid, reason); +cell AMX_NATIVE_CALL CBOnPlayerDeath(AMX *amx, cell *params) { + void *args[3]; + int + playerid = params[1], + killerid = params[2], + reason = params[3]; + args[0] = &playerid; + args[1] = &killerid; + args[2] = &reason; + + g_Mono->callMethod("Internal:OnPlayerDeath", args); + return 1; +} + +// PAWN native: native CBOnVehicleSpawn(vehicleid); +cell AMX_NATIVE_CALL CBOnVehicleSpawn(AMX *amx, cell *params) { + void *args[1]; + int vehicleid = params[1]; + args[0] = &vehicleid; + + g_Mono->callMethod("Internal:OnVehicleSpawn", args); + return 1; +} + +// PAWN native: native CBOnVehicleDeath(vehicleid, killerid); +cell AMX_NATIVE_CALL CBOnVehicleDeath(AMX *amx, cell *params) { + void *args[2]; + int + vehicleid = params[1], + killerid = params[2]; + args[0] = &vehicleid; + args[1] = &killerid; + + g_Mono->callMethod("Internal:OnVehicleDeath", args); + return 1; +} + +// PAWN native: native CBOnPlayerText(playerid, text[]); +cell AMX_NATIVE_CALL CBOnPlayerText(AMX *amx, cell *params) { + // Define some variables + int + len = 0, + ret = 0; + cell *addr = 0; + + // Get address and string length + amx_GetAddr(amx, params[2], &addr); + amx_StrLen(addr, &len); + + if(len) { + // Create a buffer variable + char *message = new char[++len]; + + // Get the string and store it in the bufer + amx_GetString(message, addr, 0, len); + + + // Create variables to store the arguments + void *args[2]; + int playerid = params[1]; + args[0] = &playerid; + args[1] = g_Mono->createString(message); + + // Call method and return result + ret = g_Mono->callReturn("Internal:OnPlayerText", args); + + // Delete message from memory + delete[] message; + } + + return ret; +} + +// PAWN native: native CBOnPlayerCommandText(playerid, cmdtext[]); +cell AMX_NATIVE_CALL CBOnPlayerCommandText(AMX *amx, cell *params) { + // Define some variables + int + len = 0, + ret = 0; + cell *addr = 0; + + // Get address and string length + amx_GetAddr(amx, params[2], &addr); + amx_StrLen(addr, &len); + + if(len) { + // Create a buffer variable + char *cmdtext = new char[++len]; + + // Get the string and store it in the bufer + amx_GetString(cmdtext, addr, 0, len); + + // Create variables to store the arguments + void *args[2]; + int playerid = params[1]; + args[0] = &playerid; + args[1] = g_Mono->createString(cmdtext); + + // Call the method + ret = g_Mono->callReturn("Internal:OnPlayerCommandText", args); + + // Remove cmdtext from memory + delete[] cmdtext; + } + + // Return 'ret' + return ret; +} + +// PAWN native: native CBOnPlayerRequestClass(playerid, classid); +cell AMX_NATIVE_CALL CBOnPlayerRequestClass(AMX *amx, cell *params) { + // Create variables to store the arguments + void *args[2]; + int + playerid = params[1], + classid = params[2]; + args[0] = &playerid; + args[1] = &classid; + + // Call the method and return result + return g_Mono->callReturn("Internal:OnPlayerRequestClass", args); +} + +// PAWN native: native CBOnPlayerEnterVehicle(playerid, vehicleid, ispassenger); +cell AMX_NATIVE_CALL CBOnPlayerEnterVehicle(AMX *amx, cell *params) { + void *args[3]; + int + playerid = params[1], + vehicleid = params[2], + ispassenger = params[3]; + args[0] = &playerid; + args[1] = &vehicleid; + args[2] = &ispassenger; + + g_Mono->callMethod("Internal:OnPlayerEnterVehicle", args); + return 1; +} + +// PAWN native: native CBOnPlayerExitVehicle(playerid, vehicleid); +cell AMX_NATIVE_CALL CBOnPlayerExitVehicle(AMX *amx, cell *params) { + void *args[1]; + int + playerid = params[1], + vehicleid = params[2]; + args[0] = &playerid; + args[1] = &vehicleid; + + g_Mono->callMethod("Internal:OnPlayerExitVehicle", args); + return 1; +} + +// PAWN native: native CBOnPlayerStateChange(playerid, newstate, oldstate); +cell AMX_NATIVE_CALL CBOnPlayerStateChange(AMX *amx, cell *params) { + void *args[3]; + int + playerid = params[1], + newstate = params[2], + oldstate = params[3]; + args[0] = &playerid; + args[1] = &newstate; + args[2] = &oldstate; + + g_Mono->callMethod("Internal:OnPlayerStateChange", args); + return 1; +} + +// PAWN native: native CBOnPlayerEnterCheckpoint(playerid); +cell AMX_NATIVE_CALL CBOnPlayerEnterCheckpoint(AMX *amx, cell *params) { + void *args[1]; + int playerid = params[1]; + args[0] = &playerid; + + g_Mono->callMethod("Internal:OnPlayerEnterCheckpoint", args); + return 1; +} + +// PAWN native: native CBOnPlayerLeaveCheckpoint(playerid); +cell AMX_NATIVE_CALL CBOnPlayerLeaveCheckpoint(AMX *amx, cell *params) { + void *args[1]; + int playerid = params[1]; + args[0] = &playerid; + + g_Mono->callMethod("Internal:OnPlayerLeaveCheckpoint", args); + return 1; +} + +// PAWN native: native CBOnPlayerEnterRaceCheckpoint(playerid); +cell AMX_NATIVE_CALL CBOnPlayerEnterRaceCheckpoint(AMX *amx, cell *params) { + void *args[1]; + int playerid = params[1]; + args[0] = &playerid; + + g_Mono->callMethod("Internal:OnPlayerEnterRaceCheckpoint", args); + return 1; +} + +// PAWN native: native CBOnPlayerLeaveRaceCheckpoint(playerid); +cell AMX_NATIVE_CALL CBOnPlayerLeaveRaceCheckpoint(AMX *amx, cell *params) { + void *args[1]; + int playerid = params[1]; + args[0] = &playerid; + + g_Mono->callMethod("Internal:OnPlayerLeaveRaceCheckpoint", args); + return 1; +} + +// PAWN native: native CBOnRconCommand(cmd[]); +cell AMX_NATIVE_CALL CBOnRconCommand(AMX *amx, cell *params) { + // Define some variables + int + len = 0, + ret = 0; + cell *addr = 0; + + // Get address and string length + amx_GetAddr(amx, params[1], &addr); + amx_StrLen(addr, &len); + + + if(len) { + // Create a buffer variable + char *cmd = new char[++len]; + + // Get the string and store it in the bufer + amx_GetString(cmd, addr, 0, len); + + + // Create variables to store the arguments + void *args[1]; + args[0] = g_Mono->createString(cmd); + + // Call method and return result + ret = g_Mono->callReturn("Internal:OnRconCommand", args); + + // Delete message from memory + delete[] cmd; + } + + return ret; +} + +// PAWN native: native CBOnPlayerRequestSpawn(playerid); +cell AMX_NATIVE_CALL CBOnPlayerRequestSpawn(AMX *amx, cell *params) { + void *args[1]; + int playerid = params[1]; + args[0] = &playerid; + + return g_Mono->callReturn("Internal:OnPlayerRequestSpawn", args); +} + +// PAWN native: native CBOnObjectMoved(objectid); +cell AMX_NATIVE_CALL CBOnObjectMoved(AMX *amx, cell *params) { + // Set arguments + void *args[1]; + int objectid = params[1]; + args[0] = &objectid; + + // Call method + g_Mono->callMethod("Internal:OnObjectMoved", args); + return 1; +} + +// PAWN native: native CBOnPlayerObjectMoved(playerid, objectid); +cell AMX_NATIVE_CALL CBOnPlayerObjectMoved(AMX *amx, cell *params) { + void *args[2]; + int + playerid = params[1], + objectid = params[2]; + args[0] = &playerid; + args[1] = &objectid; + + g_Mono->callMethod("Internal:OnPlayerObjectMoved", args); + return 1; +} + +// PAWN native: native CBOnPlayerPickUpPickup(playerid, pickupid); +cell AMX_NATIVE_CALL CBOnPlayerPickUpPickup(AMX *amx, cell *params) { + void *args[1]; + int + playerid = params[1], + pickupid = params[2]; + args[0] = &playerid; + args[1] = &pickupid; + + g_Mono->callMethod("Internal:OnPlayerPickUpPickup", args); + return 1; +} + +// PAWN native: native CBOnVehicleMod(playerid, vehicleid, componentid); +cell AMX_NATIVE_CALL CBOnVehicleMod(AMX *amx, cell *params) { + void *args[3]; + int + playerid = params[1], + vehicleid = params[2], + componentid = params[3]; + args[0] = &playerid; + args[1] = &vehicleid; + args[2] = &componentid; + + return g_Mono->callReturn("Internal:OnVehicleMod", args); +} + +// PAWN native: native CBOnEnterExitModShop(playerid, enterexit, interiorid); +cell AMX_NATIVE_CALL CBOnEnterExitModShop(AMX *amx, cell *params) { + void *args[3]; + int + playerid = params[1], + enterexit = params[2], + interiorid = params[3]; + + // Store the arguments + args[0] = &playerid; + args[1] = &enterexit; + args[2] = &interiorid; + + return g_Mono->callReturn("Internal:OnEnterExitModShop", args); +} + +// PAWN native: native CBOnVehiclePaintjob(playerid, vehicleid, paintjobid); +cell AMX_NATIVE_CALL CBOnVehiclePaintjob(AMX *amx, cell *params) { + void *args[3]; + int + playerid = params[1], + vehicleid = params[2], + paintjobid = params[3]; + args[0] = &playerid; + args[1] = &vehicleid; + args[2] = &paintjobid; + + g_Mono->callMethod("Internal:OnVehiclePaintjob", args); + return 1; +} + +// PAWN native: native CBOnVehicleRespray(playerid, vehicleid, color1, color2); +cell AMX_NATIVE_CALL CBOnVehicleRespray(AMX *amx, cell *params) { + void *args[4]; + int + playerid = params[1], + vehicleid = params[2], + color1 = params[3], + color2 = params[4]; + args[0] = &playerid; + args[1] = &vehicleid; + args[2] = &color1; + args[3] = &color2; + + g_Mono->callMethod("Internal:OnVehicleRespray", args); + return 1; +} + +// PAWN native: native CBOnVehicleDamageStatusUpdate(vehicleid, playerid); +cell AMX_NATIVE_CALL CBOnVehicleDamageStatusUpdate(AMX *amx, cell *params) { + void *args[2]; + int + vehicleid = params[1], + playerid = params[2]; + args[0] = &vehicleid; + args[1] = &playerid; + + g_Mono->callMethod("Internal:OnVehicleDamageStatusUpdate", args); + return 1; +} + +// PAWN native: native CBOnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat); +cell AMX_NATIVE_CALL CBOnUnoccupiedVehicleUpdate(AMX *amx, cell *params) { + void *args[3]; + int + vehicleid = params[1], + playerid = params[2], + passenger_seat = params[3]; + args[0] = &vehicleid; + args[1] = &playerid; + args[2] = &passenger_seat; + + g_Mono->callMethod("Internal:OnUnoccupiedVehicleUpdate", args); + return 1; +} + +// PAWN native: native CBOnPlayerSelectedMenuRow(playerid, row); +cell AMX_NATIVE_CALL CBOnPlayerSelectedMenuRow(AMX *amx, cell *params) { + void *args[2]; + int + playerid = params[1], + row = params[2]; + args[0] = &playerid; + args[1] = &row; + + g_Mono->callMethod("Internal:OnPlayerSelectedMenuRow", args); + return 1; +} + +// PAWN native: native CBOnPlayerExitedMenu(playerid); +cell AMX_NATIVE_CALL CBOnPlayerExitedMenu(AMX *amx, cell *params) { + void *args[1]; + int playerid = params[1]; + args[0] = &playerid; + + g_Mono->callMethod("Internal:OnPlayerExitedMenu", args); + return 1; +} + +// PAWN native: native CBOnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid); +cell AMX_NATIVE_CALL CBOnPlayerInteriorChange(AMX *amx, cell *params) { + void *args[3]; + int + playerid = params[1], + newinteriorid = params[2], + oldinteriorid = params[3]; + args[0] = &playerid; + args[1] = &newinteriorid; + args[2] = &oldinteriorid; + + g_Mono->callMethod("Internal:OnPlayerInteriorChange", args); + return 1; +} + +// PAWN native: native CBOnPlayerKeyStateChange(playerid, newkeys, oldkeys); +cell AMX_NATIVE_CALL CBOnPlayerKeyStateChange(AMX *amx, cell *params) { + void *args[3]; + int + playerid = params[1], + newkeys = params[2], + oldkeys = params[3]; + args[0] = &playerid; + args[1] = &newkeys; + args[2] = &oldkeys; + + return g_Mono->callReturn("Internal:OnPlayerKeyStateChange", args); +} + +// PAWN native: native CBOnRconLoginAttempt(ip[], password[], success); +cell AMX_NATIVE_CALL CBOnRconLoginAttempt(AMX *amx, cell *params) { + int success = params[3]; + int len[2] = { 0, 0 }; + cell *addr[2] = { 0, 0 }; + + MonoString *ip, *password; + + amx_GetAddr(amx, params[1], &addr[0]); + amx_GetAddr(amx, params[2], &addr[1]); + + amx_StrLen(addr[0], &len[0]); + amx_StrLen(addr[1], &len[1]); + + if(len[0]) { + char *cip = new char[++len[0]]; + amx_GetString(cip, addr[0], 0, len[0]); + ip = g_Mono->createString(cip); + delete[] cip; + } + + if(len[1]) { + char *cpassword = new char[++len[1]]; + amx_GetString(cpassword, addr[1], 0, len[1]); + password = g_Mono->createString(cpassword); + delete[] cpassword; + } + + void *args[3]; + args[0] = ip; + args[1] = password; + args[2] = &success; + + g_Mono->callMethod("Internal:OnRconLoginAttempt", args); + return 1; +} + +// PAWN native: native CBOnPlayerUpdate(playerid); +cell AMX_NATIVE_CALL CBOnPlayerUpdate(AMX *amx, cell *params) { + void *args[1]; + int playerid = params[1]; + args[0] = &playerid; + + return g_Mono->callReturn("Internal:OnPlayerUpdate", args); +} + +// PAWN native: native CBOnPlayerStreamIn(playerid, forplayerid); +cell AMX_NATIVE_CALL CBOnPlayerStreamIn(AMX *amx, cell *params) { + void *args[2]; + int + playerid = params[1], + forplayerid = params[2]; + args[0] = &playerid; + args[1] = &forplayerid; + + g_Mono->callMethod("Internal:OnPlayerStreamIn", args); + return 1; +} + +// PAWN native: native CBOnPlayerStreamOut(playerid, forplayerid); +cell AMX_NATIVE_CALL CBOnPlayerStreamOut(AMX *amx, cell *params) { + void *args[2]; + int + playerid = params[1], + forplayerid = params[2]; + args[0] = &playerid; + args[1] = &forplayerid; + + g_Mono->callMethod("Internal:OnPlayerStreamOut", args); + return 1; +} + +// PAWN native: native CBOnVehicleStreamIn(vehicleid, forplayerid); +cell AMX_NATIVE_CALL CBOnVehicleStreamIn(AMX *amx, cell *params) { + void *args[2]; + int + vehicleid = params[1], + forplayerid = params[2]; + args[0] = &vehicleid; + args[1] = &forplayerid; + + g_Mono->callMethod("Internal:OnVehicleStreamIn", args); + return 1; +} + +// PAWN native: native CBOnVehicleStreamOut(vehicleid, forplayerid); +cell AMX_NATIVE_CALL CBOnVehicleStreamOut(AMX *amx, cell *params) { + void *args[2]; + int + vehicleid = params[1], + forplayerid = params[2]; + args[0] = &vehicleid; + args[1] = &forplayerid; + + g_Mono->callMethod("Internal:OnVehicleStreamOut", args); + return 1; +} + +// PAWN native: native CBOnDialogResponse(playerid, dialogid, response, listitem, inputtext[]); +cell AMX_NATIVE_CALL CBOnDialogResponse(AMX *amx, cell *params) { + // Create some variables + int len = 0; + cell *addr = 0; + + + // Get address and string length + amx_GetAddr(amx, params[5], &addr); + amx_StrLen(addr, &len); + + + // Create variables to store the arguments + void *args[5]; + int + playerid = params[1], + dialogid = params[2], + response = params[3], + listitem = params[4]; + + // Store the arguments + args[0] = &playerid; + args[1] = &dialogid; + args[2] = &response; + args[3] = &listitem; + args[4] = 0; + + if(len) { + // Create a buffer variable + char *text = new char[++len]; + + // Get the string and store it in the bufer + amx_GetString(text, addr, 0, len); + + // Store the extra argument + args[4] = g_Mono->createString(text); + + // Remove text from memory + delete[] text; + } + + return g_Mono->callReturn("Internal:OnDialogResponse", args); +} + +// PAWN native: native CBOnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid); +cell AMX_NATIVE_CALL CBOnPlayerTakeDamage(AMX *amx, cell *params) { + void *args[4]; + int + playerid = params[1], + issuerid = params[2], + weaponid = params[4]; + float amount = amx_ctof(params[3]); + args[0] = &playerid; + args[1] = &issuerid; + args[2] = &amount; + args[3] = &weaponid; + + g_Mono->callMethod("Internal:OnPlayerTakeDamage", args); + return 1; +} + +// PAWN native: native CBOnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid); +cell AMX_NATIVE_CALL CBOnPlayerGiveDamage(AMX *amx, cell *params) { + void *args[4]; + int + playerid = params[1], + damagedid = params[2], + weaponid = params[4]; + float amount = amx_ctof(params[3]); + args[0] = &playerid; + args[1] = &damagedid; + args[2] = &amount; + args[3] = &weaponid; + + g_Mono->callMethod("Internal:OnPlayerGiveDamage", args); + return 1; +} + +// PAWN native: native CBOnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ); +cell AMX_NATIVE_CALL CBOnPlayerClickMap(AMX *amx, cell *params) { + void *args[4]; + int playerid = params[1]; + float + x = amx_ctof(params[2]), + y = amx_ctof(params[3]), + z = amx_ctof(params[4]); + args[0] = &playerid; + args[1] = &x; + args[2] = &y; + args[3] = &z; + + g_Mono->callMethod("Internal:OnPlayerClickMap", args); + + return 1; +} + +// PAWN native: native CBOnPlayerClickTextDraw(playerid, Text:clickedid); +cell AMX_NATIVE_CALL CBOnPlayerClickTextDraw(AMX *amx, cell *params) { + void *args[2]; + int + playerid = params[1], + clickedid = params[2]; + args[0] = &playerid; + args[1] = &clickedid; + + return g_Mono->callReturn("Internal:OnPlayerClickTextDraw", args); +} + +// PAWN native: native CBOnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid); +cell AMX_NATIVE_CALL CBOnPlayerClickPlayerTextDraw(AMX *amx, cell *params) { + void *args[2]; + int + playerid = params[1], + playertextid = params[2]; + args[0] = &playerid; + args[1] = &playertextid; + + g_Mono->callMethod("Internal:OnPlayerClickPlayerTextDraw", args); + return 1; +} + +// PAWN native: native CBOnPlayerClickPlayer(playerid, clickedplayerid, source); +cell AMX_NATIVE_CALL CBOnPlayerClickPlayer(AMX *amx, cell *params) { + void *args[3]; + int + playerid = params[1], + clickedplayerid = params[2], + source = params[3]; + args[0] = &playerid; + args[1] = &clickedplayerid; + args[2] = &source; + + g_Mono->callMethod("Internal:OnPlayerClickPlayer", args); + return 1; +} + +// PAWN native: native CBOnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ); +cell AMX_NATIVE_CALL CBOnPlayerEditObject(AMX *amx, cell *params) { + void *args[10]; + int + playerid = params[1], + playerobject = params[2], + objectid = params[3], + response = params[4]; + float + fX = amx_ctof(params[5]), + fY = amx_ctof(params[6]), + fZ = amx_ctof(params[7]), + fRotX = amx_ctof(params[8]), + fRotY = amx_ctof(params[9]), + fRotZ = amx_ctof(params[10]); + + args[0] = &playerid; + args[1] = &playerobject; + args[2] = &objectid; + args[3] = &response; + args[4] = &fX; + args[5] = &fY; + args[6] = &fZ; + args[7] = &fRotX; + args[8] = &fRotY; + args[9] = &fRotZ; + + g_Mono->callMethod("Internal:OnPlayerEditObject", args); + return 1; +} + +// PAWN native: native CBOnPlayerEditAttachedObject(playerid, response, index, modelid, boneid,Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,Float:fRotX, Float:fRotY, Float:fRotZ,Float:fScaleX, Float:fScaleY, Float:fScaleZ); +cell AMX_NATIVE_CALL CBOnPlayerEditAttachedObject(AMX *amx, cell *params) { + void *args[14]; + int + playerid = params[1], + response = params[2], + index = params[3], + modelid = params[4], + boneid = params[5]; + float + fOffsetX = amx_ctof(params[6]), + fOffsetY = amx_ctof(params[7]), + fOffsetZ = amx_ctof(params[8]), + fRotX = amx_ctof(params[9]), + fRotY = amx_ctof(params[10]), + fRotZ = amx_ctof(params[11]), + fScaleX = amx_ctof(params[12]), + fScaleY = amx_ctof(params[13]), + fScaleZ = amx_ctof(params[14]); + + args[0] = &playerid; + args[1] = &response; + args[2] = &index; + args[3] = &modelid; + args[4] = &boneid; + args[5] = &fOffsetX; + args[6] = &fOffsetY; + args[7] = &fOffsetZ; + args[8] = &fRotX; + args[9] = &fRotY; + args[10] = &fRotZ; + args[11] = &fScaleX; + args[12] = &fScaleY; + args[13] = &fScaleZ; + + g_Mono->callMethod("Internal:OnPlayerEditAttachedObject", args); + return 1; +} + +// PAWN native: native CBOnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ); +cell AMX_NATIVE_CALL CBOnPlayerSelectObject(AMX *amx, cell *params) { + void *args[7]; + int + playerid = params[1], + type = params[2], + objectid = params[3], + modelid = params[4]; + float + x = amx_ctof(params[5]), + y = amx_ctof(params[6]), + z = amx_ctof(params[7]); + + args[0] = &playerid; + args[1] = &type; + args[2] = &objectid; + args[3] = &modelid; + args[4] = &x; + args[5] = &y; + args[6] = &z; + + g_Mono->callMethod("Internal:OnPlayerSelectObject", args); + return 1; +} diff --git a/sampdotnethook/src/callbacks.h b/sampdotnethook/src/callbacks.h new file mode 100644 index 0000000..dcfa1d5 --- /dev/null +++ b/sampdotnethook/src/callbacks.h @@ -0,0 +1,58 @@ +#ifndef _CALLBACKS_H +#define _CALLBACKS_H + +#include "a_samp.h" + +extern "C" { +cell AMX_NATIVE_CALL CBOnGameModeInit(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnGameModeExit(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerConnect(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerDisconnect(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerSpawn(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerDeath(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnVehicleSpawn(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnVehicleDeath(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerText(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerCommandText(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerRequestClass(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerEnterVehicle(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerExitVehicle(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerStateChange(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerEnterCheckpoint(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerLeaveCheckpoint(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerEnterRaceCheckpoint(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerLeaveRaceCheckpoint(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnRconCommand(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerRequestSpawn(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnObjectMoved(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerObjectMoved(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerPickUpPickup(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnVehicleMod(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnEnterExitModShop(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnVehiclePaintjob(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnVehicleRespray(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnVehicleDamageStatusUpdate(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnUnoccupiedVehicleUpdate(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerSelectedMenuRow(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerExitedMenu(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerInteriorChange(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerKeyStateChange(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnRconLoginAttempt(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerUpdate(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerStreamIn(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerStreamOut(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnVehicleStreamIn(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnVehicleStreamOut(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnDialogResponse(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerTakeDamage(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerGiveDamage(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerClickMap(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerClickTextDraw(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerClickPlayerTextDraw(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerClickPlayer(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerEditObject(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerEditAttachedObject(AMX *amx, cell *params); +cell AMX_NATIVE_CALL CBOnPlayerSelectObject(AMX *amx, cell *params); +} +#endif // _CALLBACKS_H + diff --git a/sampdotnethook/src/common.h b/sampdotnethook/src/common.h new file mode 100644 index 0000000..dde11ed --- /dev/null +++ b/sampdotnethook/src/common.h @@ -0,0 +1,9 @@ +#ifndef COMMON_H +#define COMMON_H + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + #define __win32__ +#endif // WIN32 check + +#endif // COMMON_H + diff --git a/sampdotnethook/src/main.cpp b/sampdotnethook/src/main.cpp new file mode 100644 index 0000000..a8f5206 --- /dev/null +++ b/sampdotnethook/src/main.cpp @@ -0,0 +1,112 @@ +#include "main.h" + +typedef void (*logprintf_t)(char* format, ...); +logprintf_t logprintf; +extern void *pAMXFunctions; + +void _samp_logprintf(char *message) { + logprintf(message); +} + +unsigned int PLUGIN_CALL Supports() { + return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES; +} + +bool PLUGIN_CALL Load(void** ppData) { + // Set variables + pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS]; + logprintf = (logprintf_t) ppData[PLUGIN_DATA_LOGPRINTF]; + + // Instantiate classes + g_Invoke = new Invoke; + g_Mono = new Mono; + + // Initialize the Mono instance and load the Script library + g_Mono->init(); + + // Output status + char msg[50] = ""; + sprintf(msg, " sampdotnethook v%s is OK", __SDNH_VERSION_); + _samp_logprintf(msg); + return true; +} + +void PLUGIN_CALL Unload() { + // Unload the Script library + g_Mono->callMethod("Script:Unload", 0); + + char msg[50] = ""; + sprintf(msg, " sampdotnethook v%s unloaded", __SDNH_VERSION_); + _samp_logprintf(msg); +} + +AMX_NATIVE_INFO PluginNatives[] = { + // Set of callbacks for the PAWN gamemode Script to + { "CBOnGameModeInit", CBOnGameModeInit }, + { "CBOnGameModeExit", CBOnGameModeExit }, + { "CBOnPlayerConnect", CBOnPlayerConnect }, + { "CBOnPlayerDisconnect", CBOnPlayerDisconnect }, + { "CBOnPlayerSpawn", CBOnPlayerSpawn }, + { "CBOnPlayerDeath", CBOnPlayerDeath }, + { "CBOnVehicleSpawn", CBOnVehicleSpawn }, + { "CBOnVehicleDeath", CBOnVehicleDeath }, + { "CBOnPlayerText", CBOnPlayerText }, + { "CBOnPlayerCommandText", CBOnPlayerCommandText }, + { "CBOnPlayerRequestClass", CBOnPlayerRequestClass }, + { "CBOnPlayerEnterVehicle", CBOnPlayerEnterVehicle }, + { "CBOnPlayerExitVehicle", CBOnPlayerExitVehicle }, + { "CBOnPlayerStateChange", CBOnPlayerStateChange }, + { "CBOnPlayerEnterCheckpoint", CBOnPlayerEnterCheckpoint }, + { "CBOnPlayerLeaveCheckpoint", CBOnPlayerLeaveCheckpoint }, + { "CBOnPlayerEnterRaceCheckpoint", CBOnPlayerEnterRaceCheckpoint }, + { "CBOnPlayerLeaveRaceCheckpoint", CBOnPlayerLeaveRaceCheckpoint }, + { "CBOnRconCommand", CBOnRconCommand }, + { "CBOnPlayerRequestSpawn", CBOnPlayerRequestSpawn }, + { "CBOnObjectMoved", CBOnObjectMoved }, + { "CBOnPlayerObjectMoved", CBOnPlayerObjectMoved }, + { "CBOnPlayerPickUpPickup", CBOnPlayerPickUpPickup }, + { "CBOnVehicleMod", CBOnVehicleMod }, + { "CBOnEnterExitModShop", CBOnEnterExitModShop }, + { "CBOnVehiclePaintjob", CBOnVehiclePaintjob }, + { "CBOnVehicleRespray", CBOnVehicleRespray }, + { "CBOnVehicleDamageStatusUpdate", CBOnVehicleDamageStatusUpdate }, + { "CBOnUnoccupiedVehicleUpdate", CBOnUnoccupiedVehicleUpdate }, + { "CBOnPlayerSelectedMenuRow", CBOnPlayerSelectedMenuRow }, + { "CBOnPlayerExitedMenu", CBOnPlayerExitedMenu }, + { "CBOnPlayerInteriorChange", CBOnPlayerInteriorChange }, + { "CBOnPlayerKeyStateChange", CBOnPlayerKeyStateChange }, + { "CBOnRconLoginAttempt", CBOnRconLoginAttempt }, + { "CBOnPlayerUpdate", CBOnPlayerUpdate }, + { "CBOnPlayerStreamIn", CBOnPlayerStreamIn }, + { "CBOnPlayerStreamOut", CBOnPlayerStreamOut }, + { "CBOnVehicleStreamIn", CBOnVehicleStreamIn }, + { "CBOnVehicleStreamOut", CBOnVehicleStreamOut }, + { "CBOnDialogResponse", CBOnDialogResponse }, + { "CBOnPlayerTakeDamage", CBOnPlayerTakeDamage }, + { "CBOnPlayerGiveDamage", CBOnPlayerGiveDamage }, + { "CBOnPlayerClickMap", CBOnPlayerClickMap }, + { "CBOnPlayerClickTextDraw", CBOnPlayerClickTextDraw }, + { "CBOnPlayerClickPlayerTextDraw", CBOnPlayerClickPlayerTextDraw }, + { "CBOnPlayerClickPlayer", CBOnPlayerClickPlayer }, + { "CBOnPlayerEditObject", CBOnPlayerEditObject }, + { "CBOnPlayerEditAttachedObject", CBOnPlayerEditAttachedObject }, + { "CBOnPlayerSelectObject", CBOnPlayerSelectObject }, + + { 0, 0 } +}; + +int PLUGIN_CALL AmxLoad(AMX* amx) { + g_Invoke->amx_list.push_back(amx); + g_Invoke->getAddresses(); + return amx_Register(amx, PluginNatives, -1); +} + +int PLUGIN_CALL AmxUnload(AMX* amx) { + for(std::list::iterator i = g_Invoke->amx_list.begin(); i != g_Invoke->amx_list.end(); ) { + if(*i == amx) { + g_Invoke->amx_list.erase(i); + break; + } + } + return AMX_ERR_NONE; +} diff --git a/sampdotnethook/src/main.h b/sampdotnethook/src/main.h new file mode 100644 index 0000000..f6b1c49 --- /dev/null +++ b/sampdotnethook/src/main.h @@ -0,0 +1,19 @@ +#ifndef _MAIN_H +#define _MAIN_H + +#include "callbacks.h" +#include "a_samp.h" +#include "Mono.h" +#include "add.h" + +#define __SDNH_VERSION_ ("0.6-dev") + +PLUGIN_EXPORT void _samp_logprintf(char *message); +PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports(); +PLUGIN_EXPORT bool PLUGIN_CALL Load(void** ppData); +PLUGIN_EXPORT void PLUGIN_CALL Unload(); +PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX* amx); +PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX* amx); + +#endif // _MAIN_H +