nightwalker83 Posted June 22, 2011 Share Posted June 22, 2011 Hi, How would I retrieve an object's location to modify that object or group of objects? Thanks, Nightwalker Link to comment Share on other sites More sharing options...
Donny78 Posted June 22, 2011 Share Posted June 22, 2011 Something like: GTA.Object[] WorldObjects = World.GetAllObjects();foreach (GTA.Object obj in WorldObjects){ if (Exists(obj)) { Vector3 position = obj.Position; }} If you use arrays to keep track of objects then you can use it's index: if (Exists(WorldObjects[index])){ Vector3 position = WorldObjects[index].Position;} You could build some customs like so, this is to make your script smaller, it isn't a requirement: public Vector3 GetObjectPosition(int index){ if (Exists(WorldObjects[index])) { return new Vector3(WorldObjects[index].Position); }} That's C# btw. Link to comment Share on other sites More sharing options...
lindsayslorach Posted June 22, 2011 Share Posted June 22, 2011 public Vector3 GetObjectPosition(int index){ if (Exists(WorldObjects[index])) { return new Vector3(WorldObjects[index].Position); }} Just quickly, couldn't you do: public Vector3 GetObjectPosition(int index){ if (Exists(WorldObjects[index])) { return WorldObjects[index].Position; }} instead? Link to comment Share on other sites More sharing options...
Donny78 Posted June 22, 2011 Share Posted June 22, 2011 Yep. Link to comment Share on other sites More sharing options...
lindsayslorach Posted June 22, 2011 Share Posted June 22, 2011 Lol, sorry. Didn't mean to be mean or anything Link to comment Share on other sites More sharing options...
Donny78 Posted June 22, 2011 Share Posted June 22, 2011 Lol, sorry. Didn't mean to be mean or anything It's all good dude, you wasn't being anything but helpful, I appreciate the correction Link to comment Share on other sites More sharing options...
nightwalker83 Posted June 23, 2011 Author Share Posted June 23, 2011 (edited) I was thinking of creating a mod that displays lights over the flying rats like Demarest did with the hidden packages mod for GTA: Vice City. Edited June 23, 2011 by nightwalker83 Link to comment Share on other sites More sharing options...
nightwalker83 Posted July 9, 2011 Author Share Posted July 9, 2011 Damn, that code has a lot of errors it I can't figure out how to get it working. Link to comment Share on other sites More sharing options...
lindsayslorach Posted July 9, 2011 Share Posted July 9, 2011 Paste your code and we'll have a look at it, or join the IRC channel (click my signature). Link to comment Share on other sites More sharing options...
nightwalker83 Posted July 10, 2011 Author Share Posted July 10, 2011 (edited) Paste your code and we'll have a look at it, or join the IRC channel (click my signature). Here is my code: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows.Forms;using GTA;namespace tutorialScriptVS{ public class tutScriptVS : Script { GTA.Object[] WorldObjects = World.GetAllObjects("Flying Rats");foreach(GTA.Object obj in WorldObjects){ if (Exists(obj)) { Vector3 position = obj.Position; }} Edited July 10, 2011 by nightwalker83 Link to comment Share on other sites More sharing options...
lindsayslorach Posted July 10, 2011 Share Posted July 10, 2011 Do you use an IDE like Visual Studio or just a text editor? If you use a text editor I would suggest using Visual C# 2010 Express, it's free. Your code is missing a few closing brackets and a constructor/methods. Have you read any tutorials on C#? I suggest you do, it'll make modding much easier . I also suggest you join the IRC channel, MulleDK19 is in there a lot, he can help you. Link to comment Share on other sites More sharing options...
nightwalker83 Posted July 10, 2011 Author Share Posted July 10, 2011 Do you use an IDE like Visual Studio or just a text editor? If you use a text editor I would suggest using Visual C# 2010 Express, it's free. Your code is missing a few closing brackets and a constructor/methods. Have you read any tutorials on C#? I suggest you do, it'll make modding much easier . I also suggest you join the IRC channel, MulleDK19 is in there a lot, he can help you. I have the full version of Visual Studios and I am familiar with C#. I just have never modded before. Link to comment Share on other sites More sharing options...
kryptylomese Posted September 18, 2012 Share Posted September 18, 2012 The .net object collection works very well but I would like to do this in C++ - I cannot find any native function that appears to find objects (I can however manipulate objects that I have spawned). Can someone please give me a clue? Link to comment Share on other sites More sharing options...
Deluxe8900 Posted September 19, 2012 Share Posted September 19, 2012 Why do it in C#? It's sh*t. Do it in C++ void main() { REMOVE_OBJECT(object name, position, coords) REMOVE_COLLISON(int, var, name, object) } And that should remove it, unless you don't understand C++ or the llvlm compiler Link to comment Share on other sites More sharing options...
ch3y3zze Posted September 20, 2012 Share Posted September 20, 2012 did c# have sex with your mama or something?? did c# beat and molest u as a child?? lol Link to comment Share on other sites More sharing options...
kryptylomese Posted September 20, 2012 Share Posted September 20, 2012 So, how do I do getallobjects in C++? Link to comment Share on other sites More sharing options...
kryptylomese Posted September 24, 2012 Share Posted September 24, 2012 I want to get the world nearest object in C++ (this is easy to do in c# with getallobjects). I cannot see a Native call to do this so does anyone know of a way to do it? Link to comment Share on other sites More sharing options...
kryptylomese Posted October 5, 2012 Share Posted October 5, 2012 OK, for anyone else trying to getallobjects in C++, you can look at the newly released source code for scripthook.net which uses the address of the object pool. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now