Help for scripters (One topic - all questions)

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
Post Reply
Logofero
Serial Killer
Serial Killer
Posts: 264
Joined: 09 Dec 2015, 14:18
Location: Russia, Gelendzhik
Contact:

Help for scripters (One topic - all questions)

Post by Logofero »

I have a number of questions:
Ask and Answer a question here of scripting in GTA 2.
  • 1. Is it possible create a NEW -> set -> show dynamic display a long text (as in http://gtamp.com/images/gta2pedhealth.jpg)?
    2. Is it possible declare a variable and store text (in string) into memory and write others varible?

    Code: Select all

    // Pseudo code: 
    STRING string = "text 1" 
    SET string = "text 2"
    
    3. Can I show/hide ID http://gtamp.com/images/gta2pedhealth.jpg only one player, not all?
    4. Can I show/hide the DISPLAY_BRIEF(ID) only one player, not all?

    Code: Select all

    // Pseudo code:
    ShowDialog(player1, ID)
    HideDialog(player1, ID)
    
    5. Is it possible to extend the limit of OBJECTS/CARS/CHARREMAPS/WEAPONS have asked in this topic http://gtamp.com/forum/viewtopic.php?f=4&t=814#p9568
    6. How to get the square root?

    Code: Select all

    // Pseudo code:
    value = sqroot(9)
    7. How other methods (http://gtamp.com/forum/viewtopic.php?f=4&t=804) of a random number?

    Code: Select all

    // Pseudo code:
    value = random(MIN, MAX)
    8. How get CAR/CHAR/OBJECT ID from area x, y, z?

    Code: Select all

    // Pseudo code:
    carid = GetCarID(x, y, z)
    charid = GetCharID(x, y, z)
    objid = GetObjectID(x, y, z)
    
    9. How get start time my server in milliseconds (through memory)?
    10. Is it possible (through memory) read/write get rotation/position of tank turret?
    11. Is it possible (through memory) attached objects: object1 to object2 or object1 to car?
    12. Arrays that possible? As can be this through memory?
    13. Can be compile the script *.MIS to *.SCR in command line?
    This example compiles in "C:\" files appear: mission.SCR, mission.TXT, mission.TMP, but mission.SCR does not work, and always weighs 48kb
    compile.bat:

    Code: Select all

    @echo off
    C:\miss2.exe C:\mission.mis
    pause
    
    14. What command/arguments knows the compiler GTA2script Compiler V9.6\miss2.exe -help -input "..." -i "..." -output "..."?
NOTE:
The topic will be expanded.
The most suitable answers will be given in the references.
If you know the answer to these questions are answered, do not hesitate.
Any help would be appreciated.
Last edited by Logofero on 12 Dec 2015, 08:06, edited 1 time in total.

User avatar
Sektor
Boss
Boss
Posts: 1391
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Help for scripters (One topic - all questions)

Post by Sektor »

1. Is it possible create a NEW -> set -> show dynamic display a long text (as in http://gtamp.com/images/gta2pedhealth.jpg)?
gta2script doesn't have string support, so string manipulation would require a lot of counters and script commands and would only be able to work on one byte at a time. I don't know the memory addresses for all strings but this might help: https://github.com/Bytewerk/gta2-hacker ... ngame-text

2. Is it possible declare a variable and store text (in string) into memory and write others varible?
Same answer as 1.

3. Can I show/hide ID http://gtamp.com/images/gta2pedhealth.jpg only one player, not all?
Yes but I don't know the memory addresses. You can enable do_show_ids by changing a byte at 0x5EADA1 (this way you could tick show IDs using gta2script even if the player forgot to tick it).

4. Can I show/hide the DISPLAY_BRIEF(ID) only one player, not all?
This code will let you DISPLAY_BRIEF to a specific player: http://gtamp.com/forum/viewtopic.php?p=9364#p9364

5. Is it possible to add new OBJECTS/CARS/CHARREMAPS/WEAPONS instead of replacing them?
No. It would require major changes to exe/memory. There are some unused graphics that you could replace with your own, so that it won't overwrite used graphics but you can't add unlimited new stuff.

6. How to get the square root?
SIN and COS were added by vike, so maybe he can add sqrt in the next exe version.

7. How other methods (viewtopic.php?f=4&t=804) of a random number?
I added some comments to the pseudo random number script to show how you can set min and max http://gtamp.com/forum/viewtopic.php?f=4&t=804

8. How get CAR/CHAR/OBJECT ID from area x, y, z?
Memory addresses topic has code for reading/writing ped/vehicle/object x,y,z http://gtamp.com/forum/viewtopic.php?f=4&t=700

10. Is it possible (through memory) read/write get rotation/position of tank turret?
Yes, I have found that in cheat engine before but didn't write it down. I will find it again.

11. Is it possible (through memory) attached objects: object1 to object2 or object1 to car?
Yes but I don't know the memory locations.

12. Arrays that possible? As can be this through memory?
Not in gta2script. A better language will be needed.

Logofero
Serial Killer
Serial Killer
Posts: 264
Joined: 09 Dec 2015, 14:18
Location: Russia, Gelendzhik
Contact:

Re: Help for scripters (One topic - all questions)

Post by Logofero »

Sektor, thanks for the reply.

Anyone who knows the answers to the questions - write here.
All this is useful to other Old scooler scripters and attract more people to GTA2
  • 15. Is it possible to declare (through memory) to create and delete OBJECTS/CHARS/CARS?
    16. There was more epic question: Is it possible to create an external engine (for multiplayer) that will use their scripts and work through the memory game (server -> client-side)?

    So you can create your function more flexible and simple syntax + add mathematical expressions such as obtaining the square root, random, without compiling *.SCR.
    17. Can I hide the arrow on ALL player's head in multiplayer?
    18. What are the MAX limits of created OBJECTS/CARS/WEAPONS/PEDS?

User avatar
Sektor
Boss
Boss
Posts: 1391
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Help for scripters (One topic - all questions)

Post by Sektor »

Some great questions. They show the limitations of gta2script. Nearly anything can be done with the memory writing commands, if you can find the memory addresses but even when you have them, the code is messy and hard to read. Adding support for a better scripting language seems like the best long term solution. The hard part is finding someone to do it.

I added some answers to previous list.

Logofero
Serial Killer
Serial Killer
Posts: 264
Joined: 09 Dec 2015, 14:18
Location: Russia, Gelendzhik
Contact:

Re: Help for scripters (One topic - all questions)

Post by Logofero »

Sektor wrote: > 6. How to get the square root?
SIN and COS were added by vike, so maybe he can add sqrt in the next exe version.
Also add directly to obtain the distance between two points

Code: Select all

// Pseudo code:
// 2D Area
distance = GetDistance2DPoints(x1, y1, x2, y2)

// And 3D Area
distance = GetDistance3DPoints(x1, y1, z1, x2, y2, z2)
Thanks for replies Sektor.
Continuing to add interesting questions. :idea:
  • 19. Is it possible to repaint Object as a Car (through memory)?
    Example: If you create new Tank for can be painted (color 0-35), tower tank Do not paint.

    20. Creating a multi-language version. Upload font from NEW *.sty by GM is it possible?
    Into: The GTA first series is 1st problem always seemed fonts/language. All languages have their own special character, but when you consider the difference that you can fix it.
    Now in GTA2 to replace the fonts need to find them in will.sty, bill.sty, ste.sty and replace each character. What if you take and make your font file fstyle.sty as GTA1 it will be much easier

User avatar
T.M.
Immortal
Posts: 957
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: Help for scripters (One topic - all questions)

Post by T.M. »

Logofero wrote:6. How to get the square root?
Most of the time square root can be taken out from calculations as long as you make every other calculation in second power.

For example if you want to check if a distance from point A to point B is less than 37:

Code: Select all

if( (A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y) < 37*37){
    // do something
}
Or if you want to use square root:

Code: Select all

if( sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y)) < 37){
    // do something
}

Logofero
Serial Killer
Serial Killer
Posts: 264
Joined: 09 Dec 2015, 14:18
Location: Russia, Gelendzhik
Contact:

Re: Help for scripters (One topic - all questions)

Post by Logofero »

Thanks T.M.
Continue again 8-)
  • 21. Load/Save the text file is that possible? It would be good to create statistics on the server.

