ikkentim / SampSharp

A framework for writing game modes for SA-MP in C#. SA-MP is a free Massively Multiplayer Online game mod for the PC version of Rockstar Games Grand Theft Auto: San Andreas.
https://sampsharp.net
Apache License 2.0
210 stars 41 forks source link

VehicleModelType as command parameter #416

Closed LDami closed 11 months ago

LDami commented 2 years ago

With the following code, /v tug does not work (Usage message displayed), but /v Tug works.

[Command("vehicle", "veh", "v", DisplayName = "v")]
private static void SpawnVehicleCommand(Player player, VehicleModelType model)
{
 // Spawn vehicle
}

This might be caused by 2 entries in the enum starting with same name: Tug and TugStairsTrailer.

https://github.com/ikkentim/SampSharp/blob/master/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/EnumType.cs#L59

VillainOP2393 commented 2 years ago

if(sscanf(params, "s[20]I(-1)I(-1)", model, color1, color2)) { return SCM(playerid, COLOR_SYNTAX, "Usage: /veh [modelid/name] [color1 (optional)] [color2 (optional)]"); }

CiprianN23 commented 2 years ago

if(sscanf(params, "s[20]I(-1)I(-1)", model, color1, color2)) { return SCM(playerid, COLOR_SYNTAX, "Usage: /veh [modelid/name] [color1 (optional)] [color2 (optional)]"); }

Hi

Your code snippet is from pawn, it is not relevant in the context of SampSharp and C# and also is not working in this context

ikkentim commented 1 year ago

I tested this with this command, but it works fine for me:

[Command("vehicle", "veh", "v", DisplayName = "v")]
private static void SpawnVehicleCommand(Player player, VehicleModelType model)
{
    // Spawn vehicle
    var vehicle = Vehicle.Create(model, player.Position, 0, 0, 0);
    player.PutInVehicle(vehicle);
}

Could you provide a repro case?

LDami commented 11 months ago

Fixed in 0.10