xanman2331 Posted February 7, 2018 Share Posted February 7, 2018 I am making my first mod and I have only really started learning C# in the last few days, so I apologise if the problem is something very obvious. I just want to check whether the pickup has been collected and I don't understand what's wrong (nor can I find any other topic on these forums that helps me). The error I am getting says "Error CS1503 Argument 2: cannot convert from 'GTA.Pickup' to 'GTA.Native.InputArgument'". Thanks for your help and I can provide more code if needed. Pickup randWeapon = World.CreatePickup(weapons[rnd.Next(0, weapons.Count)], player.Position + (player.ForwardVector * 5), player.Rotation, 0, 1);{ Function.Call(Hash.HAS_PICKUP_BEEN_COLLECTED, randWeapon); Link to comment Share on other sites More sharing options...
OfficerJohnson Posted February 7, 2018 Share Posted February 7, 2018 I am making my first mod and I have only really started learning C# in the last few days, so I apologise if the problem is something very obvious. I just want to check whether the pickup has been collected and I don't understand what's wrong (nor can I find any other topic on these forums that helps me). The error I am getting says "Error CS1503 Argument 2: cannot convert from 'GTA.Pickup' to 'GTA.Native.InputArgument'". Thanks for your help and I can provide more code if needed. Pickup randWeapon = World.CreatePickup(weapons[rnd.Next(0, weapons.Count)], player.Position + (player.ForwardVector * 5), player.Rotation, 0, 1);{ Function.Call(Hash.HAS_PICKUP_BEEN_COLLECTED, randWeapon); Determine what HAS_PICKUP_BEEN_COLLECTED takes as an input argument. It's not accepting your Pickup object. Maybe it's an enum? If the function is supposed to take an object of type Pickup, review what is considered a pickup under SHV.NET. Link to comment Share on other sites More sharing options...
OfficerJohnson Posted February 7, 2018 Share Posted February 7, 2018 Okay. So the Pickup class has enums defined for pickups. Your code seems fine. Perhaps World.CreatePickup is not taking your randomization of the weapon as a valid argument? Try adding a single pickup type as the first argument and see if it gives you the error still. You may have to use a loop or some other method (maybe switch statement) to do that part. Link to comment Share on other sites More sharing options...
Bob_74 Posted February 7, 2018 Share Posted February 7, 2018 (edited) I am making my first mod and I have only really started learning C# in the last few days, so I apologise if the problem is something very obvious. I just want to check whether the pickup has been collected and I don't understand what's wrong (nor can I find any other topic on these forums that helps me). The error I am getting says "Error CS1503 Argument 2: cannot convert from 'GTA.Pickup' to 'GTA.Native.InputArgument'". Thanks for your help and I can provide more code if needed. Pickup randWeapon = World.CreatePickup(weapons[rnd.Next(0, weapons.Count)], player.Position + (player.ForwardVector * 5), player.Rotation, 0, 1);{ Function.Call(Hash.HAS_PICKUP_BEEN_COLLECTED, randWeapon); Do you use ScriptHookVDotNet? If so, it is not how pickup are created: World.CreatePickup(PickupType type, Vector3 position, Vector3 rotation, Model model, int value) The first parameter is the type of pickup the player will collect, it is an enum as OfficerJohnson said. You also need to specify a valid Model or else your pickup will not be created. Going back to your problem. Oddly, Pickups don't react the same way as other entities like Peds, Props or Vehicles when you have to pass it to a native. I don't know why, I tried to pass randWeapon.Handle since natives works with handles but it didn't work. Pickups also have the isCollected property but I had no success with it either... The only working way I've found to detect if the pickup has been collected is to check ObjectExists(): // Creating PickuprandWeapon = World.CreatePickup(PickupType.WeaponMinigun, Game.Player.Character.GetOffsetInWorldCoords(new Vector3(0f, 2f, 0f)), new Model("w_mg_minigun"), -1);// Checking every Tick:if randWeapon != null) if (!randWeapon.ObjectExists()) UI.Notify("~g~Pickup has been collected!"); Edited February 7, 2018 by Bob_74 Link to comment Share on other sites More sharing options...
xanman2331 Posted February 8, 2018 Author Share Posted February 8, 2018 I am making my first mod and I have only really started learning C# in the last few days, so I apologise if the problem is something very obvious. I just want to check whether the pickup has been collected and I don't understand what's wrong (nor can I find any other topic on these forums that helps me). The error I am getting says "Error CS1503 Argument 2: cannot convert from 'GTA.Pickup' to 'GTA.Native.InputArgument'". Thanks for your help and I can provide more code if needed. Pickup randWeapon = World.CreatePickup(weapons[rnd.Next(0, weapons.Count)], player.Position + (player.ForwardVector * 5), player.Rotation, 0, 1);{ Function.Call(Hash.HAS_PICKUP_BEEN_COLLECTED, randWeapon); Do you use ScriptHookVDotNet? If so, it is not how pickup are created: World.CreatePickup(PickupType type, Vector3 position, Vector3 rotation, Model model, int value) The first parameter is the type of pickup the player will collect, it is an enum as OfficerJohnson said. You also need to specify a valid Model or else your pickup will not be created. Going back to your problem. Oddly, Pickups don't react the same way as other entities like Peds, Props or Vehicles when you have to pass it to a native. I don't know why, I tried to pass randWeapon.Handle since natives works with handles but it didn't work. Pickups also have the isCollected property but I had no success with it either... The only working way I've found to detect if the pickup has been collected is to check ObjectExists(): // Creating PickuprandWeapon = World.CreatePickup(PickupType.WeaponMinigun, Game.Player.Character.GetOffsetInWorldCoords(new Vector3(0f, 2f, 0f)), new Model("w_mg_minigun"), -1);// Checking every Tick:if randWeapon != null) if (!randWeapon.ObjectExists()) UI.Notify("~g~Pickup has been collected!"); This fixed the problem thanks Link to comment Share on other sites More sharing options...
xanman2331 Posted February 9, 2018 Author Share Posted February 9, 2018 I have a couple of other questions: How would I go about writing the random weapon's name as a subtitle on screen? and (separate function) how do I set the coordinates I want something to spawn at? I have been using Vector3 for spawn location but it says I have a problem with value tuples (Error CS8179 Predefined type 'System.ValueTuple`3' is not defined or imported, or is declared in multiple referenced assemblies), as well as converting (int, int, int) to Vector3 (Cannot implicitly convert type '(int, int, int)' to 'GTA.Math.Vector3') Random rnd = new Random(); GTA.Math.Vector3 spawnLoc1 = (rnd.Next(-3500, 7200), rnd.Next(-3300, 4000), 0); Again I can provide more code if you need Link to comment Share on other sites More sharing options...
OfficerJohnson Posted February 10, 2018 Share Posted February 10, 2018 I have a couple of other questions: How would I go about writing the random weapon's name as a subtitle on screen? and (separate function) how do I set the coordinates I want something to spawn at? I have been using Vector3 for spawn location but it says I have a problem with value tuples (Error CS8179 Predefined type 'System.ValueTuple`3' is not defined or imported, or is declared in multiple referenced assemblies), as well as converting (int, int, int) to Vector3 (Cannot implicitly convert type '(int, int, int)' to 'GTA.Math.Vector3') Random rnd = new Random(); GTA.Math.Vector3 spawnLoc1 = (rnd.Next(-3500, 7200), rnd.Next(-3300, 4000), 0);Again I can provide more code if you need For the first part, IIRC, UI.ShowSubtitle(). You need that. As for the second part, see if there is a function for converting Vector3toInt. Yeah. We can't be casting 3-point parameters to a single int. vector3 needs an x,y and z value. Link to comment Share on other sites More sharing options...
Bob_74 Posted February 10, 2018 Share Posted February 10, 2018 (edited) I have been using Vector3 for spawn location but it says I have a problem with value tuples (Error CS8179 Predefined type 'System.ValueTuple`3' is not defined or imported, or is declared in multiple referenced assemblies), as well as converting (int, int, int) to Vector3 (Cannot implicitly convert type '(int, int, int)' to 'GTA.Math.Vector3') Random rnd = new Random(); GTA.Math.Vector3 spawnLoc1 = (rnd.Next(-3500, 7200), rnd.Next(-3300, 4000), 0); Again I can provide more code if you need Vector3 is defined by three float values. You need to cast the float type on your int numbers: GTA.Math.Vector3 spawnLoc1 = (float)(rnd.Next(-3500, 7200), (float)rnd.Next(-3300, 4000), 0f); The float notation in C# is made using an f after the number (ie: 0.0f). Otherwise it is considered as a int or a double if the number has a decimal separator (ie: 0.0). Edited February 10, 2018 by Bob_74 xanman2331 1 Link to comment Share on other sites More sharing options...