CLEO Help Help with 0470

CLEO related
Status
Not open for further replies.

Kross

Active member
Joined
Dec 15, 2021
Messages
149
Reaction score
42
Hello ugbase family,I am having problems with a certain opcode that says about the current weapon. However in my problem,I can't get it to specify only for 1 weapon(still plays the effect for all,even though I want it on only 1 weapon). If someone can tell me what I do,I will leave the code part in the topic.
PHP:
:Noname_2
0001: wait 0 ms
00D6: if and
80DF:   not actor $PLAYER_ACTOR driving
0AB1:  not @isChatOpen 0
0AB1: not @isDialogOpen 0 ret dType 0@ dId 1@
0470: 9@ = actor $PLAYER_ACTOR current_weapon
if 9@ = 34
0AB0: key_pressed 2
004D: jump_if_false @Noname_2
edit: This 9@ of the Opcode is what I tried to do, but it doesn't have the effect of specifying for 1 weapon.
 

Kross

Active member
Joined
Dec 15, 2021
Messages
149
Reaction score
42
Show all code
PHP:
// This file was decompiled using SASCM.ini published by GTAG (http://gtag.gtagaming.com/opcode-database) on 14.6.2013
{$CLEO .cs}

//-------------MAIN---------------
0000: NOP

:Noname_2
0001: wait 0 ms
00D6: if and
80DF:   not actor $PLAYER_ACTOR driving
0AB1:  not @isChatOpen 0
0AB1: not @isDialogOpen 0 ret dType 0@ dId 1@
02D8:   actor $PLAYER_ACTOR current_weapon == 34
0AB0: key_pressed 2
004D: jump_if_false @Noname_2
0AB1: @ForcePressGameKey 2 _GTASA_Key 5 _isalternatekey false
0002: jump @Noname_2

:isChatOpen
0AA2: 1@ = "samp.dll"
1@ += 0x26E9FC
0A8D: 1@ = readMem 1@ sz 4 vp 0
1@ += 0x14E0
0A8D: 1@ = readMem 1@ sz 4 vp 0
if 1@ <> 0
then
    0485: chat_open
else
    059A: chat_closed
end
0AB2: ret 0

:isDialogOpen
0AA2: 1@ = "samp.dll"
1@ += 0x26E9C8
0A8D: 1@ = readMem 1@ sz 4 vp 0
0A8E: 2@ = 1@ + 0x28
0A8D: 2@ = readMem 2@ sz 4 vp 0
if 2@ == 1
then
    0A8E: 3@ = 1@ + 0x2C //dialogType
    0A8D: 3@ = readMem 3@ sz 4 vp 0
    0A8E: 4@ = 1@ + 0x30 //dialogId
    0A8D: 4@ = readMem 4@ sz 4 vp 0
    0485: dialog_open
    0AB2: ret 2 3@ 4@
else 059A: dialog_closed
end
0AB2: ret 2 -1 -1

:ForcePressGameKey // 0AB1: @ForcePressGameKey 2 _GTASA_Key 0@ _isalternatekey 1@
    0@ *= 2
    if 1@ > 0
    then 0@++ // next byte = alternate key
    end
    0@ += 0xB734D0 // High Priority Controls
    0A8C: write_memory 0@ size 1 value 255 virtual_protect 0
ret 0
 

Saam

Active member
Joined
Apr 18, 2021
Messages
111
Reaction score
62
Location
Argentina
Okey, I tried to change the conditions of the snippets, I don't have much knowledge about this but apparently the mod works correctly, check it yourself, SA-MP R1
PHP:
{$CLEO .cs}

0000: NOP

WAIT 8500

WHILE TRUE
WAIT 0
               
IF AND
  0AB1: @isDialogClosed 0 ret dType 0@ dId 1@
  0AB1: @isChatClosed 0
  THEN
      IF 0AB0: key_pressed 2
  THEN
      IF 02D8:   actor $PLAYER_ACTOR current_weapon == 34
  THEN
      0AB1: @ForcePressGameKey 2 _GTASA_Key 5 _isalternatekey false
         
         end
      end
   end  
END // WHILE TRUE

