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

    1. Red Dead Redemption 2

      1. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

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

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

    2. Forum Support

    3. Site Suggestions

Sign in to follow this  
Grinch_

GTA Modding With C

Recommended Posts

Grinch_

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???

Share this post


Link to post
Share on other sites
Parik

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

Share this post


Link to post
Share on other sites
K^2

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.

Share this post


Link to post
Share on other sites
Grinch_

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

Share this post


Link to post
Share on other sites
Gian_Yagami
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.

Share this post


Link to post
Share on other sites
K^2

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.

Share this post


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
Sign in to follow this  

  • 1 User Currently Viewing
    0 Members, 0 Anonymous, 1 Guest

×

Important Information

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