Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    2. GTANet 20th Anniversary

    1. GTA Online

      1. The Cayo Perico Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

      1. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

      1. Court House
    3. Suggestions

Problems with GTA2 script will never stop


QuentinVance

Recommended Posts

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.

Link to post
Share on other sites

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.

Edited by Sektor
Link to post
Share on other sites

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.

Link to post
Share on other sites
PLAYER_PED sektor = (64.0, 53.0, 255.0) 25 0PARKED_CAR_DATA rookiebulwark = (65.0, 53.0, 255.0) 0 0 GT24640COUNTER true = 1COUNTER rupistol_taken = 0LEVELSTARTWHILE_EXEC (true = 1)IF ((IS_CHARACTER_IN_CAR(sektor,rookiebulwark)) AND (rupistol_taken = 0))  GIVE_WEAPON (sektor, PISTOL, 15)  SET rupistol_taken = 1ENDIFENDWHILELEVELEND

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

Edited by Sektor
Link to post
Share on other sites

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.

Edited by QuentinVance
Link to post
Share on other sites

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.

Edited by Sektor
Link to post
Share on other sites

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.

Link to post
Share on other sites

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.

Edited by Sektor
Link to post
Share on other sites

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...

  • Like 1
Link to post
Share on other sites
  • 1 month later...

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
  • 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.