[New to modding] Player/Ped obj ID property not defined, how to obtain it?
-
Hello Community !
I'm completely new to GTAV modding but I have some experience in programming. By following this tutorial playlist (videos are from more than a year ago)
https://www.youtube.com/playlist?list=PLbhQKmLHe3WVkQx1oO3XZuGcfk0ddzlUt
I got running a super simple mod which spawns dogs by pressing a key. I got stuck when trying to obtain the ID property of a Ped object, like follows:
Ped player = Game.Player.Character;
int pID = player.ID // VS error about no definition for IDOR
Ped pedObj = GTA.World.CreatePed(pedModelName, spawnLocation);
int pID = PedObj.ID; // Same error.A screenshot of tutorial here: https://1drv.ms/i/s!Anc-GpEvfA8Qg6ts--4y24t5ECFCNA (ID is found) and my code (where undefined) https://1drv.ms/i/s!Anc-GpEvfA8Qg6tqohwUbaX-AIwDaQ
By browsing on ScriptHookVdotNet (I have latest version as January 2017) I can check that ID has not been defined so maybe it is obtained differently now, my only guess right now in order to make the code run is:
player.GetHashCode();
OR
PedObj.GetHashCode()which also returns Int but of course the meaning is different. So my questions are:
- Is it safe to assume this ID simply as a unique identifier of created objects? (if so then I assign them one myself)
- Is it safe to assume the meaning of GetHashCode() is a unique identifier for each object within the library?
- How do I obtain the ID number?
Thank you!
-
@pc_user86 As far as I know, GetHashCode gets the hash for the model used, so two Peds could have the same hashcode if they are using the same model, even if they looked different because of clothing/accessory variations.
I have never come across any ID property for the player, so the only thing I know will be unique, is the instance of the Ped itself. If you wanted to assign ID numbers, then you would have to build a class to store Ped information and then make that Ped persistent.
I suspect the IDs are not used because for the majority of the time, Peds are not persistent. They spawn, walk around and then vanish, so an ID wouldn't have much practical use in that short lifespan.
-
ID was replaced with Handle.
-
@aimless Ah, thank you. That'll teach me to make speculative assumptions.
@pc_user86 Sorry for the misleading information, I've only been modding for around 6 months and very little with Peds... I have so much to learn yet it's untrue.
-
@LeeC2202 I would would not have known about what an ID is. If i never saw that tutorial.
-
@aimless Do you know if the Handles are recycled after a period of time or are they always guaranteed to be unique?
If they are unique, I can use them in my dirty cars mod and the OP gets a perfect solution to their problem as well. I call that a win-win for you.
-
Thank you guys @aimless and @LeeC2202 for your reply. This was very useful!.
Please allow me add 2 quick questions:- How do I print text on the screen? (and update the actual string, for example displaying a ever-changing number on the middle-right of the screen?)
- Is there any document with guidelines, syntax usage, code examples, things like this that we could always use for quick-referencing and consultation?
Thanks again guys!
-
@LeeC2202 I believe they are unique.
-
@pc_user86 You can use UI.ShowSubtitle(Game.Player.Character.Position.ToString(), 100);
in a loop or on tick to display your players position. It shows at center bottom of screen. You can do it at a different position but you need ether use NativeUI or use function calls. I have some links that ill post later to some code examples.
-
@aimless this worked perfect is just what I need, thank you man.
-
@pc_user86
These are some bookmarks i use frequently.
http://gtaforums.com/forum/370-gta-v/ScriptHookVDotNet wiki
https://github.com/crosire/scripthookvdotnet/wikiNative database.
http://www.dev-c.com/nativedb/Lots of examples in these two.
http://gtaforums.com/topic/814258-c-ultimate-modding-thread/
http://gtaforums.com/topic/803234-ultimate-modding-thread/Setting ped relationships and groups
http://gtaforums.com/topic/814647-calling-all-critters/?hl=relationshipgroupSetting Ped components.
http://gtaforums.com/topic/808513-changing-ped-clothes-and-attaching-props-to-ped-via-scripts/Simple helpful functions.
http://gtaforums.com/topic/813669-c-net-simple-helpful-functions/?hl=input_context#entry1068151517Display Help Text
http://gtaforums.com/topic/820813-displaying-help-text/?hl=input_contextDriving style guid
http://gtaforums.com/topic/822314-guide-driving-styles/Task sequnce using natives
http://gtaforums.com/topic/819828-task-sequence/?hl=sequenceNativeUI Menu Library
http://gtaforums.com/topic/809284-net-nativeui/Animations list
http://docs.ragepluginhook.net/html/62951c37-a440-478c-b389-c471230ddfc5.htm#amb@bagels@male@walking@Sectionlots of list and usefull info.
http://pastebin.com/u/UnknownModderVehicle modle table
http://gtaforums.com/topic/854636-vehicle-model-list/?p=1068937838