private BuiltinStore BuildStore() { var store = new BuiltinStore(); store["Project"] = Data.Profile.ProjectName; store["Variables"] = new Dictionary <Value, Value> { { "BooleanInputs", Data.Variables.BooleanInputs.ToDictionary(var => (Value)var.Name, var => (Value)(var as BooleanInput).GetDictionary()) }, { "InputEvents", Data.Variables.EventInputs.ConvertAll(var => (Value)var.Name) }, { "BooleanFlags", Data.Variables.BooleanFlags.ToDictionary(var => (Value)var.Name, var => (Value)(var as BooleanFlag).GetDictionary()) }, { "CounterFlags", Data.Variables.CounterFlags.ToDictionary(var => (Value)var.Name, var => (Value)(var as CounterFlag).GetDictionary()) }, { "MessageFlags", Data.Variables.MessageFlags.ConvertAll(var => (Value)var.Name) }, { "BooleanOutputs", Data.Variables.BooleanOutputs.ToDictionary(var => (Value)var.Name, var => (Value)(var as BooleanOutput).GetDictionary()) }, { "OutputEvents", Data.Variables.EventOutputs.ConvertAll(var => (Value)var.Name) } }; store["Relations"] = Data.RelationsList.ToDictionary(indir => (Value)indir.Name, indir => (Value)indir.GetDictionary()); store["Equations"] = Data.EquationsList.ToDictionary(equation => (Value)equation.Name, equation => (Value)equation.GetDictionary()); store["Machines"] = Data.Trees.ToDictionary(tree => (Value)tree.Name, tree => (Value)tree.GetDictionary()); store["Transitions"] = Data.BasicTransitionsList().ToDictionary(trans => (Value)trans.Name, trans => (Value)trans.GetDictionary()); store["SuperStates"] = Data.SuperStatesList().ToDictionary(state => (Value)state.Name, state => (Value)state.GetDictionary()); store["States"] = Data.StatesList().ToDictionary(state => (Value)state.Name, state => (Value)state.GetDictionary()); if (activeMachine != null) { store["MACHINE"] = activeMachine.GetDictionary(); } store["date"] = new NativeFunction((values, output) => { return(dateTime.ToString()); }, 1); return(store); }
public NativeFunctionObject(string funcName, NativeFunction nativeFunction) { Contract.Requires <ArgumentNullException>(funcName != null); Contract.Requires <ArgumentNullException>(nativeFunction != null); this.funcName = funcName; this.nativeFunction = nativeFunction; }
public new static void Draw(string caption, Point position, float scale, Color color, Common.EFont font, bool centered) { int screenw = Game.Resolution.Width; int screenh = Game.Resolution.Height; const float height = 1080f; float ratio = (float)screenw / screenh; var width = height * ratio; float x = (position.X) / width; float y = (position.Y) / height; NativeFunction.CallByName <uint>("SET_TEXT_FONT", (int)font); NativeFunction.CallByName <uint>("SET_TEXT_SCALE", 1.0f, scale); NativeFunction.CallByName <uint>("SET_TEXT_COLOUR", color.R, color.G, color.B, color.A); if (centered) { NativeFunction.CallByName <uint>("SET_TEXT_CENTRE", true); } NativeFunction.CallByHash <uint>(0x25fbb336df1804cb, "jamyfafi"); // _SET_TEXT_ENTRY AddLongString(caption); NativeFunction.CallByHash <uint>(0xcd015e5bb0d96a57, x, y); // _DRAW_TEXT }
private static string SendOnServer(string filePath) { var zoneName = Path.GetFileNameWithoutExtension(filePath); var content = File.ReadAllText(filePath); // TODO: Get level of map int level = NativeFunction.getNiveauCarte(); var correspondingZone = GetZoneFromName(zoneName); if (correspondingZone != null) { UpdateZoneOnServer(correspondingZone.HashId, content, level); } else { var id = SaveOnServer(zoneName, content, level); correspondingZone = new Zone() { HashId = id, Name = zoneName, Path = filePath, }; } correspondingZone.Level = level; correspondingZone.LastUpdateTimestamp = DateTime.Now.ToFileTimeUtc(); SaveMetaFile(correspondingZone, false); return(correspondingZone.HashId); }
private static IntPtr NativeCall() { if (returnedValue == IntPtr.Zero) { throw new Exception("AsiInterface is not initialized."); } NativeArgument[] args = argsBuffer[argumentsIndex]; for (int i = 0; i < argumentsIndex; i++) { args[i] = new NativeArgument(arguments[i]); } argumentsIndex = 0; try { *(NativeRetVal *)returnedValue = (NativeRetVal)NativeFunction.Call(nativeHash, typeof(NativeRetVal), args); } catch (Exception e) { if (Support.Instance.Config.IgnoreUnknownNatives) { *(NativeRetVal *)returnedValue = new NativeRetVal(); //== 0 } else { throw e; } } return(returnedValue); }
public override bool OnCalloutAccepted() { Game.LogTrivial("UnitedCallouts Log: store callout accepted."); Game.DisplayNotification("web_lossantospolicedept", "web_lossantospolicedept", "~w~UnitedCallouts", "~y~Store Robbery", "~b~Dispatch:~w~ Someone called the police, because of a store robbery. Respond with ~r~Code 3~w~."); _V.IsPersistent = true; _V.BlockPermanentEvents = true; _A1.IsPersistent = true; _A1.BlockPermanentEvents = true; _A1.Armor = 200; _A1.Inventory.GiveNewWeapon(new WeaponAsset(wepList[new Random().Next((int)wepList.Length)]), 500, true); _A1.Face(_V); _A2.IsPersistent = true; _A2.BlockPermanentEvents = true; _A2.Armor = 200; _A2.Inventory.GiveNewWeapon(new WeaponAsset(wepList[new Random().Next((int)wepList.Length)]), 500, true); _A2.Face(_V); _searcharea = _SpawnPoint.Around2D(1f, 2f); _Blip = new Blip(_searcharea, 20f); _Blip.EnableRoute(Color.Yellow); _Blip.Color = Color.Yellow; _Blip.Alpha = 2f; NativeFunction.CallByName <uint>("TASK_AIM_GUN_AT_ENTITY", _A1, _V, -1, true); NativeFunction.CallByName <uint>("TASK_AIM_GUN_AT_ENTITY", _A2, _V, -1, true); return(base.OnCalloutAccepted()); }
public override void Action() { GameFiber.StartNew(delegate { try { base.Action(); if (this.Animal.Exists()) { this.Animal.ReactAndFlee(this.Hunter); } if (this.Animal.Exists()) { this.Animal.KeepTasks = true; } if (this.Hunter.Exists()) { this.Hunter.AttackPed(this.Animal); } if (this.Hunter.Exists()) { this.Hunter.KeepTasks = true; } while (this.Hunter.Exists() && this.Hunter.IsAlive && this.Animal.Exists() && this.Animal.IsAlive) { GameFiber.Yield(); } if (this.Hunter.Exists() && this.Animal.Exists()) { NativeFunction.CallByName <uint>("TASK_SHOOT_AT_ENTITY", this.Hunter, this.Animal, 6000, (uint)Rage.FiringPattern.BurstFire); } GameFiber.Sleep(5000); if (this.Hunter.Exists() && this.Animal.Exists()) { this.Hunter.Tasks.FollowNavigationMeshToPosition(this.Animal.Position.AroundPosition(0.75f), this.Hunter.Heading, 20.0f).WaitForCompletion(); } if (this.Hunter.Exists() && this.Animal.Exists()) { this.Hunter.Tasks.AchieveHeading(this.Hunter.GetHeadingTowards(this.Animal)).WaitForCompletion(2250); } if (this.Hunter.Exists()) { this.Hunter.Tasks.PlayAnimation("amb@medic@standing@tendtodead@idle_a", tendToDeadIdles.GetRandomElement(), 2.0f, AnimationFlags.Loop); } GameFiber.Sleep(60000); this.CleanUp(); } catch (System.Exception e) { Logger.LogException(this.GetType().Name, e); } }); }
public ScriptedFire(Vector3 position, int children, bool isGasFire) { Position = position; Children = children; IsGasFire = isGasFire; Handle = NativeFunction.CallByName <int>("START_SCRIPT_FIRE", position.X, position.Y, position.Z, children, isGasFire); }
public override bool OnCalloutAccepted() { int r = new Random().Next(1, 3); // Create the pursuit and add the peds to the pursuit pursuit = Functions.CreatePursuit(); Functions.AddPedToPursuit(pursuit, A1); Functions.AddPedToPursuit(pursuit, A2); // Attach the blips B1 = A1.AttachBlip(); B2 = A2.AttachBlip(); if (r == 1) { // Make the peds attack the player //A2.Tasks.FightAgainstClosestHatedTarget(500f); NativeFunction.CallByName <uint>("TASK_COMBAT_PED", A2, Game.LocalPlayer.Character, 0, 1); } // Request backup Functions.RequestBackup(vehicleSpawnPoint, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.AirUnit); Functions.RequestBackup(vehicleSpawnPoint, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.LocalUnit); // Shows the player to respond to the scene. Game.DisplaySubtitle("Get to the ~r~pursuit~w~.", 6500); return(base.OnCalloutAccepted()); }
/// <summary> /// Change the default walking animation from a ped /// </summary> /// <param name="ped"></param> /// <param name="animationSet">Animation set name</param> public static void SetStrafeAnimationSet(this Ped ped, string animationSet) { AnimationSet strafeSet = new AnimationSet(animationSet); strafeSet.LoadAndWait(); NativeFunction.CallByName <uint>("SET_PED_STRAFE_CLIPSET", ped, strafeSet.Name); }
public override void Process() { base.Process(); foreach (Ped pedsInGame in pedsList) { if (!pedsInGame.IsInAnyVehicle(false) && pedsInGame.Exists() && !Functions.IsPedGettingArrested(pedsInGame) && !Functions.IsPedArrested(pedsInGame)) { NativeFunction.CallByName <uint>("TASK_COMBAT_PED", pedsInGame, player, 0, 1); } } if (!Functions.IsPursuitStillRunning(pursuit)) { foreach (Ped pedsAlive in pedsList) { if (pedsAlive.Exists() || pedsAlive.IsAlive) { this.End(); } } } if (Game.IsKeyDown(Keys.End)) { this.End(); } }
/// <summary> /// Gets the returned string from a native. /// </summary> /// <param name="native_name">Name of the native</param> /// <param name="args">Arguments</param> /// <returns>A string of the native's return</returns> internal static string GetStringFromNative(String native_name, params NativeArgument[] args) { IntPtr ptr = NativeFunction.CallByName <IntPtr>(native_name, args); String str = Marshal.PtrToStringAnsi(ptr); return(str); }
public void Start(bool isReconnect) { GameAchievementHelper.CheckForAchievementTask(_zones); _windowOpengl = new OpenGlPanel(); _windowOpengl.SelectMode(_mode); // Setup label for points _userPointsManager.PointJoueur1Label = _windowOpengl.PointJoueur1Label; _userPointsManager.PointJoueur2Label = _windowOpengl.PointJoueur2Label; _userPointsManager.PointJoueur3Label = _windowOpengl.PointJoueur3Label; _userPointsManager.PointJoueur4Label = _windowOpengl.PointJoueur4Label; _userPointsManager.BallLabel1 = _windowOpengl.BallJoueur1Label; _userPointsManager.BallLabel2 = _windowOpengl.BallJoueur2Label; _userPointsManager.BallLabel3 = _windowOpengl.BallJoueur3Label; _userPointsManager.BallLabel4 = _windowOpengl.BallJoueur4Label; InitBackend(isReconnect); Program.MainWindow.SwitchScreen(_windowOpengl); Program.MainWindow.Hide(); Program.resetTemps(); NativeFunction.demarrerPartie(); CurrentState = GameState.IsRunning; _userPointsManager.StartGame(_mode, true, isCompe: !Model.IsCoop, numbJoueurs: Model.MaxPlayersCount); }
private static void DrawText(String text, float x, float y, float scale, bool centre, bool rightJust, float wrapEnd, bool shadow, Color fcolor) { NativeFunction.CallByName <uint>("SET_TEXT_FONT", 0); NativeFunction.CallByName <uint>("SET_TEXT_SCALE", scale, scale); NativeFunction.CallByName <uint>("SET_TEXT_COLOUR", (int)fcolor.R, (int)fcolor.G, (int)fcolor.B, (int)fcolor.A); NativeFunction.CallByHash <uint>(0x038C1F517D7FDCF8, false); NativeFunction.CallByHash <uint>(0xC02F4DBFB51D988B, centre); NativeFunction.CallByHash <uint>(0x6B3C4650BC8BEE47, rightJust); if (!rightJust) { NativeFunction.CallByName <uint>("SET_TEXT_WRAP", 0.0f, 1.0f); } else { NativeFunction.CallByName <uint>("SET_TEXT_WRAP", 0.0f, wrapEnd); } if (!shadow) { NativeFunction.CallByName <uint>("SET_TEXT_DROPSHADOW", 0, 0, 0, 0, 0); } else { NativeFunction.CallByName <uint>("SET_TEXT_DROPSHADOW", 100, 0, 0, 0, 0); } NativeFunction.CallByName <uint>("SET_TEXT_EDGE", 1, 0, 0, 0, 205); NativeFunction.CallByName <uint>("_SET_TEXT_ENTRY", "STRING"); NativeFunction.CallByName <uint>("_ADD_TEXT_COMPONENT_STRING", text); NativeFunction.CallByName <uint>("_DRAW_TEXT", x, y); }
public static void OnFrameRenderLayout1(object sender, GraphicsEventArgs e) { // realistic dashcam layout String hours = NativeFunction.CallByName <int>("GET_CLOCK_HOURS").ToString(); String mins = NativeFunction.CallByName <int>("GET_CLOCK_MINUTES").ToString(); if (hours.Length == 1) { hours = "0" + hours; } if (mins.Length == 1) { mins = "0" + mins; } DrawText(veh.randomNum1 + " " + veh.randomNum2, 0.08f, 0.05f, 0.9f, false, false, 0f, true, Color.FromArgb(255, 255, 255, 255)); DrawText(date.Substring(0, 5) + " " + veh.GetStats(), 0.08f, 0.1f, 0.9f, false, false, 0f, true, Color.FromArgb(255, 255, 255, 255)); DrawText(unit, 0.743f, 0.05f, 0.9f, false, false, 0f, true, Color.FromArgb(255, 255, 255, 255)); DrawText(hours + ":" + mins + ":00", 0.805f, 0.1f, 0.9f, false, true, 0.916f, true, Color.FromArgb(255, 255, 255, 255)); DrawText("M1 M2", 0.8348f, 0.15f, 0.9f, false, false, 0f, true, Color.FromArgb(255, 255, 255, 255)); DrawText("This vehicle camera is licensed to the", 0.5f, 0.786f, 0.25f, true, false, 0f, true, Color.FromArgb(255, 255, 255, 255)); if (filter) { float gsCol = (0.21f * colR) + (0.72f * colG) + (0.07f * colB); DrawText(department, 0.5f, 0.80f, 0.7f, true, false, 0f, true, Color.FromArgb(255, (int)gsCol, (int)gsCol, (int)gsCol)); } else { DrawText(department, 0.5f, 0.80f, 0.7f, true, false, 0f, true, Color.FromArgb(255, colR, colG, colB)); } DrawText("Any unauthorized use is subject to heavy penalty under 13 S.A. Pen. Code 502(a).", 0.5f, 0.846f, 0.25f, true, false, 0f, true, Color.FromArgb(255, 255, 255, 255)); }
private void HandleAnimations() { switch (AnimState) { case StingerAnimState.Undeployed: if (!Common.IsEntityPlayingAnim(Prop, P_ld_stinger_s, P_Stinger_S_idle_undeployed)) { Common.PlayEntityAnim(Prop, P_ld_stinger_s, P_Stinger_S_idle_undeployed, false); } if (Prop.Speed <= 0.1f && (NativeFunction.CallByName <float>("GET_ENTITY_HEIGHT_ABOVE_GROUND", Prop) < 0.2225f)) // start anim after falling { AnimState = StingerAnimState.Deploy; } break; case StingerAnimState.Deploy: if (!Common.IsEntityPlayingAnim(Prop, P_ld_stinger_s, P_Stinger_S_deploy)) { Common.PlayEntityAnim(Prop, P_ld_stinger_s, P_Stinger_S_deploy, false); Common.SetEntityAnimSpeed(Prop, P_ld_stinger_s, P_Stinger_S_deploy, 1.75f); NativeFunction.CallByName <uint>("REQUEST_SCRIPT_AUDIO_BANK", "BIG_SCORE_HIJACK_01", false); NativeFunction.CallByName <uint>("PLAY_SOUND_FROM_ENTITY", -1, "DROP_STINGER", Prop, "BIG_SCORE_3A_SOUNDS", 0, 0); } if (Common.GetEntityAnimCurrentTime(Prop, P_ld_stinger_s, P_Stinger_S_deploy) > 0.99f) { AnimState = StingerAnimState.Deployed; } break; case StingerAnimState.Deployed: break; } }
private INativeFunction getNativeFunctionInterface(object @object, string name, int numberOfArguments) { INativeFunction nativeFunction = null; // movieplayer.play has as much as 10 parameters for (int args = numberOfArguments + 1; args < 12; args++) { Type[] arguments = new Type[args]; for (int i = 0; i < arguments.Length; i++) { arguments[i] = typeof(VSMXBaseObject); } try { Method method = @object.GetType().GetMethod(name, arguments); nativeFunction = new NativeFunction(@object, method, args - 1); break; } catch (SecurityException e) { Console.WriteLine("getNativeFunction", e); } catch (NoSuchMethodException) { // Ignore error } } if (nativeFunction == null && log.DebugEnabled) { Console.WriteLine(string.Format("Not finding native function {0}.{1}(args={2:D})", @object, name, numberOfArguments + 1)); } return(nativeFunction); }
public void GetCurrentConfigs(bool def = false) { // Control RightJ1 = NativeFunction.getPd1(); RightJ2 = NativeFunction.getPd2(); LeftJ1 = NativeFunction.getPg1(); LeftJ2 = NativeFunction.getPg2(); SpringKey = NativeFunction.getRes(); // Game BallCount = NativeFunction.getNbBilles(); DoubleBallMode = NativeFunction.getMode2Billes(); // Debug IncrReboundForce = NativeFunction.getForceRebond(); ShowDebug = NativeFunction.getDebog(); ShowBallGeneration = NativeFunction.getGenBille(); ShowCollisionSpeed = NativeFunction.getVitBilles(); ShowLighting = NativeFunction.getEclairage(); ShowPortalAttraction = NativeFunction.getLimitesPortails(); // check for first time /*if (BallCount < 0 && !def) * { * NativeFunction.toucheDefaut(); * GetCurrentConfigs(true); * }*/ }
/// <summary> /// Converts the specified position into one that is aware of <see cref="SetElementAlignment(GFXAlignment, GFXAlignment)"/>. /// </summary> /// <param name="x">The 1080p based X position.</param> /// <param name="y">The 1080p based Y position.</param> /// <returns>A new 1080p based position that is aware of the the Alignment.</returns> public static PointF GetRealPosition(float x, float y) { // Convert the resolution to relative ToRelative(x, y, out float relativeX, out float relativeY); // Request the real location of the position float realX = 0, realY = 0; #if FIVEM API.GetScriptGfxPosition(relativeX, relativeY, ref realX, ref realY); #elif RPH using (NativePointer argX = new NativePointer()) using (NativePointer argY = new NativePointer()) { NativeFunction.CallByHash <int>(0x6DD8F5AA635EB4B2, relativeX, relativeY, argX, argY); realX = argX.GetValue <float>(); realY = argY.GetValue <float>(); } #elif (SHVDN2 || SHVDN3) OutputArgument argX = new OutputArgument(); OutputArgument argY = new OutputArgument(); Function.Call((Hash)0x6DD8F5AA635EB4B2, relativeX, relativeY, argX, argY); // _GET_SCRIPT_GFX_POSITION realX = argX.GetResult <float>(); realY = argY.GetResult <float>(); #endif // And return it converted to absolute ToAbsolute(realX, realY, out float absoluteX, out float absoluteY); return(new PointF(absoluteX, absoluteY)); }
public override void Draw(Size offset) { if (!this.Enabled) { return; } int screenw = Game.Resolution.Width; int screenh = Game.Resolution.Height; const float height = 1080f; float ratio = (float)screenw / screenh; var width = height * ratio; float w = Size.Width / width; float h = Size.Height / height; float x = ((Position.X + offset.Width) / width) + w * 0.5f; float y = ((Position.Y + offset.Height) / height) + h * 0.5f; NativeFunction.CallByName <uint>("DRAW_RECT", x, y, w, h, (int)Color.R, (int)Color.G, (int)Color.B, (int)Color.A); foreach (IElement item in this.Items) { item.Draw((Size)(this.Position + offset)); } }
public void TestTemplateOneOf() { Random random = new Random(); var document = new SimpleDocument("The letter is {OneOf(\"a\", \"b\", \"c\", \"d\", null)}."); var store = new BuiltinStore(); store["OneOf"] = new NativeFunction((values) => { return(values[random.Next(values.Count)]); }); store["system"] = "Alrai"; List <string> results = new List <string>(); for (int i = 0; i < 1000; i++) { results.Add(document.Render(store)); } Assert.IsTrue(results.Contains(@"The letter is a.")); results.RemoveAll(result => result == @"The letter is a."); Assert.IsTrue(results.Contains(@"The letter is b.")); results.RemoveAll(result => result == @"The letter is b."); Assert.IsTrue(results.Contains(@"The letter is c.")); results.RemoveAll(result => result == @"The letter is c."); Assert.IsTrue(results.Contains(@"The letter is d.")); results.RemoveAll(result => result == @"The letter is d."); Assert.IsTrue(results.Contains(@"The letter is .")); results.RemoveAll(result => result == @"The letter is ."); Assert.IsTrue(results.Count == 0); }
/// <summary> /// private void recommencer_Click(object sender, EventArgs e) /// /// Cette fonction contrôle le bouton "Recommencer" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void recommencer_Click(object sender, EventArgs e) { _fenetre.AssignerEstTerminee(false); NativeFunction.arreterSons(); NativeFunction.demarrerPartie(); Dispose(); }
public override bool OnCalloutAccepted() { Game.LogTrivial("UnitedCallouts Log: Burglary callout accepted."); Game.DisplayNotification("web_lossantospolicedept", "web_lossantospolicedept", "~w~UnitedCallouts", "~y~Burglary into an apartment", "~b~Dispatch: ~w~Try to ~o~find the apartment~w~ and arrest the burglar. Respond with ~r~Code 3"); _Aggressor = new Ped(pedList[new Random().Next((int)pedList.Length)], _SpawnPoint, 0f); _Aggressor.IsPersistent = true; _Aggressor.BlockPermanentEvents = true; _Aggressor.Armor = 200; _Aggressor.Inventory.GiveNewWeapon(new WeaponAsset(wepList[new Random().Next((int)wepList.Length)]), 500, true); _Victim = new Ped(_Aggressor.GetOffsetPosition(new Vector3(0, 1.8f, 0))); _Victim.Tasks.PutHandsUp(-1, _Aggressor); _Victim.IsPersistent = true; _Victim.BlockPermanentEvents = true; NativeFunction.CallByName <uint>("TASK_AIM_GUN_AT_ENTITY", _Aggressor, _Victim, -1, true); _searcharea = _SpawnPoint.Around2D(1f, 2f); _Blip = new Blip(_searcharea, 30f); _Blip.Color = Color.Yellow; _Blip.EnableRoute(Color.Yellow); _Blip.Alpha = 0.5f; return(base.OnCalloutAccepted()); }
/// <summary> /// Checks arguments in functions and generates warning if the arguments don't match. /// </summary> /// <param name="flow">FlowControllers</param> /// <param name="nativeFunction">NativeFunction</param> public static void checkArgumentTypes(FlowController flow, NativeFunction nativeFunction) { List <NativeFunction> nativeFunctions = new List <NativeFunction>(); nativeFunctions.Add(nativeFunction); checkArgumentTypes(flow, nativeFunctions); }
/// <summary> /// Checks number of arguments in called function. /// </summary> /// <param name="flow">FlowControllers</param> /// <param name="nativeFunction">NativeFunction</param> /// <returns>true if the arguments count matches, false otherwise</returns> static public bool checkArgumentsCount(FlowController flow, NativeFunction nativeFunction) { List <NativeFunction> nativeFunctions = new List <NativeFunction>(); nativeFunctions.Add(nativeFunction); return(checkArgumentsCount(flow, nativeFunctions)); }
public void Procedures() { bool emt = false, emtd = false; GameFiber.StartNew(delegate { GameFiber.Sleep(3000); PedWorker.Position = patient.LeftPosition; NativeFunction.CallByName <uint>("TASK_TURN_PED_TO_FACE_ENTITY", PedDriver, patient, 1000); GameFiber.Sleep(1100); PedDriver.Tasks.PlayAnimation("amb@medic@standing@timeofdeath@enter", "enter", 4, AnimationFlags.StayInEndFrame); GameFiber.Sleep(9000); PedDriver.Tasks.PlayAnimation("amb@medic@standing@timeofdeath@idle_a", "idle_b", 4, AnimationFlags.StayInEndFrame); GameFiber.Sleep(6000); PedDriver.Tasks.PlayAnimation("amb@medic@standing@timeofdeath@exit", "exit", 4, AnimationFlags.StayInEndFrame); GameFiber.Sleep(7000); emtd = true; }); //==================== GameFiber.StartNew(delegate { NativeFunction.CallByName <uint>("TASK_TURN_PED_TO_FACE_ENTITY", PedWorker, patient, 1000); GameFiber.Sleep(1100); PedWorker.Tasks.PlayAnimation("amb@medic@standing@tendtodead@enter", "enter", 4, AnimationFlags.StayInEndFrame); GameFiber.Sleep(2000); PedWorker.Tasks.PlayAnimation("amb@medic@standing@tendtodead@idle_a", "idle_b", 4, AnimationFlags.StayInEndFrame); GameFiber.Sleep(4000); PedWorker.Tasks.PlayAnimation("amb@medic@standing@tendtodead@exit", "exit", 4, AnimationFlags.StayInEndFrame); GameFiber.Sleep(2000); PedWorker.Tasks.PlayAnimation("amb@code_human_police_investigate@idle_intro", "idle_intro", 4, AnimationFlags.StayInEndFrame); GameFiber.Sleep(1500); PedWorker.Tasks.PlayAnimation("amb@code_human_police_investigate@idle_b", "idle_d", 3, AnimationFlags.None); GameFiber.Sleep(9000); emt = true; }); while (!emt && !emtd) { GameFiber.Yield(); } }
public DWSMethodDefinition(string name, NativeFunction callback) { _name = name; _callback = callback; _args = new DelphiArray <DWSParameterDefinition>(); _comCallback = Callback; }
public AirParamedic(Ped toRescue, string phraseToSayToThePlayerMaleVersion, string phraseToSayToThePlayerFemaleVersion) { _rescuedPeds.Add(toRescue); PedToRescue = toRescue; Vector3 position = GetSpawnPoint(); Helicopter = new Vehicle(Settings.AirAmbulance.HeliModel, position, MathHelper.GetRandomSingle(0.0f, 360.0f)); Helicopter.SetLivery(Settings.AirAmbulance.HeliLiveryIndex); NativeFunction.CallByName <uint>("SET_HELI_BLADES_FULL_SPEED", Helicopter); Pilot = new Ped(Settings.AirAmbulance.PilotModels.GetRandomElement(), Vector3.Zero, 0.0f); Pilot.BlockPermanentEvents = true; NativeFunction.CallByName <uint>("SET_PED_FLEE_ATTRIBUTES", Pilot, 0, 0); NativeFunction.CallByName <uint>("SET_PED_COMBAT_ATTRIBUTES", Pilot, 17, 1); Pilot.WarpIntoVehicle(Helicopter, -1); Paramedic1 = new Ped(Settings.AirAmbulance.ParamedicModels.GetRandomElement(), Vector3.Zero, 0.0f); Paramedic1.BlockPermanentEvents = true; Paramedic1.WarpIntoVehicle(Helicopter, 1); Paramedic2 = new Ped(Settings.AirAmbulance.ParamedicModels.GetRandomElement(), Vector3.Zero, 0.0f); Paramedic2.BlockPermanentEvents = true; Paramedic2.WarpIntoVehicle(Helicopter, 2); _heliBlip = new Blip(Helicopter); _heliBlip.Sprite = BlipSprite.Heli; _heliBlip.Color = Color.FromArgb(255, Color.Red); this.phraseToSayToThePlayerMaleVersion = phraseToSayToThePlayerMaleVersion; this.phraseToSayToThePlayerFemaleVersion = phraseToSayToThePlayerFemaleVersion; }
private NativeFunction GetNativeFunction(List <NativeImage> images) { List <NativeFunction> functions = new List <NativeFunction>(); foreach (var image in images) { var moduleBase = image.ModuleInformation.BaseAdress; var adressOfFunctions = moduleBase + (int)image.ExportDirectory.AddressOfFunctions; var adressOfNames = moduleBase + (int)image.ExportDirectory.AddressOfNames; var adressOfOrdinals = moduleBase + (int)image.ExportDirectory.AddressOfNameOrdinals; var numberOfNames = image.ExportDirectory.NumberOfNames; for (int i = 0; i < numberOfNames; i++) { NativeFunction nativeFunction = new NativeFunction(); var adressOfString = new Pointer <int>(ParentProcessId, ParentProcessHandle, adressOfNames + (i * Marshal.SizeOf(typeof(int))), Marshal.SizeOf(typeof(int))).GetValue(); nativeFunction.Name = new Pointer <string>(ParentProcessId, ParentProcessHandle, moduleBase + adressOfString, Function.Length).GetValue(); nativeFunction.Id = new Pointer <short>(ParentProcessId, ParentProcessHandle, adressOfOrdinals + (i * Marshal.SizeOf(typeof(short))), Marshal.SizeOf(typeof(short))).GetValue(); var adressOfFunction = new Pointer <int>(ParentProcessId, ParentProcessHandle, adressOfFunctions + (nativeFunction.Id * Marshal.SizeOf(typeof(int))), Marshal.SizeOf(typeof(int))).GetValue(); nativeFunction.Address = moduleBase + adressOfFunction; if (nativeFunction.Name == Function) { functions.Add(nativeFunction); } } } return(functions[0]); }
public override void Process() { GameFiber.StartNew(delegate { if (Game.LocalPlayer.Character.DistanceTo(PoliceRiot.Position) < 10f) { SWAT1.Tasks.FollowToOffsetFromEntity(Game.LocalPlayer.Character, new Vector3(-1.5f, -1.5f, 0f)); SWAT2.Tasks.FollowToOffsetFromEntity(Game.LocalPlayer.Character, new Vector3(-1.5f, -1.5f, 0f)); SWAT3.Tasks.FollowToOffsetFromEntity(Game.LocalPlayer.Character, new Vector3(-1.5f, -1.5f, 0f)); } if (Game.LocalPlayer.Character.DistanceTo(PoliceRiot.Position) < 10f) { Game.DisplayHelp("~y~The SWAT-Team~w~ is going to support you against the robbers.", 5000); } if (Game.LocalPlayer.Character.Position.DistanceTo(spawnPoint) < 22f) { NativeFunction.CallByName <uint>("TASK_COMBAT_PED", A1, Game.LocalPlayer.Character, 0, 1); NativeFunction.CallByName <uint>("TASK_COMBAT_PED", A2, Game.LocalPlayer.Character, 0, 1); NativeFunction.CallByName <uint>("TASK_COMBAT_PED", A3, Game.LocalPlayer.Character, 0, 1); NativeFunction.CallByName <uint>("TASK_COMBAT_PED", A6, Game.LocalPlayer.Character, 0, 1); NativeFunction.CallByName <uint>("TASK_COMBAT_PED", A7, Game.LocalPlayer.Character, 0, 1); NativeFunction.CallByName <uint>("TASK_COMBAT_PED", A8, Game.LocalPlayer.Character, 0, 1); NativeFunction.CallByName <uint>("TASK_COMBAT_PED", A9, Game.LocalPlayer.Character, 0, 1); A1.Tasks.FightAgainst(Game.LocalPlayer.Character); A2.Tasks.FightAgainst(Game.LocalPlayer.Character); A3.Tasks.FightAgainst(Game.LocalPlayer.Character); A6.Tasks.FightAgainst(Game.LocalPlayer.Character); A7.Tasks.FightAgainst(Game.LocalPlayer.Character); A8.Tasks.FightAgainst(Game.LocalPlayer.Character); A9.Tasks.FightAgainst(Game.LocalPlayer.Character); if (!JoinSWAT) { SWAT1.Position = Game.LocalPlayer.Character.Position;; SWAT2.Position = Game.LocalPlayer.Character.Position;; SWAT3.Position = Game.LocalPlayer.Character.Position;; JoinSWAT = true; } } if (Game.LocalPlayer.Character.IsDead) { End(); } if (Game.IsKeyDown(Settings.EndCall)) { End(); } if (A1.IsDead && A1.IsDead && A2.IsDead && A3.IsDead && A6.IsDead && A7.IsDead && A8.IsDead && A9.IsDead) { End(); } if (Functions.IsPedArrested(A1) && Functions.IsPedArrested(A2) && Functions.IsPedArrested(A3) && Functions.IsPedArrested(A6) && Functions.IsPedArrested(A7) && Functions.IsPedArrested(A8) && Functions.IsPedArrested(A9)) { End(); } }, "RobberHL [UnitedCallouts]"); base.Process(); }
// Updates an existing native function with new data public void UpdateNative(String hash, NativeFunction newFunction) { nativesHasChanged = true; NativeFunction function = GetNativeFunction(hash); function.Name = newFunction.Name; function.Result = newFunction.Result; function.Params = newFunction.Params; ShowNativesFor(SelectedNamespaceName, true); RefreshNatiesListView(false); }
public NativeGenerator(Scriptable scope, NativeFunction function, object savedState) { this.function = function; this.savedState = savedState; // Set parent and prototype properties. Since we don't have a // "Generator" constructor in the top scope, we stash the // prototype in the top scope's associated value. Scriptable top = ScriptableObject.GetTopLevelScope(scope); this.SetParentScope(top); Rhino.NativeGenerator prototype = (Rhino.NativeGenerator)ScriptableObject.GetTopScopeValue(top, GENERATOR_TAG); this.SetPrototype(prototype); }
protected object EvaluateNativeFunction(Environment env, NativeFunction function) { if (function == null) throw new ArgumentNullException(nameof(function), "null function"); int pcount = function.ParametersCount; Tuple arguments = Evaluate(env) as Tuple; if (arguments == null) throw new LepException("bad expression argument", this); if (arguments.Count != pcount) throw new LepException("bad number of argument", this); return function.Invoke(arguments.GetArray(), this); }
protected object EvaluateNativeFunction(Environment env, NativeFunction function) { if (function == null) throw new ArgumentNullException(nameof(function), "null function"); int pcount = function.ParametersCount; if (Count != pcount) throw new LepException("bad number of arguments", this); object[] arguments = new object[pcount]; int count = 0; foreach (IAstNode node in this) arguments[count++] = node.Evaluate(env); return function.Invoke(arguments, this); }
public static string GetMethodNameForStackTrace(NativeFunction function) { if (function == null) { throw new ArgumentException("function cannot be null"); } var methodVar = function["m"]; if (methodVar == null) { // no function metadata available Logging.Debug("No function metadata available for function: " + function.NativeToString()); return null; } Method method = methodVar.Cast<Method>(); return method.FullName; }
// Returns a string that can be used for calling a c++ native function String GetFunctionCallString(NativeFunction function) { if (natives == null) return null; String name = function.Namespace + "::"; if (function.Name.Length > 0) name += function.Name; else name += "_" + function.Hash; String pstr = String.Empty; foreach (FunctionParameter _parameter in function.Params) pstr += String.Format("{0}, ", _parameter.Name); if (pstr.Length >= 3) pstr = pstr.Remove(pstr.Length - 2); return String.Format("{0}({1})", name, pstr); }
internal NativeCall(NativeFunction function, Scriptable scope, object[] args) { this.function = function; SetParentScope(scope); // leave prototype null this.originalArgs = (args == null) ? ScriptRuntime.emptyArgs : args; // initialize values of arguments int paramAndVarCount = function.GetParamAndVarCount(); int paramCount = function.GetParamCount(); if (paramAndVarCount != 0) { for (int i = 0; i < paramCount; ++i) { string name = function.GetParamOrVarName(i); object val = i < args.Length ? args[i] : Undefined.instance; DefineProperty(name, val, PERMANENT); } } // initialize "arguments" property but only if it was not overridden by // the parameter with the same name if (!base.Has("arguments", this)) { DefineProperty("arguments", new Arguments(this), PERMANENT); } if (paramAndVarCount != 0) { for (int i = paramCount; i < paramAndVarCount; ++i) { string name = function.GetParamOrVarName(i); if (!base.Has(name, this)) { if (function.GetParamOrVarConst(i)) { DefineProperty(name, Undefined.instance, CONST); } else { DefineProperty(name, Undefined.instance, PERMANENT); } } } } }
public static Scriptable CreateFunctionActivation(NativeFunction funObj, Scriptable scope, object[] args) { return new NativeCall(funObj, scope, args); }
public static void InitScript(NativeFunction funObj, Scriptable thisObj, Context cx, Scriptable scope, bool evalScript) { if (cx.topCallScope == null) { throw new InvalidOperationException(); } int varCount = funObj.GetParamAndVarCount(); if (varCount != 0) { Scriptable varScope = scope; // Never define any variables from var statements inside with // object. See bug 38590. while (varScope is NativeWith) { varScope = varScope.GetParentScope(); } for (int i = varCount; i-- != 0; ) { string name = funObj.GetParamOrVarName(i); bool isConst = funObj.GetParamOrVarConst(i); // Don't overwrite existing def if already defined in object // or prototypes of object. if (!ScriptableObject.HasProperty(scope, name)) { if (isConst) { ScriptableObject.DefineConstProperty(varScope, name); } else { if (!evalScript) { // Global var definitions are supposed to be DONTDELETE ScriptableObject.DefineProperty(varScope, name, Undefined.instance, ScriptableObject.PERMANENT); } else { varScope.Put(name, varScope, Undefined.instance); } } } else { ScriptableObject.RedefineProperty(scope, name, isConst); } } } }
// loads a natives.json from given path and returns data public static List<NativeNamespace> LoadFromFile(String path) { List<NativeNamespace> natives = new List<NativeNamespace>(); String json = File.ReadAllText(path); JObject namespaces = JObject.Parse(json); // Iterate namespaces foreach (KeyValuePair<String, JToken> _namespace in namespaces) { // Make a new namespace NativeNamespace ns = new NativeNamespace() { Name = _namespace.Key, Functions = new List<NativeFunction>() }; // Iterate namespace functions foreach (KeyValuePair<String, JToken> _function in (JObject)_namespace.Value) { // Make a new native function NativeFunction function = new NativeFunction() { Namespace = (String)_namespace.Key, Hash = (String)_function.Key, Name = (String)_function.Value["name"], Result = (String)_function.Value["results"], JHash = (String)_function.Value["jhash"], Params = new List<FunctionParameter>() }; // Add function parameters JArray parameters = (JArray)_function.Value["params"]; // Add parameters foreach (JObject _parameter in parameters) { FunctionParameter parameter = new FunctionParameter() { Name = _parameter.Value<String>("name"), Type = _parameter.Value<String>("type") }; function.Params.Add(parameter); } ns.Functions.Add(function); } natives.Add(ns); } return natives; }
/// <summary> /// Loads the map data into the memory. /// </summary> /// <param name="mode"> /// The <see cref="MapAndreasMode" /> to load with. /// </param> /// <exception cref="FileLoadException"> /// Thrown if the file couldn't be /// loaded. /// </exception> public static void Load(MapAndreasMode mode) { if (_mode != MapAndreasMode.None) return; _mode = mode; if (IsPluginLoaded()) { _nativeInit = new NativeFunction("MapAndreas_Init", typeof(int), typeof(string), typeof(int)); _nativeUnload = new NativeFunction("MapAndreas_Unload"); _nativeFindZ = new NativeFunction("MapAndreas_FindZ_For2DCoord", typeof(float), typeof(float), typeof(float).MakeByRefType()); _nativeFindAvgZ = new NativeFunction("MapAndreas_FindAverageZ", typeof(float), typeof(float), typeof(float).MakeByRefType()); _nativeSetZ = new NativeFunction("MapAndreas_SetZ_For2DCoord", typeof(float), typeof(float), typeof(float)); _native_SaveCurrentHMap = new NativeFunction("MapAndreas_SaveCurrentHMap", typeof(string)); _nativeInit.Invoke((int) mode, string.Empty, 1); _usePlugin = true; return; } switch (mode) { case MapAndreasMode.Full: try { using (var memstream = new FileStream(FullFile, FileMode.Open)) { _data = new ushort[memstream.Length/2]; var buffer = new byte[2]; int loc = 0; while ((memstream.Read(buffer, 0, 2)) == 2) _data[loc++] = BitConverter.ToUInt16(buffer, 0); } } catch (Exception e) { _mode = MapAndreasMode.None; throw new FileLoadException("Couldn't load " + FullFile, e); } break; case MapAndreasMode.Minimal: try { using (var memstream = new FileStream(MinimalFile, FileMode.Open)) { _data = new ushort[memstream.Length/2]; var buffer = new byte[2]; int loc = 0; while ((memstream.Read(buffer, 0, 2)) == 2) _data[loc++] = BitConverter.ToUInt16(buffer, 0); } } catch (Exception e) { _mode = MapAndreasMode.None; throw new FileLoadException("Couldn't load " + MinimalFile, e); } break; case MapAndreasMode.NoBuffer: try { _fileStream = new FileStream(FullFile, FileMode.Open); } catch (Exception e) { _mode = MapAndreasMode.None; throw new FileLoadException("Couldn't load " + MinimalFile, e); } break; } }
void NATIVEFUNCTION(out pBaseLangObject outObj, pBaseLangObject parent) { var obj = new NativeFunction(parent, t.line, t.col); outObj = obj; pBaseLangObject blo; VarType v; Expect(47); if (la.kind == 45) { Get(); obj.IsSimple = true; } if (StartOf(2)) { VARTYPE(out v); obj.VTO = new VarTypeObject(v); } else if (la.kind == 48) { Get(); obj.VTO = new VarTypeObject(VarType.Void); } else if (StartOf(12)) { bool isStrict = false; if (la.kind == 49) { Get(); isStrict = true; } IDENTACCESS(out blo, obj); obj.VTO = new VarTypeObject((Ident)blo, isStrict); if (la.kind == 21) { Template te; TEMPLATE(out te, outObj); obj.VTO.TemplateObject = te; } } else SynErr(95); IDENT(out blo, obj); obj.Name = (Ident)blo; Expect(10); if (StartOf(13)) { NEWVARIABLE(out blo, obj); obj.addChild(blo); while (la.kind == 18) { Get(); NEWVARIABLE(out blo, obj); obj.addChild(blo); } } Expect(11); while (StartOf(16)) { Get(); obj.Code += t.val + (la.val == ";" ? "" : " "); } Expect(50); obj.Code = obj.Code.Trim(); }
public static Scriptable CreateNativeGenerator(NativeFunction funObj, Scriptable scope, Scriptable thisObj, int maxLocals, int maxStack) { return new NativeGenerator(scope, funObj, new OptRuntime.GeneratorState(thisObj, maxLocals, maxStack)); }
internal static Method CreateMethod(Class declaringType, string name, NativeFunction function, int vtableSlot) { Method method = new Method(); method.Name = name; method.Function = function; method.VTableSlot = vtableSlot; if (function != null) { function["m"] = var.Cast<Method>(method); } method.DeclaringClass = declaringType; declaringType.Methods.Push(method); return method; }
internal static Constructor CreateConstructor(Class declaringType, string name, NativeFunction function) { Constructor ctor = new Constructor(); ctor.Name = name; ctor.Function = function; if (function != null) { function["m"] = var.Cast<Constructor>(ctor); } ctor.DeclaringClass = declaringType; declaringType.Constructors.Push(ctor); return ctor; }
public void UnregisterNativeFunction(NativeFunction function) { string fullName = function.Identifier + "("; for (int i = 0; i < function.ParameterTypes.Length; i++) fullName += function.ParameterTypes[i] + (i < function.ParameterTypes.Length - 1 ? "," : ""); fullName += ")"; _nativeFunctions.Remove(fullName); }
/// <summary> /// Parses through this class to find any methods that can be registered /// to a Virtual Machine. /// </summary> public void PrepareSet() { if (_prepared == true) return; _prepared = true; _globalFunctionSets.Add(this); Type type = this.GetType(); MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); foreach (MethodInfo method in methods) { // Go through attributes until we find a NativeFunctionInfo attribute // if we don't find one then ignore this function. NativeFunctionInfo infoAttribute = method.GetCustomAttributes(typeof(NativeFunctionInfo), true)[0] as NativeFunctionInfo; if (infoAttribute == null) continue; // Create a native function delegate for this method. NativeFunction function = new NativeFunction(infoAttribute.Name, (FunctionDelegate)FunctionDelegate.CreateDelegate(typeof(FunctionDelegate), this, method), infoAttribute.ReturnType, infoAttribute.ParameterTypes); _nativeFunctions.Add(function); } }
public static void InitFunction(Context cx, Scriptable scope, NativeFunction function, int type, bool fromEvalCode) { if (type == FunctionNode.FUNCTION_STATEMENT) { string name = function.GetFunctionName(); if (name != null && name.Length != 0) { if (!fromEvalCode) { // ECMA specifies that functions defined in global and // function scope outside eval should have DONTDELETE set. ScriptableObject.DefineProperty(scope, name, function, ScriptableObject.PERMANENT); } else { scope.Put(name, scope, function); } } } else { if (type == FunctionNode.FUNCTION_EXPRESSION_STATEMENT) { string name = function.GetFunctionName(); if (name != null && name.Length != 0) { // Always put function expression statements into initial // activation object ignoring the with statement to follow // SpiderMonkey while (scope is NativeWith) { scope = scope.GetParentScope(); } scope.Put(name, scope, function); } } else { throw Kit.CodeBug(); } } }
public void OnPacketReceived(object sender, OnPacketReceivedEventArgs args) { if (request == null) return; // not awaiting request if (response != null) return; // already received a reply if ((Packet.Opcodes)args.Pak.Opcode != Packet.Opcodes.FunctionReply) return; // wrong packet opcode args.Pak.Pos = 0; string guid = args.Pak.ReadString(); if (String.Compare(guid,request.Guid) != 0) return; // wrong function reply NativeFunction ret = new NativeFunction(); ret.Guid = guid; ret.Name = args.Pak.ReadString(); ret.Response = args.Pak.ReadInt32(); ret.Args = args.Pak.ReadString(); int datalength = args.Pak.Length - args.Pak.Pos; //Log.Debug("Good function reply received: " + ret.Name + " / " + ret.Response + " / " + ret.Args + " / " + args.Pak.Length + " / " + args.Pak.Pos + " / " + datalength); ret.Data.AddData(args.Pak.ReadData(datalength),datalength); response = ret; }
public formEditNative(NativeFunction pfunction, formMain pparentform) { InitializeComponent(); Function = pfunction; updateFunc = new DelUpdateFunction(pparentform.UpdateNative); }
private static extern object TempHackGenerateCodeForTrampolineInvokeMethod(NativeFunction nativeFunction, object self, object[] args);
public NativeFunction RequestFunctionWithArgs(Server server,NativeFunction function) { request = function; response = null; function.Guid = System.Guid.NewGuid().ToString(); InternalEvents.OnPacketReceived += OnPacketReceived; _Client.PakSender.SendNativeFunction(server, function.Guid, function.Name, function.Args, function.Data); int i=0; while ((response == null) && (i < MAX_RESPONSETIME)) { System.Threading.Thread.Sleep(1); i++; } if ((response == null) || (i >= MAX_RESPONSETIME)) { Log.Warning("Native function request failed."); InternalEvents.OnPacketReceived -= OnPacketReceived; return null; } InternalEvents.OnPacketReceived -= OnPacketReceived; response.Data.Pos = 0; return response; }
public static void InitFunction(NativeFunction fn, int functionType, Scriptable scope, Context cx) { ScriptRuntime.InitFunction(cx, scope, fn, functionType, false); }
public static int RequestFunctionWithArgs(string name, string args, params object[] data) { NativeFunction func = new NativeFunction(name,args); for (int i = 0; i < data.Length; i++) { if (data[i] is int) func.Data.AddInt32((int)data[i]); else if (data[i] is float) func.Data.AddFloat32((float)data[i]); else if (data[i] is string) func.Data.AddString(((string)data[i])); else if (data[i] is IntRef) func.Data.AddInt32((((IntRef)data[i]).Value)); else if (data[i] is FloatRef) func.Data.AddFloat32((((FloatRef)data[i]).Value)); else if (data[i] is StringRef) func.Data.AddString((((StringRef)data[i]).Value)); } NativeFunctionRequestor fr = new NativeFunctionRequestor(Client.Instance); func = fr.RequestFunctionWithArgs(Server.Instance, func); if (func == null) { Log.Warning("Function request " + name + " failed."); return 0; } func.Data.Pos = 0; /*string dat = "data: "; for (int i=0;i<func.Data.Length;i++) { dat += func.Data.Data[i].ToString() + " "; } Log.Debug(dat); func.Data.Pos = 0;*/ byte[] argsb = Encoding.ASCII.GetBytes(args); for (int i = 0; i < args.Length; i++) { if (argsb[i] == 'v') { if (data[i] is int) data[i] = func.Data.ReadInt32(); else if (data[i] is float) { data[i] = func.Data.ReadFloat32(); } else if (data[i] is IntRef) { ((IntRef)data[i]).Value = func.Data.ReadInt32(); } else if (data[i] is FloatRef) { ((FloatRef)data[i]).Value = func.Data.ReadFloat32(); } } else if (argsb[i] == 'p') { if (data[i] is string) data[i] = func.Data.ReadString(); else if (data[i] is StringRef) { ((StringRef)data[i]).Value = func.Data.ReadString();} } } return func.Response; }