Jump to content

Mission Scripting


Maro Hannover

Recommended Posts

Maro Hannover

Hi i am back. I just wanted to take a rest from practicing C#. the website dotnetperls upgraded me from dummy to begginer to semi-intermediate. The thing that blow my mind is that i want to code missions. I want things like Objective to kill actors enter car. if car destroyed mission fail. Yesterday i kept the whole day searching for a possible method. finally i made something like this

if(car.destroy){goto case "carfail"}public void graphic(Graphiceventags , e)case "carfail":e.graphics(Mission Failed , 0.5f , 0.5f)return //What i want now is to make it to return to the beggining of the script

there was a mod called iv side missions by vdh net. i have'nt understand exactly its codes but the scripting is very bad. like if you destroy the car the mission will continue also even if you die,

 

So I have think so much about the methods of getting in car and these things. my problem i don't know how to make it return to start of the mission. also if the mission finished the mission will vanish and so on. I think missions is better with c++ but i don't know how to use SCOCL. (i have visual studio ultimate) i have opened Scocl.exe it shows me global seg version is not set and turns off as i already set the commandline for gta iv. i open Scocdle.exe but it is useless. So i need help. and also i cannot download aru's c++ SDK.. because his website is not working now.

Sorry if disturb you. Ignore me if you don't want to help

Link to comment
Share on other sites

What language is this supposed to be?

Link to comment
Share on other sites

Spaghetti code, argh.

Don't use goto, no one likes it, I don't know the parameters for that function as I haven't use the graphics stuff but you could simply go there by calling the function/method by using

if(car.destroy){     graphic(parameters)}
Edited by Noox
Link to comment
Share on other sites

Uhm, I don't think you understood how return works.

You see that void right there? that means you're not returning values/objects, you can use return; to leave the function though.

(you're missing some basic programming knowledge)

I don't know how to explain it so I'll make an example.

int add(int number) //in this case number is storing the value x is storing{    return number + 1; //it returns the value stored in number + 1, which is 4}int main(){    int x = 3; //1) variable X is declared, it stores 3    int y = add(x); //variable Y is declared and the function add is called, x is given as a parameter and Y will have 4 as value in the end    cout<<y<<endl; //prints 4}

(I made it in C++ since I don't know the standard C# template as I'm using it just for GTA)

What that does is simple, I declared a variable with a default value of 3, then I declared one more which calls the function "add" that takes a number as a parameter, I gave that function x.

The CPU jumps to the code of the function, int number is the parameter (passed by value and not by reference) which is storing the value of x (3 in this case), it returns x + 1 (3 + 1) so y will store 4 when the function is done, the output (cout) will be 4.

 

return doesn't mean you can "return" back to somewhere in the script.

Edited by Noox
Link to comment
Share on other sites

Maro Hannover

Ok how do i return to somewhere in the script and how do i use Scocl

Link to comment
Share on other sites

Ok how do i return to somewhere in the script and how do i use Scocl

You can use goto but I think you'll use it somewhere else as well lol just post all the code so we can see what can be done.

Edited by Noox
Link to comment
Share on other sites

Generally speaking, if you have to use goto in higher-level languages, it means you're doing something wrong.

Link to comment
Share on other sites

Generally speaking, if you have to use goto in higher-level languages, it means you're doing something wrong.

Indeed, that's why I asked him to post the entire script.

 

Maro I gave a look at some SCO scripts and I don't think it's easy to use it, references are in there.

Edited by Noox
Link to comment
Share on other sites

So stop making fun or will ban you

Go ahead.

 

 

Seriously speaking, look again at this code. IT. IS. WRONG. So stop trying to prove us false and go f*cking learn the basics.

 

EDIT:

Damn, wrong topic. Thought it's the IV Coding one. Consider it related to this one instead.

 

EDIT2:

I moved it here as it seems more appropriate.

Edited by Silent
  • Like 1
Link to comment
Share on other sites

silent why you disrespect me much why do you hate me?

lol he said nothing offensive, it's a fact, goto is a bad statement, if you use many the code will be impossible to read because you won't understand a single thing and it will look ugly, the only language where goto (JMP in that case) needs to be used is Assembly.

Edited by Noox
Link to comment
Share on other sites

goto is a bad statement, if you use many the code will be impossible to read because you won't understand a single thing and it will look ugly.

Not to mention it can skip some variable declarations, breaking the code.

Link to comment
Share on other sites

Maro post all the script so we can help, we have to see what it does before we can tell you how to go to the start as we don't know how you're managing stuff.

Edited by Noox
Link to comment
Share on other sites

 

goto is a bad statement, if you use many the code will be impossible to read because you won't understand a single thing and it will look ugly.

Not to mention it can skip some variable declarations, breaking the code.

 

if you know how to use it right, i've seen lcpdfr .net script use "goto" alot, but not sure about the new version by LMS...

Edited by hardsty1e
Link to comment
Share on other sites

Anyway Maro if you want a friendly tip go back and keep reading the C# guide you were following, I started to code IV yesterday and I am not having much troubles mostly because I knew the basics about programmings, things wrong in your code:

 

1) Missing brackets in the second function

2) Parameters are completely wrong, C/C++/C# are case sensitive that means A is not a, Graphicseventargs must be GraphicsEventArgs, also you forgot to give the first parameter a name and the second has no type, just an useless name which means nothing and the game will tell you "hey, stop, there is a guy I don't know (the first parameter in this case as it has no name) and someone I haven't invited (second parameter as it has no type and the game doesn't know what it is)

Maybe you didn't want to write the point/comma...

