06.03.2015, 11:09
Target framework should be 4.0 or can be 4.5?
|
I actually like this...
But I have some questions... Does this affect the speed of execution in runtime or does it affect any thing ? And will I have to create a wrapper for each and every plugin I use ? |
class Vehicle: GtaVehicle
{
public Vehicle(int i): base(i)
{
}
}
class Vehicle
{
GtaVehicle vehicle;
//for example in constructor
public Vehicle(GtaVehicle v)
{
vehicle = v;
}
}
class Vehicle: GtaVehicle
{
public Vehicle(int v):base(v)
{
}
}
[Command("car")]
public static void commandCar(Player player)
{
player.SendClientMessage("No i masz samochуd.");
//Vehicle car = new Vehicle(GtaVehicle.CreateStatic(400, player.Position, 0.0f, 1, 2));
//car.vehicle.Position = player.Position;
//player.PutInVehicle(car.vehicle);
Vehicle car = (Vehicle) Vehicle.Create(400, player.Position, player.Rotation.Z, 3, 3, -1);
car.Position = player.Position;
player.PutInVehicle((GtaVehicle) car);
}
[06/03/2015 20:15:36] Exception thrownOnPlayerCommandText: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Cannot cast from source type to destination type. at PaSaSaPGM.GameMode.commandCar (PaSaSaPGM.World.Player player) [0x00000] in <filename unknown>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 --- End of inner exception stack trace --- at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0 at SampSharp.GameMode.SAMP.Commands.DetectedCommand.RunCommand (SampSharp.GameMode.World.GtaPlayer player, System.String args) [0x00000] in <filename unknown>:0 at SampSharp.GameMode.Controllers.CommandController+<>c__DisplayClass8.<gameMode_PlayerCommandText>b__6 (System.Tuple`2 candidate) [0x00000] in <filename unknown>:0 at System.Linq.Enumerable.First[Tuple`2] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0 at System.Linq.Enumerable.FirstOrDefault[Tuple`2] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0 at SampSharp.GameMode.Controllers.CommandController.gameMode_PlayerCommandText (System.Object sender, SampSharp.GameMode.Events.CommandTextEventArgs e) [0x00000] in <filename unknown>:0 at (wrapper delegate-invoke) System.EventHandler`1<SampSharp.GameMode.Events.CommandTextEventArgs>:invoke_void_object_TEventArgs (object,SampSharp.GameMode.Events.CommandTextEventArgs) at SampSharp.GameMode.BaseMode.OnPlayerCommandText (SampSharp.GameMode.World.GtaPlayer player, SampSharp.GameMode.Events.CommandTextEventArgs e) [0x00000] in <filename unknown>:0 at PaSaSaPGM.GameMode.OnPlayerCommandText (SampSharp.GameMode.World.GtaPlayer player, SampSharp.GameMode.Events.CommandTextEventArgs e) [0x00000] in <filename unknown>:0 at SampSharp.GameMode.BaseMode.OnPlayerCommandText (Int32 playerid, System.String cmdtext) [0x00000] in <filename unknown>:0
public class Vehicle: GtaVehicle
{
public Vehicle(int id) : base(id)
{
}
}
public class VehicleController : GtaVehicleController
{
public override void RegisterTypes()
{
Vehicle.Register<Vehicle>();
}
}
protected override void LoadControllers(ControllerCollection controllers)
{
base.LoadControllers(controllers);
controllers.Remove<GtaVehicleController>();
controllers.Add(new VehicleController());
}
Native.CallNative("CallRemoteFunction", __arglist("Function", arg1, arg2));
[07/03/2015 20:34:06] Exception thrownOnGameModeInit: FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. ---> NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.MySqlDataDriver, NHibernate, Version=4.0.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Configuration.ConfigurationErrorsException: Failed to find or load the registered .Net Framework Data Provider 'MySql.Data.MySqlClient'. at System.Data.Common.DbProviderFactories.GetFactory (System.String providerInvariantName) [0x00000] in <filename unknown>:0 at NHibernate.Driver.ReflectionBasedDriver..ctor (System.String providerInvariantName, System.String driverAssemblyName, System.String connectionTypeName, System.String commandTypeName) [0x00000] in <filename unknown>:0 at NHibernate.Driver.MySqlDataDriver..ctor () [0x00000] in <filename unknown>:0 at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0 --- End of inner exception stack trace --- at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0 at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0 at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0 at NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0 at NHibernate.Connection.ConnectionProvider.ConfigureDriver (IDictionary`2 settings) [0x00000] in <filename unknown>:0 --- End of inner exception stack trace --- at NHibernate.Connection.ConnectionProvider.ConfigureDriver (IDictionary`2 settings) [0x00000] in <filename unknown>:0 at NHibernate.Connection.ConnectionProvider.Configure (IDictionary`2 settings) [0x00000] in <filename unknown>:0 at NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider (IDictionary`2 settings) [0x00000] in <filename unknown>:0 at NHibernate.Cfg.SettingsFactory.BuildSettings (IDictionary`2 properties) [0x00000] in <filename unknown>:0 at NHibernate.Cfg.Configuration.BuildSettings () [0x00000] in <filename unknown>:0 at NHibernate.Cfg.Configuration.BuildSessionFactory () [0x00000] in <filename unknown>:0 at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory () [0x00000] in <filename unknown>:0 --- End of inner exception stack trace --- at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory () [0x00000] in <filename unknown>:0 at PaSaSaPGM.DbSession.CreateSessionFactory () [0x00000] in <filename unknown>:0 at PaSaSaPGM.DbSession.get_Factory () [0x00000] in <filename unknown>:0 at PaSaSaPGM.DbSession.OpenSession () [0x00000] in <filename unknown>:0 at PaSaSaPGM.GameMode.OnInitialized (System.EventArgs e) [0x00000] in <filename unknown>:0 at SampSharp.GameMode.BaseMode.OnGameModeInit () [0x00000] in <filename unknown>:0
//Lets store our current session
using (ISession session = DbSession.OpenSession())
{
session.Save(new ServerInfo { Number = new Random().Next(0, 100) });
}
//...
//... lets open a bunch of sessions
for (int x = 0; x < 10; x++)
{
using (ISession session = DbSession.OpenSession())
{
//Get first 10 sessions
IQueryable<ServerInfo> serverinfos = session.Query<ServerInfo>().Take(10);
foreach (ServerInfo si in serverinfos)
{
Console.WriteLine(si);
}
}
}
|
Failed to find or load the registered .Net Framework Data Provider 'MySql.Data.MySqlClient' |
new Vehicle(400); new Vehicle(400, new Vector(1.0f, 1.0f, 1.0f), 1.0f, 3, 3);
|
I changed MySQL package ;'D
I have the Vehicle class and it looks like You wrote above. What is difference between constructors: Код:
new Vehicle(400); new Vehicle(400, new Vector(1.0f, 1.0f, 1.0f), 1.0f, 3, 3); |
|
OK. I cant find how to start with linux server. Mybe I am so stupid to do this. So how to start with linux server?
|
Failed (plugins/libtest.so: undefined symbol: mono_string_to_utf8)
|
Been doing some testing with this. Some additional questions:
How to handle dialogs inline, such as implementing the response logic in the relevant classes? I tried spawning the player manually using this.spawn() in the Player class when the login would be successful. In Pawn, i used to return 0 on OnPlayerRequestClass. What would be the preffered way in Sharp, since the manual spawn does not work. |
var dialog = new Dialog(...);
dialog.Response += (sender, args) {
// handle response
};