Quantcast

Jump to content

» «
Photo

[WIP|REL] San Andreas .NET Script Hook

36 replies to this topic
NTAuthority
  • NTAuthority

    member_title

  • The Yardies
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"

#1

Posted 09 March 2009 - 12:14 PM Edited by NTAuthority, 16 April 2009 - 07:40 PM.

What is this mod?

This modification is, like other script hooks, adds a external scripting possibility to SA. I know CLEO already exists, but SA's SCM language has some major limitations -- so I wrote this .NET scripting hook. It is inspired by HazardX's IV scripting hook, and based on the existing C++ SA script hook.

This version is a pretty tiny initial testing version, with just a few APIs (and a CallOpcode function smile.gif )

How to use this mod?

Just copy the scripts directory and the .asi file to your SA directory. The .NET Framework 3.5, and the Visual C++ 2008 Runtime are required. For development I recommend using Visual Studio/Visual C# Express's IntelliSense feature, example scripts for C# are in the scripts/development/ directory.

The hook will read both compiled .dll files, and .cs/.vb files, though Visual Basic is untested. To open or close the console, just press `.

TestScript2.cs has a keybinding of 'U': spawn a Ballas member and add some health to the player.
RandomStuff.cs has more key bindings:

- 'I': display a text box
- 'O': Spawn a Vagos member.
- 'kill' in console: Kill the player.
- 'spawn groves' in console: spawn 3 GSF members around the player

Where to download?

Version 0.0.3

You will need at least the DirectX November 2008 runtimes to use the script hook!

I look forward to your comments. smile.gif

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci Racing
  • Joined: 19 Aug 2006
  • Unknown

#2

Posted 09 March 2009 - 01:16 PM

Really interesting, but it seems that there aren't any references, or am I wrong?

NTAuthority
  • NTAuthority

    member_title

  • The Yardies
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"

#3

Posted 09 March 2009 - 01:27 PM

QUOTE (Wesser @ Mar 9 2009, 14:16)
Really interesting, but it seems that there aren't any references, or am I wrong?

You can simply add the .asi file as reference in Visual Studio if you copy it to a .dll -- didn't know VS would give errors if it's not a .dll file, will fix it in the next version. smile.gif

Grove Street Boy
  • Grove Street Boy

    Maggot for life!

  • Members
  • Joined: 06 Aug 2005

#4

Posted 09 March 2009 - 03:30 PM

cool! but this means i have to learn C++ to code for this hook? I only know Java, VB.Net and Cleo confused.gif

NTAuthority
  • NTAuthority

    member_title

  • The Yardies
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"

#5

Posted 09 March 2009 - 03:32 PM Edited by NTAuthority, 09 March 2009 - 03:53 PM.

QUOTE (Grove Street Boy @ Mar 9 2009, 16:30)
cool! but this means i have to learn C++ to code for this hook? I only know Java, VB.Net and Cleo confused.gif

Nope, you can't even use C++ 'officially' biggrin.gif The examples are just C#, but I have also written in support for VB.NET scripts, though you will need to discover the syntax yourself. By the way, C# is almost Java syntax with VB.NET's class libraries. smile.gif Next up for this hook: car APIs, and some more character stuff.

EDIT: ported RandomStuff.cs to VB.NET:

CODE

Imports System
Imports System.Collections.Generic
Imports System.Text

Namespace TestScript1
   Public Class TestScript
       Inherits GTA.Script

       Public Sub TestScript()
           BindKey(System.Windows.Forms.Keys.O, New GTA.KeyPressDelegate(AddressOf SpawnVago))
           BindKey(System.Windows.Forms.Keys.I, New GTA.KeyPressDelegate(AddressOf ShowText))
           BindConsoleCommand("kill", New GTA.ConsoleCommandDelegate(AddressOf Kill), Me)
           BindConsoleCommand("spawn groves", New GTA.ConsoleCommandDelegate(AddressOf NewGroves), Me)
       End Sub

       Public Sub Kill(ByVal args As String())
           PlayerObject.Character.Health = 0

           GTA.Console.WriteLine("Killed the player!")
       End Sub

       Public Sub NewGroves(ByVal args As String())
           Dim ped As GTA.Char = GTA.World.CreateChar(GTA.PedID.FAM1, PlayerObject.Character.Position.Around(2), 4)
           ped = GTA.World.CreateChar(GTA.PedID.FAM2, PlayerObject.Character.Position.Around(2), 4)
           ped = GTA.World.CreateChar(GTA.PedID.FAM3, PlayerObject.Character.Position.Around(2), 4)
       End Sub

       Public Sub SpawnVago()
           Dim vector As GTA.Vector3 = PlayerObject.Character.Position

           vector.pY += 1
           Dim ped As GTA.Char = GTA.World.CreateChar(GTA.PedID.LSV2, vector, 4)
       End Sub

       Public Sub ShowText()
           GTA.Game.DisplayTextBox("You pressed I")
       End Sub
   End Class
End Namespace

Zach
  • Zach

    Thug

  • Members
  • Joined: 29 Jun 2004

#6

Posted 10 March 2009 - 03:36 AM

Nice. Any chance you'll release the source code (for your hook) as well?

Grove Street Boy
  • Grove Street Boy

    Maggot for life!

  • Members
  • Joined: 06 Aug 2005

#7

Posted 10 March 2009 - 10:16 AM

lol cool. Ive been learning VB.NET in college lately! Really should look into learning this tool. smile.gif

rlim201
  • rlim201

    Player Hater

  • Members
  • Joined: 17 May 2009

#8

Posted 17 May 2009 - 01:55 PM

download link is dead!

joemomma53
  • joemomma53

    Ohai

  • Members
  • Joined: 10 Jun 2007

#9

Posted 02 June 2009 - 09:18 PM

Sorry for bump, But I downloaded this and started testing it. It's really nice. The only thing I found wrong with it is that I can't get it to read .dll's, but thats not really a big deal, as it reads the C# source file biggrin.gif

By the way, is there a documentation on it, like for what it supports, like vehicle API's for example? I was also wondering if it had a weapons API in it

NTAuthority
  • NTAuthority

    member_title

  • The Yardies
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"

#10

Posted 09 June 2009 - 02:32 PM

QUOTE (joemomma53 @ Jun 2 2009, 23:18)
Sorry for bump, But I downloaded this and started testing it. It's really nice. The only thing I found wrong with it is that I can't get it to read .dll's, but thats not really a big deal, as it reads the C# source file biggrin.gif

By the way, is there a documentation on it, like for what it supports, like vehicle API's for example? I was also wondering if it had a weapons API in it

(sorry for bumping, have been away from april 30th to today)

It should be able to use .dll files, if not, could you please post the log file entries? Also, the GTA.Next version of the hook supports weapon changing (but Native.CallOpcode is a good help) -- I'll update the links later this week.

joemomma53
  • joemomma53

    Ohai

  • Members
  • Joined: 10 Jun 2007

#11

Posted 11 June 2009 - 01:14 AM

QUOTE (NTAuthority @ Jun 9 2009, 14:32)
QUOTE (joemomma53 @ Jun 2 2009, 23:18)
Sorry for bump, But I downloaded this and started testing it. It's really nice. The only thing I found wrong with it is that I can't get it to read .dll's, but thats not really a big deal, as it reads the C# source file biggrin.gif

By the way, is there a documentation on it, like for what it supports, like vehicle API's for example? I was also wondering if it had a weapons API in it

(sorry for bumping, have been away from april 30th to today)

It should be able to use .dll files, if not, could you please post the log file entries? Also, the GTA.Next version of the hook supports weapon changing (but Native.CallOpcode is a good help) -- I'll update the links later this week.

Well, My second hard drive got formatted the other day and I still need to re install San Andreas. When I re install it, I will get the logs and upload them for you biggrin.gif .

Thank you for your answer, when I get every thing set back up I will be experimenting with this more.

Donny78
  • Donny78

    Zombie

  • Members
  • Joined: 18 Jul 2008

#12

Posted 20 August 2009 - 11:39 AM

Is this still being developed ?

Just thought I'd ask as I'm interested in this for sure.

joemomma53
  • joemomma53

    Ohai

  • Members
  • Joined: 10 Jun 2007

#13

Posted 22 August 2009 - 11:08 PM

I don't think it is

sgt.slaughter
  • sgt.slaughter

    Li'l G Loc

  • BUSTED!
  • Joined: 26 Nov 2008

#14

Posted 23 August 2009 - 01:30 AM

I tried the link,it seems to get some sort of error confused.gif .I'll post the link to the GTAGaming download page just in-case someone else is getting the same thing icon14.gif :

http://www.gtagaming...reas/tools/2354

NTAuthority
  • NTAuthority

    member_title

  • The Yardies
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"

#15

Posted 24 August 2009 - 10:00 AM

QUOTE (joemomma53 @ Aug 23 2009, 01:08)
I don't think it is

It is, though I haven't gotten around to releasing the new version (with HUGE updates) tounge.gif

Donny78
  • Donny78

    Zombie

  • Members
  • Joined: 18 Jul 2008

#16

Posted 24 August 2009 - 01:58 PM

QUOTE (NTAuthority @ Aug 24 2009, 10:00)
QUOTE (joemomma53 @ Aug 23 2009, 01:08)
I don't think it is

It is, though I haven't gotten around to releasing the new version (with HUGE updates) tounge.gif

Good news, thankyou.

joemomma53
  • joemomma53

    Ohai

  • Members
  • Joined: 10 Jun 2007

#17

Posted 03 September 2009 - 01:56 AM

Yay!

I look forward to the updates biggrin.gif

NTAuthority
  • NTAuthority

    member_title

  • The Yardies
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"

#18

Posted 05 September 2009 - 05:36 PM

A tiny hint of one of the more special features in the next version... texture drawing. And by that, I mean with the old DX hooking code, but with a feature the IV hook doesn't have. If you know some C#, check out the code below:

CODE

this.tex = new Texture(256, 32);

// ...

Graphics rbg = this.tex.LockBitmap();
rbg.DrawString("Woef", this.font, new SolidBrush(Color.Black), 125, 0);
this.tex.UnlockBitmap();

// and... in another 'event'

Direct3D.DrawSprite(tex, new RectangleF(vPos.X, vPos.Y, GetX(105), GetY(28)), Color.White, 256f, 32f);


Indeed, the most annoying thing in the world (LockRectangle) now in a easy-to-use package for drawing your own dynamic textures. biggrin.gif


joemomma53
  • joemomma53

    Ohai

  • Members
  • Joined: 10 Jun 2007

#19

Posted 05 September 2009 - 06:08 PM Edited by joemomma53, 06 September 2009 - 06:16 AM.

biggrin.gif

Very nice

EDIT : Oh yeah, forgot to say. Well, in C# I added SanAndreasScriptHook as a reference, and even when I have
CODE
using SanAndreasScriptHook;
I get the error :
QUOTE
The type or namespace name 'SanAndreasScriptHook' could not be found (are you missing a using directive or an assembly reference?)


I never got it before cause I never added the reference.

Any way to fix this?

NTAuthority
  • NTAuthority

    member_title

  • The Yardies
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"

#20

Posted 13 September 2009 - 06:00 PM

QUOTE (joemomma53 @ Sep 5 2009, 20:08)
EDIT : Oh yeah, forgot to say. Well, in C# I added SanAndreasScriptHook as a reference, and even when I have
CODE
using SanAndreasScriptHook;
I get the error :
QUOTE
The type or namespace name 'SanAndreasScriptHook' could not be found (are you missing a using directive or an assembly reference?)


I never got it before cause I never added the reference.

Any way to fix this?

Sorry for the late response... but as you may have already figured out, the assembly name is indeed SanAndreasScriptHook, but the namespace everything's in is named GTA. By the way, the next release will have another very cool feature that allows you to 'hack' into the control state stuff... I have already made a cool gamepad control mod for the next version! I just want to release it now since it's so cool, but I can't tounge.gif

joemomma53
  • joemomma53

    Ohai

  • Members
  • Joined: 10 Jun 2007

#21

Posted 14 September 2009 - 02:38 AM

Thanks for the help man, I can't believe I didn't think of that, with everything being GTA, haha

Yeah man i'm looking forward to the new version, That sounds awesome!. Keep up the good work biggrin.gif

johnathon956
  • johnathon956

    Jim Davidson fan

  • BUSTED!
  • Joined: 15 Apr 2009

#22

Posted 16 October 2009 - 01:50 PM

does this work with cleo 3

joemomma53
  • joemomma53

    Ohai

  • Members
  • Joined: 10 Jun 2007

#23

Posted 17 October 2009 - 12:52 AM

QUOTE (johnathon956 @ Oct 16 2009, 13:50)
does this work with cleo 3

Err, i'm not quite sure what you mean by that, but I don't see why cleo wouldn't work if you used this also.

Donny78
  • Donny78

    Zombie

  • Members
  • Joined: 18 Jul 2008

#24

Posted 28 October 2009 - 06:06 PM

I just tested this on Windows 7 (64) and it doesn't seem to goto plan.

It crashed once at the loading screen before you spawn, it just froze at the end when the white bar was full. This was when I forgot to put my scripts asi into the scripts folder, I dropped it in the root along with your scripthook asi but when I put it in the script folder it didn't crash but didn't appear to load as the console wouldn't activate and I couldn't test the button binds as it gives me an error on compile so I removed the lines that binds 'i' & 'o' ("Windows is not a member of System").

I'm using VB Express (free, just downloaded it now), I added the reference dll to my project and compiled after removing the bind lines so it's the RandomStuff.vb file without the binds on Windows 7 x64 and the 'gta_sa.exe' is set to run compatible for XP SP3 (can I do this for a dll, it's not a program so I haven't checked).

Does this have a log file it outputs ? I couldn't find one to explore the issue myself, I'll keep it testing and see if I can get it working but I thought I'd report this incase you already have a fix.

Cheers.

NTAuthority
  • NTAuthority

    member_title

  • The Yardies
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"

#25

Posted 29 October 2009 - 04:41 PM Edited by NTAuthority, 29 October 2009 - 04:43 PM.

QUOTE (Donny78 @ Oct 28 2009, 20:06)
I just tested this on Windows 7 (64) and it doesn't seem to goto plan.

It crashed once at the loading screen before you spawn, it just froze at the end when the white bar was full. This was when I forgot to put my scripts asi into the scripts folder, I dropped it in the root along with your scripthook asi but when I put it in the script folder it didn't crash but didn't appear to load as the console wouldn't activate and I couldn't test the button binds as it gives me an error on compile so I removed the lines that binds 'i' & 'o' ("Windows is not a member of System").

I'm using VB Express (free, just downloaded it now), I added the reference dll to my project and compiled after removing the bind lines so it's the RandomStuff.vb file without the binds on Windows 7 x64 and the 'gta_sa.exe' is set to run compatible for XP SP3 (can I do this for a dll, it's not a program so I haven't checked).

Does this have a log file it outputs ? I couldn't find one to explore the issue myself, I'll keep it testing and see if I can get it working but I thought I'd report this incase you already have a fix.

Cheers.

This current version is really buggy and out-of-date, a more recent version can be found here (copy the .asi to a .dll for a reference, you need a scripts folder and datafiles folder... all old code should still work after recompiling. and please, remove the old .asi), but it does not contain the console. Also, for key bindings, you need to add a reference to System.Windows.Forms to your project. (though I usually prefer the new GTAKey in a OnTick event... it's what you prefer)

(that version in the mod has some of the bugs still in, but a lot more features and such smile.gif )

Also, did you really have the code 'extend'-ing ('Inherits' in VB, possibly?) Script? Your file structure should, by the way, be for example:

GTASA\
-- citizenhook.asi
-- scripts\
---- DBNetwork.Citizen.Game.dll (your DLL file)
------ datafiles\ (nothing specific needed in there)

Another thing is that the mod still is incompatible with the CLEO GXTHook, but it's possible to emulate it using the new Game.CustomGXTs property. smile.gif Also, it hasn't been used much with VB, but since both are full .NET languages, it should still work. smile.gif

(offtopic: decided you didn't like C++? tounge.gif )

PS: Do you intend on releasing a mod made with this? If so, it's just about time. tounge.gif

Donny78
  • Donny78

    Zombie

  • Members
  • Joined: 18 Jul 2008

#26

Posted 31 October 2009 - 10:46 AM

I'm going to reinstall XP on another drive soon so I'll have another go with this then dude, nothing seems to work no matter what I do, everything is setup correctly like you explained so I'm either being retarded or it's this bloody OS messing with me (probably the case).

No I like C++ just fine, it's C++ that doesn't like me biggrin.gif

I plan on doing a few mods if I ever get anything working, I have many ideas that I would like to put into action, once I go back to XP then I'll start on them for sure.

Cheers for the help, I apreciate it.

denisy
  • denisy

    Player Hater

  • Members
  • Joined: 01 Feb 2010

#27

Posted 01 February 2010 - 03:40 AM

QUOTE (sgt.slaughter @ Aug 23 2009, 01:30)
I tried the link,it seems to get some sort of error confused.gif .I'll post the link to the GTAGaming download page just in-case someone else is getting the same thing icon14.gif :

http://www.gtagaming...reas/tools/2354

Thanks for the link man! biggrin.gif

NTAuthority
  • NTAuthority

    member_title

  • The Yardies
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"

#28

Posted 01 February 2010 - 07:58 AM

QUOTE (denisy @ Feb 1 2010, 04:40)
QUOTE (sgt.slaughter @ Aug 23 2009, 01:30)
I tried the link,it seems to get some sort of error confused.gif .I'll post the link to the GTAGaming download page just in-case someone else is getting the same thing icon14.gif :

http://www.gtagaming...reas/tools/2354

Thanks for the link man! biggrin.gif

Noooooooooooooooooooooooo, do not use that very old version! Until I write a new topic for the new GTAScriptHook, you should use the pre-release instead... unless you like compatibility with the 2 crap scripts I've written tounge.gif

TheSiggi
  • TheSiggi

    Surgeon

  • Members
  • Joined: 05 Jul 2009

#29

Posted 27 September 2010 - 01:26 PM

Could you upload your latest version aswell?
cheers

TheSiggi
  • TheSiggi

    Surgeon

  • Members
  • Joined: 05 Jul 2009

#30

Posted 01 November 2010 - 08:25 PM

I know this is a bump and I'm also doubleposting suicidal.gif

But: Can it be that some incompability problems occour when VC++ 2010 Runtime is installed? Because I noticed starnge behaviour of scripts since i updated the Runtime...
I also know .NET 4 is compatible downwards but could it be a cause for problems too?
cheers




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users