User avatar
Sektor
Boss
Boss
Posts: 1391
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Help for scripters (One topic - all questions)

Post by Sektor »

Logofero wrote:
  • 21. Load/Save the text file is that possible? It would be good to create statistics on the server.
According to the manual, there's a limit of 300 SAVED_COUNTERs, so enough for some statistics but not enough for an epic in game level editor. I've never tested the limit.

If you SAVE_GAME () then all the values in SAVED_COUNTER variables are saved. You will need to specify the filename of an existing save game in the debug gta2 manager tab or in the registry. If it's not in gta2\player then you will have to give a relative path, like ..\data\test.svg. I really should add mmp filename based save game support to Game Hunter.

edit: I just tested loading a save in multiplayer with 2 players but unfortunately it makes both players start in the exact same location and causes crashes. This will need an exe fix unless there's something that can be patched in the actual save game. I tried to work around it with GTA2 scripting by changing each player coordinate in memory but the saved position overrides and still crashes the game.

User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: Help for scripters (One topic - all questions)

Post by elypter »

Logofero wrote: 17. Can I hide the arrow on ALL player's head in multiplayer?
you can remove the arrows in the sty file. its been done here http://gtamp.com/mapscript/maplist/list ... noarrow.7z
yur sa'nok ngeyä

User avatar
Sektor
Boss
Boss
Posts: 1391
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Help for scripters (One topic - all questions)

