Grinch_ Posted August 1, 2017 Share Posted August 1, 2017 Well,i am learning C.I dont know C++ yet.But i opened some source codes and tried to figure them out.As i noticed that there's a lot more to C++ than C and its a obvious fact.But I still can't get it.Well i know variables,data types etc of C and can make programs with it also but still i cant figure out how i can make my program to do some specific work on GTA games.Like I wanna decet some file it game directory and when the files are dected i wanna show a pop up before game starts. I know can check a file or read a file using pointer but still how i am gonna put the pop up? Will it work is i use printf or there is any other ways.??? I am still confused.Still it even possible to develop a mod via pure C??? Link to comment Share on other sites More sharing options...
Parik Posted August 1, 2017 Share Posted August 1, 2017 (edited) You cannot display a pop up with pure c. You have to use some sort of library. Windows has WINAPI which has a nice function called MessageBox you can use to pop up a message box. MessageBox(hWnd,lpText,lpCaption,uType) this is its syntax. You can read about it on MSDN. https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx Example Code: MessageBox(NULL,"A file has been detected" , "Detected" , MB_ICONINFORMATION); To have it run when the game starts , you have to compile the program as a dynamic link library , and then rename it to ASI. With the help of an asi loader it will be loaded. I have some sample programs you might consider reading through ( C ): [NOTE: neither was tested] https://gist.github.com/Zarig/e77544326d0ee005b6ea86e8dfd377ed- A mod similar to what you described. https://gist.github.com/Zarig/5f3b8ba271f13a9fbd62c64cd426965c- A script which increments your money by 20 if F6 is being holded. (GTA SA) The above two were simple programs , and therefore could be made using "pure" c with winapi , however when you are trying to do bigger mods , such as writing your own multiplayer client , it will become more difficult to write them with pure C. Learning C++ and also taking up some projects would help you to improve. For simple mods it is not recommended to use C. You can easily do it using CLEO in GTA VC/SA , or using C#/C++ Scripthook for GTA V/IV. Edited August 1, 2017 by Parik K^2 and RyanDri3957V 2 Link to comment Share on other sites More sharing options...
K^2 Posted August 1, 2017 Share Posted August 1, 2017 If you want to use printf, you can open a new console window, and re-direct stdout to it. If no console has been created yet, as with most games, all you really have to do is call AllocConsole. That will open a new console window, and you'll be able to printf to it. Keep in mind, though, that the game itself might also be printing a lot of debug info to stdout or stderror. So you might be getting a lot of stuff printed to that console. But yeah, either way, your program has to communicate with something else to create output. Either the operating system or the game itself. Prior to filing a bug against any of my code, please consider this response to common concerns. Link to comment Share on other sites More sharing options...
Grinch_ Posted August 1, 2017 Author Share Posted August 1, 2017 (edited) You cannot display a pop up with pure c. You have to use some sort of library. Windows has WINAPI which has a nice function called MessageBox you can use to pop up a message box. MessageBox(hWnd,lpText,lpCaption,uType)this is its syntax. You can read about it on MSDN. https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspxExample Code: MessageBox(NULL,"A file has been detected" , "Detected" , MB_ICONINFORMATION);To have it run when the game starts , you have to compile the program as a dynamic link library , and then rename it to ASI. With the help of an asi loader it will be loaded. I have some sample programs you might consider reading through ©: [NOTE: neither was tested] https://gist.github.com/Zarig/e77544326d0ee005b6ea86e8dfd377ed- A mod similar to what you described. https://gist.github.com/Zarig/5f3b8ba271f13a9fbd62c64cd426965c- A script which increments your money by 20 if F6 is being holded. (GTA SA) The above two were simple programs , and therefore could be made using "pure" c with winapi , however when you are trying to do bigger mods , such as writing your own multiplayer client , it will become more difficult to write them with pure C. Learning C++ and also taking up some projects would help you to improve. For simple mods it is not recommended to use C. You can easily do it using CLEO in GTA VC/SA , or using C#/C++ Scripthook for GTA V/IV. Thanks bro..I really needed a help on that.So i think it will be best for me to got to C++ then. Edited August 1, 2017 by inan.ahammad Link to comment Share on other sites More sharing options...
Gian_Yagami Posted September 26, 2017 Share Posted September 26, 2017 AFAIK, C++ is improvement of C. In C ++ added new concepts such as classes with properties such as inheritance and overloading. So that's no difference, just some improvement. I don't know yet about read/write a file using pointer, usually I am using method from library. Link to comment Share on other sites More sharing options...
K^2 Posted September 26, 2017 Share Posted September 26, 2017 AFAIK, C++ is improvement of C. In C ++ added new concepts such as classes with properties such as inheritance and overloading. So that's no difference, just some improvement. I don't know yet about read/write a file using pointer, usually I am using method from library.C++ started as an expansion of C. It is now a completely separate language, however. Modern C++ has very little in common with modern C outside of some naming conventions and broad syntax. Example in C. void PrintArray(int array[], int size){ for (int i = 0; i < size; ++i) { printf("%d\n", array[i]); }}Same in modern C++. void PrintArray(std::vector<int> array){ for (auto& value : array) { std::cout << value << std::endl; }}Moreover, instead of creating a function you can just pass a suitable lambda into an algorithm. std::for_each(array.begin(), array.end(), [](auto& value){ std::cout << value << std::endl; });Or maybe this reduce algorithm from numerics. std::cout << std::accumulate(array.begin(), array.end(), std::string{}, [](std::string string, auto& value){ return string + std::to_string(value) + "\n"; });And even more importantly, you could still use that initial function by importing it with extern "C" and calling PrintArray(array.data(), array.size()). C++ gives you all the same access to underlying low-level implementation as C did, but you can also use it as a higher level language. Which means you can have all the convenience and memory safety of high level languages with performance and type-safety of the low level languages. RyanDri3957V 1 Prior to filing a bug against any of my code, please consider this response to common concerns. Link to comment Share on other sites More sharing options...