06.03.2015, 15:50
(
Последний раз редактировалось PaSaSaP; 06.03.2015 в 18:47.
)
How connect to MySQL? Can I use MySQL/R33 or get another library, for example like here?
And second question: How to create subclass of GtaVehicle?
or maybe:
Another: Is it possible to write filterscripts with C#?
If I has:
And this:
I has exception:
But if I use GtaVehicle instead my Vehicle, it works. I know, that I do casting and it is source of that exception, but I want know how to create vehicles in my own class, which is subclass of GtaVehicle, no field.
And second question: How to create subclass of GtaVehicle?
Код:
class Vehicle: GtaVehicle { public Vehicle(int i): base(i) { } }
Код:
class Vehicle { GtaVehicle vehicle; //for example in constructor public Vehicle(GtaVehicle v) { vehicle = v; } }
If I has:
Код:
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