Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (86,058 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

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

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

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

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

    2. Site Suggestions

Sign in to follow this  
TheGreg

Newbie coding problems.

Recommended Posts

TheGreg

Hey, i got into coding just two days ago and today i wanted to write my own little code. It's not anything fancy, it's just a very simple code that's supposed to toggle thermal vision when holding the backspace button. The problem is: when i start GTA, the code doesn't quite work how it's supposed to. Once i press the backspace button, the thermal vision effect stays on for quite some time, even though i'm not pressing it. Then the effect randomly goes away. I tried correcting the code, looking for errors, but i couldn't find any. Sometimes it would work, sometimes it would just crash the game or freeze it. So i thought that maybe you guys could tell me what i did wrong. Here's the code.

 

{$CLEO .cs}

:Shekels
03A4: name_thread "SHEKELS"
:Shekels_1
0001: wait 0 ms
if
0256: player$PLAYER_CHAR defined
004D: jump_if_false @Shekels_1
if
0AB0: key_pressed 8
004D: jump_if_false @Shekels_1
08B2: toggle_thermal_vision 1
:Shekels_2
0001: wait 0 ms
if
0256: player$PLAYER_CHAR defined
004D: jump_if_false @Shekels_2
if
8AB0: not key_pressed 8
004D: jump_if_false @Shekels_1
08B2: toggle_thermal_vision 0
004E: end_thread

 

Share this post


Link to post
Share on other sites
ZAZ

there's a mistake in your script

 

the Global Var: $PLAYER_CHAR must be separated from other charackters

 

your code line:

 

 

0256: player$PLAYER_CHAR defined

there must be space between the description "player" and the Global Var "$PLAYER_CHAR"

 

 

0256:   player $PLAYER_CHAR defined

then play around with wait codes, let the script wait for some seconds after the change

 

08B2: toggle_thermal_vision 1wait 3000
and change the keypress check in 2.Loop

 

{$CLEO .cs}  :Shekels03A4: name_thread "SHEKELS" :Shekels_1// 1. Loop0001: wait 0 msif0256: player $PLAYER_CHAR defined004D: jump_if_false @Shekels_1if0AB0: key_pressed 8     004D: jump_if_false @Shekels_108B2: toggle_thermal_vision 1// play around with wait codes after the changewait 3000 :Shekels_2// 2. Loop0001: wait 0 msif0256: player $PLAYER_CHAR defined004D: jump_if_false @Shekels_2if0AB0: key_pressed 8// change it to normal keypress004D: jump_if_false @Shekels_2// <-- let it jump to 2. Loop08B2: toggle_thermal_vision 0  004E: end_thread

Share this post


Link to post
Share on other sites
In45do

Isn't it supposed to be 0A93: end_custom_thread instead of 004E: end_thread ?

Share this post


Link to post
Share on other sites
TheGreg

Isn't it supposed to be 0A93: end_custom_thread instead of 004E: end_thread ?

Well, since i'm a newbie at coding, i'm not really able to tell the difference between them. I tried using both, but with the 0A93 opcode it would crash the game when i press the key. But then again, i think it's because of some error in the code that makes the game crash if i press the backspace button and any other button at the same time. I'm not really sure, i'll try to add a wait code to the script to see if it'll work.

Share this post


Link to post
Share on other sites
In45do

I was thinking the same as you did. But I follow what ZAZ suggest on his tutorial guide. (GTA SA version) ;):^:

Share this post


Link to post
Share on other sites
TheGreg

Alright, i did as Zaz said and changed the keypress code to a normal one (00E1), but when i start the game, the code doesn't work at all. By the way, is there any difference between the 0AB0 and the 00E1 opcodes?

 

{$CLEO .cs}

:Shekels
03A4: name_thread "Shekels"
:Shekels_1
0001: wait 0 ms
if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @Shekels_1
if
00E1: player 0 pressed_key 8
004D: jump_if_false @Shekels_1
08B2: enable_thermal_vision 1
wait 2000 ms
:Shekels_2
0001: wait 0 ms
if
0256: player $PLAYER_CHAR defined
004D: jump_if_false @Shekels_2
if
80E1: not player 0 pressed_key 8
004D: jump_if_false @Shekels_2
08B2: enable_thermal_vision 0
0A93: end_custom_thread
Edited by TheGreg

Share this post


Link to post
Share on other sites
In45do

Known the difference here.

Share this post


Link to post
Share on other sites
Ify24

{$CLEO .cs}

thread "Shekels"

 

:Shekels_11

wait 0

if and

Player.Defined($PLAYER_CHAR)

0AB0: key_pressed 0x8

jf @Shekels_11

08B2: enable_thermal_vision 1

wait 1500 ms

:Shekels_46

wait 0

if and

Player.Defined($PLAYER_CHAR)

0AB0: key_pressed 0x8

jf @Shekels_46

08B2: enable_thermal_vision 0

wait 1500 ms

jump @Shekels_11

 

Here you go :) Edited by Silent

Share this post


Link to post
Share on other sites
Silent

^ I've been rude enough to edit the previous post, removing one useless thing from the script.

Share this post


Link to post
Share on other sites
ZAZ

sorry, i didn't notice the wrong end_thread, 0A93: end_custom_thread is right.

Ify24 gave a propper script and changed end_thread with a jump back to script beginn
This is your next step: jump back to script beginn instead end_thread to let the script repeating instead ending

BTW. Ify24 recompiled the script with option "no opcodes"
this will change the opcode syntax into classes syntax

with opcode0256: player $PLAYER_CHAR defined
as classesPlayer.Defined($PLAYER_CHAR)

have a look to Sannybuilder options and also to Sannybuilder > Help > Coding > Classes

 

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

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