Jump to content

Question about scripting


Recommended Posts

I have this Code:

 

if (Player.Character.Armor > 0) {

if (Player.Skin.Component.Bags.ModelIndex == 0) {
Player.Skin.Component.Bags.ModelIndex = 2;
}
} else if (Player.Skin.Component.Bags.ModelIndex == 2) {
Player.Skin.Component.Bags.ModelIndex = 0;
}

 

and want to know If I should compile it from a .txt to a .c or can I just write it in the Notepad and save it as a .c file. And then I want to know how to compile it to an script (.cs, .net, etc.) and which is best of them? :D

Link to comment
https://gtaforums.com/topic/765759-question-about-scripting/
Share on other sites

.c file extensions are for the C programming language, so you should NOT use this for what you are coding in (C#). Also, .c is for source code, it is not compiled code.

.cs is also for source code. .cs is what you should be coding in, not a .txt file. If you want, you can put this in the scripts folder and .NET Scripthook will automatically compile it in run time and run it.

.net is really just a .dll file. To compile to a .dll file, create a Visual Studio (2010+) project, add a reference to the ScriptHookDotNet.dll file (in the "For Developers" folder in the scripts folder), copy your code to the newly created class in the Visual Studio project, then click Build -> Build Solution. Now go to where you created the project file (default is "C:\Users\<username>\Documents\Visual Studio 2013\Projects\<projectname>\", then go to bin -> Debug (unless you compiled it for Release or another platform like x86 (which you should)) and copy the <projectname>.dll file to your scripts folder and rename it to <projectname>.net or <projectname>.net.dll.

I also recommend to code in Visual Studio, and not in a normal text editor like notepad. It makes things a lot easier.

Oh and P.S. If you need to know how to do things like "add a reference to the ScriptHookDotNet.dll file", just Google it (not the "ScriptHookDotNet.dll part").

Edited by LetsPlayOrDy
Link to comment
https://gtaforums.com/topic/765759-question-about-scripting/#findComment-1066930315
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
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

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