Quantcast

Jump to content

» «
Photo

Problems with GTA2 script will never stop

9 replies to this topic
QuentinVance
  • QuentinVance

    Russian Gangster

  • Members
  • Joined: 28 Mar 2015
  • Italy

#1

Posted 09 September 2015 - 01:12 PM

Hi there! I've recently started working on my custom level again, and of course I'm having problems scripting some actions.

For example, I'm trying to give the player a pistol when he gets in a car I've previously created

 

This is the code I'm currently using:

COUNTER rupistol_taken = 0
//OTHER STUFF
  WHILE ((IS_CHARACTER_IN_CAR(rookiebulwark, QUENTIN)) AND (rupistol_taken = 0)))
     GIVE_WEAPON (QUENTIN, COLLECT_00, 15)
     SET rupistol_taken = 1
  ENDWHILE

Of course, it doesn't work.

After trying for about an hour and changing random parts of the code (I'm using THIS DOCUMENT as an example) I managed to make the code "work", but I also had to change COLLECT_00 to PISTOL, which allows me to compile the code. However, once in the game, it doesn't work.

 

Now, I know this is normal because GTA2 code doesn't follow any logic rule and code may (not) work depending of totally random facts like the number of clouds in the sky, but I would like to find an explanation to this, if it is possible to find any. Probably the code I'm using now is totally wrong, but I've been working on it for a lot of time, and I even managed to get it compiled and it was pretty similiar to this.


Sektor
  • Sektor

    GTAMP.com

  • GTA Series Staff
  • Joined: 28 Jan 2003
  • None

#2

Posted 09 September 2015 - 01:40 PM Edited by Sektor, 09 September 2015 - 01:46 PM.

WHILE ((IS_CHARACTER_IN_CAR(rookiebulwark, QUENTIN)) AND (rupistol_taken = 0))) will check once and then stop since it's going to be false on LEVELSTART.
 
If you don't have an infinite while loop around WHILE ((IS_CHARACTER_IN_CAR(rookiebulwark, QUENTIN)) AND (rupistol_taken = 0))) then you should add one, like COUNTER true=1, WHILE_EXEC (true=1)
 
The order looks backwards, it should be WHILE ((IS_CHARACTER_IN_CAR(QUENTIN,rookiebulwark)) AND (rupistol_taken = 0))).
 
I'd use an IF statement instead but WHILE might work.


QuentinVance
  • QuentinVance

    Russian Gangster

  • Members
  • Joined: 28 Mar 2015
  • Italy

#3

Posted 09 September 2015 - 04:55 PM

I tried using a IF before, and that didn't work. I will try it now witht the IF again. Do I still neet to put it inside a WHILE_EXEC ? Because it actually was, as you told me in a previous post.

Also, I tried to put (QUENTIN, rookiebulwark) instead of (rookiebulwark, QUENTIN) and that didn't work.

 

The problem is that I did it exactly as you're suggesting now, but that just didn't let me compile.


Sektor
  • Sektor

    GTAMP.com

  • GTA Series Staff
  • Joined: 28 Jan 2003
  • None

#4

Posted 10 September 2015 - 03:28 PM Edited by Sektor, 10 September 2015 - 03:32 PM.

PLAYER_PED sektor = (64.0, 53.0, 255.0) 25 0
PARKED_CAR_DATA rookiebulwark = (65.0, 53.0, 255.0) 0 0 GT24640

COUNTER true = 1
COUNTER rupistol_taken = 0

LEVELSTART

WHILE_EXEC (true = 1)

IF ((IS_CHARACTER_IN_CAR(sektor,rookiebulwark)) AND (rupistol_taken = 0))
  GIVE_WEAPON (sektor, PISTOL, 15)
  SET rupistol_taken = 1
ENDIF

ENDWHILE

LEVELEND

This worked for me.  It also works with WHILE/ENDWHILE instead of IF/ENDIF but that's not my style.

  • Fireman likes this

QuentinVance
  • QuentinVance

    Russian Gangster

  • Members
  • Joined: 28 Mar 2015
  • Italy

#5

Posted 10 September 2015 - 05:06 PM Edited by QuentinVance, 10 September 2015 - 05:19 PM.

Okay, it works. I'm sorry, it was my fault. I didn't put it inside LEVELSTART.

Now I'm trying to make two other characters appear in a certain part of the map right after I pick up two people with the car (I don't know if you remember my other post).

So, these two guys should act as guards, and the player just needs to kill them using the car or the pistol provided with it. The problem is, I can't find a way to make these two guys appear in the game.

 