3) case "carfail" is absolutely wrong, you use the keyword case if you are using a switch, you use a switch when you have many IFs, instead of doing this

 

 

 

if(x == 0)//somethingif(x == 1)//somethingif(x == 2)//somethingif(x == 3)

 

 

 

you write this

 

 

 

switch(x){    case 0:        //something        break; //you always have to write break    case 1:        //something        break;    case 2:        //something        break;    case 3:        //something        break;    default: //default is an else, you use it if x not 0, 1, 2 or 3        //something        //break not needed}

 

 

 

if you want to use goto you write this

 

goto carfail

 

and instead of writing case "carfail" you simply write carfail: but as we told you goto is not good at all.

 

4) The graphics function (e.Graphics), I never used it but I'm sure the first parameter needed is a string (correct me if I'm wrong) so you should write "Mission failed"

 

You should at least learn loops (foreach is the one you'll use more I think) arrays (if you use them the for loop is good to speed things up) and functions.

Edited by Noox
Link to comment
Share on other sites

Why do you absolutely want to code like in SA?

 

Maybe try something more like this?

//Put this boolean out of any functionsbool showMissionFailed = false;//Put this in a timerif (!justaCar.isAlive || !justaCar.isDriveable || justaCar.Health < 1)            {                showMissionFailed = true;            }//Put this in your PerFrameDrawingif (showMissionFailed)            {                e.Graphics.DrawText("Missions failed", 20, 20, System.Drawing.Color.Red);            }
Link to comment
Share on other sites

Maro Hannover

Thank you very much letsmodordy you are a very nice guy. But i thing you forgot something in this line

if (showMissionFailed)

i think it should be

if (showMissionFailed = true)

Correct me if i am wrong

@Nordi

You started Modding yesterday whyle i started october 2011. Kinda Wierd????????

Edited by Maro Hannover
Link to comment
Share on other sites

Thank you very much letsmodordy you are a very nice guy.

@Nordi

You started Modding yesterday whyle i started october 2011. Kinda Wierd????????

Nordi? :panic:

 

Back to the serious stuff, I saw your topics and by the errors above you have no programming knowledge.

Also, not only I started modding 2 days ago but I started to learn programming in september at school with C++ and the only things I know are basic stuff such as if, loops, arrays, bidimensional arrays, functions and I/O with text files with some dynamic memory allocation knowledge.

What I'm trying to say is, learn the basic stuff, mod later, really, by modding GTA with .NET after you learn those basic things which will take you not more than 3 months to understand you will feel like home because you could easily mod with just functions and conditions.

You're missing programming logic.

Edited by Noox
Link to comment
Share on other sites

Maro Hannover

No you are wrong Nordi.

I am 13 years old and i learn from internet. if you don't believe me i swear i know all the basics. I am always thinking about it when i am sleeping. The only thing that makes you think like that is i don't write correctly what i want exactly. My english is good but i am getting much Tension when posting here and i am also writing very fast so you cn see my words are not very sense-full

Link to comment
Share on other sites

This code says otherwise

if(car.destroy){goto case "carfail"}public void graphic(Graphiceventags , e)case "carfail":e.graphics(Mission Failed , 0.5f , 0.5f)return //What i want now is to make it to return to the beggining of the script

Anyway we'd better get back in topic if we don't want to get this locked :)

Link to comment
Share on other sites

Thank you very much letsmodordy you are a very nice guy. But i thing you forgot something in this line

if (showMissionFailed)
i think it should be
if (showMissionFailed = true)
Correct me if i am wrong

@Nordi

You started Modding yesterday whyle i started october 2011. Kinda Wierd????????

It was correct the first time. Put it into Visual Studio and it won't get any errors ;)

foiYMqM.png

No offense, but I would say a noob. You haven't been working on IV since 2011. A guy who has been on the modding scene for 2 days has a better knowledge than you do with IV modding. Edited by LetsPlayOrDy
  • Like 2
Link to comment
Share on other sites

if you put an equal into an if statement you have to write == not =.

Anyway with boolean variables variable == true or variable is the same thing, instead of writing if(variable == false) you can simply write if(!variable) because ! means not.

Link to comment
Share on other sites

Basically what he is saying, is that

if (boolean) { }

is the same thing as

if (boolean == true) { }

and

if (!boolean) { }

is the same thing as

if (boolean == false) { }
Link to comment
Share on other sites

But can you help me with SCOCL

Check this out...

 

To create missions you don't need SCO! With .Net languages (VB, C#) you can get best results.

BUT if you want to recreate original missions you have to learn C... Try SCOCL to code new stuff or SCOToolBox (low level format like ASM) to edit original sources...

Link to comment
Share on other sites

Maro Hannover

@Letsplyordy

When i started programming i was 8-9 years(In gta san andreas not IV) and i did not know this is called programming so first compare my age with noox or nordi

Link to comment
Share on other sites

Maro Hannover

U don't understand.

i look like a noob because my school is english like Skopro. I am getting too much tension when posting and i am typing too fast so i should not be accurate in talking. My c# is very good but i don't look like because of this two bloody things.

 

Shyness

and

 

Tension

So Please i also have feelings and your speech hurts me more than anyone in this forums,

 

 

Age means nothing.

Ok go back to ice age and stay there for 3 years and come back. Will you remeber c# as now?

 

another example.

you are 16 years and i am 13 years. If you take exams of mine you will get full mark but if i examined yours i will get 0,

Why?

Because you studied it before but yet i have not studied yours.

 

You learned programming from college.

i am in school and i learn c# alone.

 

it is possible me and rugz007 are the only programmers(Semi-Pro)who are less than the age of 14.

Edited by Maro Hannover
  • Like 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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.