Quantcast

Jump to content

» «
Photo

C# ASI files

5 replies to this topic
Node
  • Node

    War. War never changes.

  • Members
  • Joined: 31 May 2010
  • United-Kingdom

#1

Posted 10 October 2012 - 05:35 PM

What exactly does/can an ASI file do?

I've seen multiple mods (Including CLEO) that use an ASI file and are put into the GTA SA directory.

What does an ASI file do that script cant?:S

Also can an ASI file be created in C# (Stupid question but I like to be certain)

K^2
  • K^2

    Vidi Vici Veni

  • Moderator
  • Joined: 14 Apr 2004
  • United-States
  • Best Poster [Programming] 2015
    Most Knowledgeable [Web Development/Programming] 2013
    Most Knowledgeable [GTA Series] 2011
    Best Debater 2010

#2

Posted 10 October 2012 - 06:23 PM

They are just renamed dynamically linked libraries (DLL). The sound engine used by Vice City and San Andreas would load extensions as .asi files. Basically, any .asi file it finds in game's root directory will be loaded at start up. This makes a call to DLL Main, which lets you access memory, add hooks, and so on.

In GTA IV era, this idea was brought back. While the game wouldn't load .asi files automatically, loaders have been written that do that. I will not get into details of how these work, but they effectively replicate the above behavior. The .asi extension has been kept both because people have been used to them and to distinguish mod libraries from libraries used by the game.

In principle, with ASI mods you can do absolutely anything in the game. You can change absolutely any behavior. However, it can be quite a bit of work depending on what you want to do. If you are writing an ASI script from scratch, you will have to know exactly which functions you want to hook into, write your own hooks, etc. That requires fairly detailed knowledge of the main process of the GTA game you are working with as well as good understanding of both machine language and whichever high-level language you happen to use.

Of course, for GTA IV, you have an option of using Script Hook library which covers most of this. It's not quite as flexible as writing your own hooks from scratch, but it's far easier to use. If you know some basic programming, you can write a basic mod with it.


And yes, you absolutely can write an ASI mod in C#. There is a ScriptHook.Net library, a modified version of the above, which can be used to write your GTA IV mod in C#. If you want to write an ASI file from scratch, then absolutely any language that can be used to compile a DLL file will do. That naturally includes C#.

Node
  • Node

    War. War never changes.

  • Members
  • Joined: 31 May 2010
  • United-Kingdom

#3

Posted 10 October 2012 - 06:28 PM

Thankyou for that information K^2 , It's just that I'm working on SAA2 (San Andreas Achievements 2).

I was wondering if I could use a .asi file to check if an achievement has been completed and update a text file with the results?

I know it sounds simple, but like you said, writing it from scratch takes knowledge and there aren't any tutorials on the internet on how to write asi files that manipulates GTA.

K^2
  • K^2

    Vidi Vici Veni

  • Moderator
  • Joined: 14 Apr 2004
  • United-States
  • Best Poster [Programming] 2015
    Most Knowledgeable [Web Development/Programming] 2013
    Most Knowledgeable [GTA Series] 2011
    Best Debater 2010

#4

Posted 10 October 2012 - 07:11 PM

Sounds doable, so long as you can find a good function call to hook into. Basically, you need to find a call that game itself makes that you would exploit to get your custom code called. From there, it's pretty straight forward. Check whatever variables you need to verify an achievement, and do file read/write as normal.

By the way, I said ASI would get loaded automatically in Vice and SA. That's wrong. Only Vice did that. San Andreas requires a loader. But it's pretty much the same from there on.

Node
  • Node

    War. War never changes.

  • Members
  • Joined: 31 May 2010
  • United-Kingdom

#5

Posted 06 November 2012 - 12:41 PM

QUOTE (K^2 @ Wednesday, Oct 10 2012, 20:11)
San Andreas requires a loader. But it's pretty much the same from there on.

If SA required a .asi loader then how does CLEO load its .asi file?

Just curious.

Bad.boy!
  • Bad.boy!

    SA modder

  • Feroci
  • Joined: 20 Jun 2010
  • Netherlands

#6

Posted 06 November 2012 - 06:33 PM

The cleo installer includes an ASI loader in San Andreas (VorbisFile.dll & vorbisHooked.dll). The other III-era games automatically load .asi files. You can find the source of an ASI loader here. The ASI loader uses the "LoadLibrary" function to load a dll.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users