:isChatClosed
0AA2: 1@ = "samp.dll"
1@ += 0x21A0E8
0A8D: 1@ = readMem 1@ sz 4 vp 0
1@ += 0x14E0
0A8D: 1@ = readMem 1@ sz 4 vp 0
if not 1@ <> 0
then
    0485: chat_closed
else
    059A: chat_open
end
0AB2: ret 0

:isDialogClosed
0AA2: 1@ = "samp.dll"
1@ += 0x21A0B8
0A8D: 1@ = readMem 1@ sz 4 vp 0
0A8E: 2@ = 1@ + 0x28
0A8D: 2@ = readMem 2@ sz 4 vp 0
if 2@ == 0
then
    0485:  dialog_closed
else
    0A8E: 3@ = 1@ + 0x2C //dialogType
    0A8D: 3@ = readMem 3@ sz 4 vp 0
    0A8E: 4@ = 1@ + 0x30 //dialogId
    0A8D: 4@ = readMem 4@ sz 4 vp 0
    059A: dialog_open
    0AB2: ret 2 3@ 4@
end
0AB2: ret 2 -1 -1

:ForcePressGameKey // 0AB1: @ForcePressGameKey 2 _GTASA_Key 0@ _isalternatekey 1@
    0@ *= 2
    if 1@ > 0
    then 0@++ // next byte = alternate key
    end
    0@ += 0xB734D0 // High Priority Controls
    0A8C: write_memory 0@ size 1 value 255 virtual_protect 0
ret 0
Maybe someone can improve the code.
 
Last edited:

Kross

Active member
Joined
Dec 15, 2021
Messages
149
Reaction score
42
Okey, I tried to change the conditions of the snippets, I don't have much knowledge about this but apparently the mod works correctly, check it yourself
PHP:
{$CLEO .cs}

0000: NOP

WAIT 8500

WHILE TRUE
WAIT 0
               
IF AND
  0AB1: @isDialogClosed 0 ret dType 0@ dId 1@
  0AB1: @isChatClosed 0
  THEN
      IF 0AB0: key_pressed 2
  THEN
      IF 02D8:   actor $PLAYER_ACTOR current_weapon == 34
  THEN
      0AB1: @ForcePressGameKey 2 _GTASA_Key 5 _isalternatekey false
         
         end
      end
   end  
END // WHILE TRUE

:isChatClosed
0AA2: 1@ = "samp.dll"
1@ += 0x21A0E8
0A8D: 1@ = readMem 1@ sz 4 vp 0
1@ += 0x14E0
0A8D: 1@ = readMem 1@ sz 4 vp 0
if not 1@ <> 0
then
    0485: chat_closed
else
    059A: chat_open
end
0AB2: ret 0

:isDialogClosed
0AA2: 1@ = "samp.dll"
1@ += 0x21A0B8
0A8D: 1@ = readMem 1@ sz 4 vp 0
0A8E: 2@ = 1@ + 0x28
0A8D: 2@ = readMem 2@ sz 4 vp 0
if 2@ == 0
then
    0485:  dialog_closed
else
    0A8E: 3@ = 1@ + 0x2C //dialogType
    0A8D: 3@ = readMem 3@ sz 4 vp 0
    0A8E: 4@ = 1@ + 0x30 //dialogId
    0A8D: 4@ = readMem 4@ sz 4 vp 0
    059A: dialog_open
    0AB2: ret 2 3@ 4@
end
0AB2: ret 2 -1 -1

:ForcePressGameKey // 0AB1: @ForcePressGameKey 2 _GTASA_Key 0@ _isalternatekey 1@
    0@ *= 2
    if 1@ > 0
    then 0@++ // next byte = alternate key
    end
    0@ += 0xB734D0 // High Priority Controls
    0A8C: write_memory 0@ size 1 value 255 virtual_protect 0
ret 0
Maybe someone can improve the code.
This code crashes for me. But no problem brother, what matters is the attempt to help. Thanks a lot
 

Saam

Active member
Joined
Apr 18, 2021
Messages
111
Reaction score
62
Location
Argentina
This code crashes for me. But no problem brother, what matters is the attempt to help. Thanks a lot
Try this, SA-MP R4
PHP:
{$CLEO .cs}

0000: NOP

WAIT 8500

WHILE TRUE
WAIT 0
               
