SampSharp icon indicating copy to clipboard operation
SampSharp copied to clipboard

VehicleModelType as command parameter

Open LDami opened this issue 3 years ago • 3 comments
trafficstars

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

LDami avatar Jul 05 '22 16:07 LDami

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)]"); }

VillainOP2393 avatar Aug 02 '22 08:08 VillainOP2393

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

CiprianN23 avatar Aug 02 '22 08:08 CiprianN23

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?

ikkentim avatar Sep 19 '22 19:09 ikkentim

Fixed in 0.10

LDami avatar Oct 17 '23 21:10 LDami