I have an "objective" variable, which I set to 1 after I pick the first two guys with the car. Then, I should make the two other characters spawn at a certain location. I've declared them as zoperative1 and 2, then I use this code inside the LEVELSTART:

  WHILE (objective = 1)
     zoperative1 = CREATE_CHAR (94.5 , 153.5 , 2.0) 8 90 GUARD_AGAINST_PLAYER END
     SET_CHAR_THREAT_SEARCH (zoperative1, AREA_PLAYER_ONLY)
     SET_CHAR_THREAT_REACTION (zoperative1, REACT_AS_NORMAL)
     zoperative2 = CREATE_CHAR (94.5 , 154.5 , 2.0) 8 90 GUARD_AGAINST_PLAYER END
     SET_CHAR_THREAT_SEARCH (zoperative2, AREA_PLAYER_ONLY)
     SET_CHAR_THREAT_REACTION (zoperative2, REACT_AS_NORMAL)
  ENDWHILE

Which I thought would create two guards. However, they don't spawn at all!
I've also tried to use the same code before LEVELSTART, and tried to set their behaviour before the LEVELSTART and making them spawn in the LEVELSTART (which led me to a game crash).

EDIT: I've noticed that I can make them work simply putting the whole code before LEVELSTART, but I need them to appear ONLY after the var objective has been set to 1.

 

Now, I don't know how to go on. I feel like the game's kidding me, every single thing I do requires me to ask for help because just following instructions doesn't make the code work.

I'm sorry for wasting your time.

  • Fireman likes this

Sektor
  • Sektor

    GTAMP.com

  • GTA Series Staff
  • Joined: 28 Jan 2003
  • None

#6

Posted 11 September 2015 - 12:39 PM Edited by Sektor, 11 September 2015 - 12:40 PM.

It probably crashes because it constantly tries to create them.  You should only create them again if they die or you delete them.  Try adding a SET objective = 0 inside WHILE (objective = 1) or add a new check to make sure the CREATE_CHAR command only runs once.


QuentinVance
  • QuentinVance

    Russian Gangster

  • Members
  • Joined: 28 Mar 2015
  • Italy

#7

Posted 18 September 2015 - 02:33 PM

I've been trying to make this work lately. It just does not make sense. There is no way to create those two during the mission, any single way I tried produced the same result: nobody spawning at all, no matter where I put the code or how. I can use three variables or use none, put them before or after LEVELSTART, but THAT-WILL-JUST-NOT-WORK.

 

This programm is totally messed up, just makes me go crazy. It's a sh*tty piece of code I could make even better, I know how it works and how it should be used, but it just doesn't work.

I've got half a city, perfectly working and full of details. Made it from a blank map. And I now have a useless piece of code that just doesn't work without a reason.

I've created a code to check if you got the gun inside the car at the beginning of the job: it works twice, then you get the gun's ammo every time you start the mission (first it used to bug at the second time you start). The guys don't show up, the car can't be jumped over by anyone and glitches characters when they touch it... totally random stuff is happening.


Sektor
  • Sektor

    GTAMP.com

  • GTA Series Staff
  • Joined: 28 Jan 2003
  • None

#8

Posted 18 September 2015 - 04:13 PM Edited by Sektor, 03 October 2015 - 10:27 AM.

Post the whole script and I'll fix it.  It works fine if you know what you are doing.

 

Maybe you are spawning a vehicle on top of another vehicle.

 

edit: it was the PARK command causing problems, that should only be run once and only when the car is near a door.  If you run it many times on a car that doesn't have a player it will do strange things like stop the playing from jumping over the car.


QuentinVance
  • QuentinVance

    Russian Gangster

  • Members
  • Joined: 28 Mar 2015
  • Italy

#9

Posted 18 September 2015 - 04:52 PM

No double vehicles, I can still drive it if I press the Enter button before running towards it. However, the whole code is too long to post here, if you don't mind I'll send you the whole script in private as soon as I can.

 

Please don't get the wrong idea of me, I actually know how to code and I've also made a few games. The problem is... I totally don't understand how GTA2's code works, so I don't know where to put my hands. There's so much stuff that sounds rasonable to do in a way and the game doesn't accept it...

  • Andrew_Thiago likes this

Andrew_Thiago
  • Andrew_Thiago

    http://dyom.gtagames.nl/profile/12409

  • Members
  • Joined: 15 Feb 2015
  • Brazil

#10

Posted 26 October 2015 - 12:51 AM Edited by Andrew_Thiago, 26 October 2015 - 12:52 AM.

Quentin vance, can you help me on my post? That's what i don't understand: the code makes sense but the game say that not! 

 

http://gtaforums.com...scripting-help/





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users