IF AND
  0AB1: @isDialogClosed 0 ret dType 0@ dId 1@
  0AB1: @isChatClosed 0
  THEN
      IF 0AB0: key_pressed 2
  THEN
      IF 02D8:   actor $PLAYER_ACTOR current_weapon == 34
  THEN
      0AB1: @ForcePressGameKey 2 _GTASA_Key 5 _isalternatekey false        
         end
      end
   end  
END // WHILE TRUE

:isChatClosed
0AA2: 1@ = "samp.dll"
1@ += 0x26E9FC
0A8D: 1@ = readMem 1@ sz 4 vp 0
1@ += 0x14E0
0A8D: 1@ = readMem 1@ sz 4 vp 0
if not 1@ <> 0
then
    0485: chat_closed
else
    059A: chat_open
end
0AB2: ret 0

:isDialogClosed
0AA2: 1@ = "samp.dll"
1@ += 0x26E9C8
0A8D: 1@ = readMem 1@ sz 4 vp 0
0A8E: 2@ = 1@ + 0x28
0A8D: 2@ = readMem 2@ sz 4 vp 0
if 2@ == 0
then
    0485:  dialog_closed
else
    0A8E: 3@ = 1@ + 0x2C //dialogType
    0A8D: 3@ = readMem 3@ sz 4 vp 0
    0A8E: 4@ = 1@ + 0x30 //dialogId
    0A8D: 4@ = readMem 4@ sz 4 vp 0
    059A: dialog_open
    0AB2: ret 2 3@ 4@
end
0AB2: ret 2 -1 -1

:ForcePressGameKey // 0AB1: @ForcePressGameKey 2 _GTASA_Key 0@ _isalternatekey 1@
    0@ *= 2
    if 1@ > 0
    then 0@++ // next byte = alternate key
    end
    0@ += 0xB734D0 // High Priority Controls
    0A8C: write_memory 0@ size 1 value 255 virtual_protect 0
ret 0
 

Kross

Active member
Joined
Dec 15, 2021
Messages
149
Reaction score
42
Try this, SA-MP R4
PHP:
{$CLEO .cs}

0000: NOP

WAIT 8500

WHILE TRUE
WAIT 0
              
IF AND
  0AB1: @isDialogClosed 0 ret dType 0@ dId 1@
  0AB1: @isChatClosed 0
  THEN
      IF 0AB0: key_pressed 2
  THEN
      IF 02D8:   actor $PLAYER_ACTOR current_weapon == 34
  THEN
      0AB1: @ForcePressGameKey 2 _GTASA_Key 5 _isalternatekey false       
         end
      end
   end 
END // WHILE TRUE

:isChatClosed
0AA2: 1@ = "samp.dll"
1@ += 0x26E9FC
0A8D: 1@ = readMem 1@ sz 4 vp 0
1@ += 0x14E0
0A8D: 1@ = readMem 1@ sz 4 vp 0
if not 1@ <> 0
then
    0485: chat_closed
else
    059A: chat_open
end
0AB2: ret 0

:isDialogClosed
0AA2: 1@ = "samp.dll"
1@ += 0x26E9C8
0A8D: 1@ = readMem 1@ sz 4 vp 0
0A8E: 2@ = 1@ + 0x28
0A8D: 2@ = readMem 2@ sz 4 vp 0
if 2@ == 0
then
    0485:  dialog_closed
else
    0A8E: 3@ = 1@ + 0x2C //dialogType
    0A8D: 3@ = readMem 3@ sz 4 vp 0
    0A8E: 4@ = 1@ + 0x30 //dialogId
    0A8D: 4@ = readMem 4@ sz 4 vp 0
    059A: dialog_open
    0AB2: ret 2 3@ 4@
end
0AB2: ret 2 -1 -1

:ForcePressGameKey // 0AB1: @ForcePressGameKey 2 _GTASA_Key 0@ _isalternatekey 1@
    0@ *= 2
    if 1@ > 0
    then 0@++ // next byte = alternate key
    end
    0@ += 0xB734D0 // High Priority Controls
    0A8C: write_memory 0@ size 1 value 255 virtual_protect 0
ret 0
Man,what is this magic that you keep? It worked perfectly,thank you brother.
 
Status
Not open for further replies.
Top