Quantcast

Jump to content

» «
Photo

an Problem with String Scan

10 replies to this topic
MasterHK
  • MasterHK

    کیان حامی‏

  • Members
  • Joined: 20 Mar 2013
  • Iran

#1

Posted 21 November 2013 - 06:58 AM Edited by MasterHK, 21 November 2013 - 07:00 AM.

0AD4: scan_string 3@ 0@ "XS "
0AD4: scan_string 3@ 0@ "xs "
else_jump @Console_1423
5@ = String.Length(0@)
5@ -= 3
if
5@ > 0
else_jump @Console_1423
6@ = Memory.Alloc(5@)
if or
0AD4: scan_string 3@ 0@ "XS %s" 6@
0AD4: scan_string 3@ 0@ "xs %s" 6@
else_jump @Console_1415
4@ = Memory.VarOffset(4@)                // pIndex
0AB1: call_scm_func @StrLowcase 2 source_string 6@ use_same_buffer 1 // store_to 6@
0AA5: call _sprintf 0x004C5940 _getModelIndexByName num_params 2 pop 2 pIndex 4@ modelName 6@
if or
0488:   model 4@ exists // versionA
07DE:   model 4@ exists // versionB
else_jump @Console_1423
Car.SpawnLikeCheat(4@)
:Console_1415
wait 50
Memory.FreeAlloc(6@)

:Console_1423

It's part of new version of my CheatConsole.

I want that when i enter:

 

XS LANDSTAL

 

it spawn a car with model 400.(in this example)

 

but it make my game crash! :catspider:

 

anyone can help me? :blink:


MasterHK
  • MasterHK

    کیان حامی‏

  • Members
  • Joined: 20 Mar 2013
  • Iran

#2

Posted 22 November 2013 - 09:24 AM

0AD4: scan_string 3@ 0@ "XS "
0AD4: scan_string 3@ 0@ "xs "
else_jump @Console_1423
0D4C: 5@ = string 0@ length
5@ -= 3
if
5@ > 0
else_jump @Console_1423
0AC8: 6@ = allocate_memory_size 5@
if or
0AD4: scan_string 3@ 0@ "XS %s" 6@
0AD4: scan_string 3@ 0@ "xs %s" 6@
else_jump @Console_1415
0AC7: 4@ = var 4@ offset                // pIndex
0AB1: call_scm_func @StrLowcase 2 source_string 6@ use_same_buffer 1 // store_to 6@
0AA5: call _sprintf 0x004C5940 _getModelIndexByName num_params 2 pop 2 pIndex 4@ modelName 6@
if or
0488:   model 4@ exists // versionA
07DE:   model 4@ exists // versionB
else_jump @Console_1423
0ADD: spawn_car_with_model 4@ like_a_cheat
:Console_1415
wait 50
0AC9: free_allocated_memory 6@

:Console_1423

Really nobody? :-?


Danikov
  • Danikov

    The Fake Russian

  • Members
  • Joined: 27 Aug 2009
  • Israel

#3

Posted 22 November 2013 - 12:13 PM

Its been just a day,no need to panic,you'll get an answer eventually.

Silent
  • Silent

    Moderating Cookie Monster

  • Feroci
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#4

Posted 22 November 2013 - 01:17 PM

Where does 0D4C opcode come from?

MasterHK
  • MasterHK

    کیان حامی‏

  • Members
  • Joined: 20 Mar 2013
  • Iran

#5

Posted 22 November 2013 - 02:29 PM

From DK22Pac's NewOpcodes.cleo:

http://www.gtaforums...howtopic=518780


Deji
  • Deji

    Coding like a Rockstar!

  • Feroci
  • Joined: 24 Dec 2007
  • None

#6

Posted 22 November 2013 - 06:35 PM

0AD4: scan_string 3@ 0@ "XS "
0AD4: scan_string 3@ 0@ "xs "
else_jump @Console_1423
5@ = String.Length(0@)
5@ -= 3
if
5@ > 0
else_jump @Console_1423
6@ = Memory.Alloc(5@)
if or
0AD4: scan_string 3@ 0@ "XS %s" 6@
0AD4: scan_string 3@ 0@ "xs %s" 6@
else_jump @Console_1415
4@ = Memory.VarOffset(4@)                // pIndex
0AB1: call_scm_func @StrLowcase 2 source_string 6@ use_same_buffer 1 // store_to 6@
0AA5: call _sprintf 0x004C5940 _getModelIndexByName num_params 2 pop 2 pIndex 4@ modelName 6@
if or
0488:   model 4@ exists // versionA
07DE:   model 4@ exists // versionB
else_jump @Console_1423
Car.SpawnLikeCheat(4@)
:Console_1415
wait 50
Memory.FreeAlloc(6@)

:Console_1423

 

6@ = Memory.Alloc(5@)
if or
0AD4: scan_string 3@ 0@ "XS %s" 6@
0AD4: scan_string 3@ 0@ "xs %s" 6@
else_jump @Console_1415

 

Since we're not working with the efficiency of a proper programming language, both scan_string's will be performed, no matter what. So if the first one returns true and the second false, it'll pass the else_jump. The first scan_string may have stored a result to 6@, but if so, then the second will erase it. Time to use a var to store a bool :p

  • MasterHK likes this

MasterHK
  • MasterHK

    کیان حامی‏

  • Members
  • Joined: 20 Mar 2013
  • Iran

#7

Posted 23 November 2013 - 12:14 PM

Thanks but...

Not effective... :(


Deji
  • Deji

    Coding like a Rockstar!

  • Feroci
  • Joined: 24 Dec 2007
  • None

#8

Posted 23 November 2013 - 12:52 PM

Post the new script and try to post more of it.


MasterHK
  • MasterHK

    کیان حامی‏

  • Members
  • Joined: 20 Mar 2013
  • Iran

#9

Posted 23 November 2013 - 02:12 PM

Link

Console.txt+Classes.db (7-kb)


Deji
  • Deji

    Coding like a Rockstar!

  • Feroci
  • Joined: 24 Dec 2007
  • None

#10

Posted 23 November 2013 - 05:17 PM

Well one tip I can give is try to convert the input to lower-case before doing any scans on the string. That way you won't have to do it twice for upper or lower and it will work much better, e.g. "aAa" will match "AAA", wheras now your console prefers only upper or only lower casings. You'll also reduce the amount of code... and less code, less problems :p I can't really follow the script much because of all the classes and random parameter orders so you should try writing some debug code (e.g. printing values of variables to ensure they're correct) to locate the exact line where the problem starts.

  • MasterHK likes this

MasterHK
  • MasterHK

    کیان حامی‏

  • Members
  • Joined: 20 Mar 2013
  • Iran

#11

Posted 23 November 2013 - 05:57 PM

Thank you very much for your helps! :)

... and Excuse me for my __!_!__ english!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users