Post by Sektor »

elypter wrote:
Logofero wrote: 17. Can I hide the arrow on ALL player's head in multiplayer?
you can remove the arrows in the sty file. its been done here http://gtamp.com/mapscript/maplist/list ... noarrow.7z
That was before I knew about the power of the SET command.

Here's how to remove player arrows in GTA2 script. It creates a scripted arrow and then subtracts 124 from it to find a player arrow.

[mis]
//This script removes the player arrows
PLAYER_PED p1 = (117.0,133.5,255.0) 10 270 // Red
PLAYER_PED p2 = (118.0,133.5,255.0) 09 090 // Orange
PLAYER_PED p3 = (117.5,132.5,255.0) 07 180 // Yellow
PLAYER_PED p4 = (117.5,134.5,255.0) 11 000 // Green
PLAYER_PED p5 = (117.0,132.5,255.0) 13 225 // Blue
PLAYER_PED p6 = (118.0,134.5,255.0) 08 045 // Black

COUNTER loop = 1
COUNTER playerarrow = 0
COUNTER arrowoffset = 0

ARROW_DATA arrow

LEVELSTART

POINT_ARROW_AT (arrow, p1)
REMOVE_ARROW (arrow)

SET arrowoffset=-124
SET playerarrow=(arrow+arrowoffset)
REMOVE_ARROW (playerarrow)
SET arrowoffset=-248
SET playerarrow=(arrow+arrowoffset)
REMOVE_ARROW (playerarrow)
SET arrowoffset=-372
SET playerarrow=(arrow+arrowoffset)
REMOVE_ARROW (playerarrow)
SET arrowoffset=-496
SET playerarrow=(arrow+arrowoffset)
REMOVE_ARROW (playerarrow)
SET arrowoffset=-620
SET playerarrow=(arrow+arrowoffset)
REMOVE_ARROW (playerarrow)

WHILE_EXEC (loop = 1)

DO_NOWT

ENDWHILE

LEVELEND

[/mis]

User avatar
Sektor
Boss
Boss
Posts: 1391
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Help for scripters (One topic - all questions)

Post by Sektor »

You can add the player arrows back again by writing 6 to byte 64 of the arrow address

[mis]

COUNTER arrowon=6
COUNTER arrowonaddress


IF (CHECK_CHAR_CURR_WEAPON(p1,PISTOL))
SET arrowoffset=-124
SET playerarrow=(arrow+arrowoffset)
SET arrowonaddress=(playerarrow+64)
CHANGE_GANG_CHAR_RESPECT (arrowonaddress,arrowon,111)
SET arrowoffset=-248
SET playerarrow=(arrow+arrowoffset)
SET arrowonaddress=(playerarrow+64)
CHANGE_GANG_CHAR_RESPECT (arrowonaddress,arrowon,111)
SET arrowoffset=-372
SET playerarrow=(arrow+arrowoffset)
SET arrowonaddress=(playerarrow+64)
CHANGE_GANG_CHAR_RESPECT (arrowonaddress,arrowon,111)
SET arrowoffset=-496
SET playerarrow=(arrow+arrowoffset)
SET arrowonaddress=(playerarrow+64)
CHANGE_GANG_CHAR_RESPECT (arrowonaddress,arrowon,111)
SET arrowoffset=-620
SET playerarrow=(arrow+arrowoffset)
SET arrowonaddress=(playerarrow+64)
CHANGE_GANG_CHAR_RESPECT (arrowonaddress,arrowon,111)
ENDIF
[/mis]

Post Reply