Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Cayo Perico Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

      1. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

      1. GTANet 20th Anniversary
    2. Support

      1. Court House
    3. Suggestions

GTA Modding With C


Grinch_

Recommended Posts

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 post
Share on other sites

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 by Parik
  • Like 2
Link to post
Share on other sites

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.

Link to post
Share on other sites

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 ©:

[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 by inan.ahammad
Link to post
Share on other sites
  • 1 month later...
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 post
Share on other sites

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.

  • Like 1
Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.