Quantcast

Jump to content

» «
Photo

[SA] Simple script not working

3 replies to this topic
Danikov
  • Danikov

    The Fake Russian

  • Members
  • Joined: 27 Aug 2009
  • Israel

#1

Posted 31 December 2013 - 09:16 PM

I am trying to achieve slower game speed whenever the player presses RMB + X ,but my script doesn't do anything.

 

This is the first time I am working with memory addresses,so I cannot tell what I am doing wrong.

 

Here's the script :

{$CLEO .cs}
    
0000:
while true
  wait 0 
  0A8D: 1@ = read_memory 0x00969110 size 4 virtual_protect 0 
  if
  0256: player $PLAYER_CHAR defined
  then
  if
  044B: actor $PLAYER_ACTOR on_foot
  04A4: 1@ == 0x0258 // RMB + X
  then
  015D: set_gamespeed 0.25
  0A8C: write_memory 0x00969110 size 4 value 0 virtual_protect 0 
  end
  
  if
  044B: actor $PLAYER_ACTOR on_foot
  04A4: 1@ == 0x0258 // RMB + X
  then
  015D: set_gamespeed 1.0
  0A8C: write_memory 0x00969110 size 4 value 0 virtual_protect 0 
  end
end
0A93: end_custom_thread m_thread

OrionSR
  • OrionSR

    Chain Game Development Team

  • Members
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#2

Posted 31 December 2013 - 11:11 PM Edited by OrionSR, 31 December 2013 - 11:20 PM.

One thing jumps out right away, you are using IF instead of IF AND for multiple conditions. The scripting language for SA is very primitive. You can decompile your script to get rid of any of the higher level stuff like WHILE that Sanny translates into the specific opcodes used in the script.

 

Trying to follow the script logic... it looks like the version above, if the IF AND stuff is fixed and the button combo is pressed and works correctly, will set .25 game speed and then immediately set it back to 1.0.

 

This script will run super fast with only a 0 wait, and will probably execute dozens of times during the time it takes to quickly press and release the proper button combo. You may want to execute when the combo is released.


Danikov
  • Danikov

    The Fake Russian

  • Members
  • Joined: 27 Aug 2009
  • Israel

#3

Posted 01 January 2014 - 01:35 AM

One thing jumps out right away, you are using IF instead of IF AND for multiple conditions. The scripting language for SA is very primitive. You can decompile your script to get rid of any of the higher level stuff like WHILE that Sanny translates into the specific opcodes used in the script.
 
Trying to follow the script logic... it looks like the version above, if the IF AND stuff is fixed and the button combo is pressed and works correctly, will set .25 game speed and then immediately set it back to 1.0.
 
This script will run super fast with only a 0 wait, and will probably execute dozens of times during the time it takes to quickly press and release the proper button combo. You may want to execute when the combo is released.


Ah,I see,thanks for clearing these out!

As for the key combo release,what do you mean,mind explaining in a simple sequence so I can understand how to actually make it work as I want to?

And happy new year!

OrionSR
  • OrionSR

    Chain Game Development Team

  • Members
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#4

Posted 01 January 2014 - 05:50 AM Edited by OrionSR, 01 January 2014 - 05:52 AM.

See example below. Custom mission is started when F7 is pressed ||: wait loop :|| and then released. However, that's more of a preference really. You could also put the code to be executed just before the :wait label to trigger on press instead of release. Sorry I didn't follow my suggestion of working strictly with SA opcodes, but I suspect this example will be a bit more clear.

{$CLEO .cs}
//TestF7.txt
0000:
wait 10

while true
  wait 0
  if
    0AB0:   key_pressed 0x76    // F7
  then
    :Wait
    wait 10
    if
      0AB0:   key_pressed 0x76    // F7
    then
      jump @Wait
    end
    0A94: start_custom_mission "Testing"
  end
end

Hm... I suppose I should finally get around to adding an On Mission check to this key trigger to avoid a few accidental crashes.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users